| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | __title__ = "FreeCAD FEM calculix constraint fluidsection" |
| | __author__ = "Bernd Hahnebach" |
| | __url__ = "https://www.freecad.org" |
| |
|
| |
|
| | import codecs |
| | import os |
| | from os.path import join |
| |
|
| | import FreeCAD |
| |
|
| | from femmesh import meshtools |
| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | def handle_fluidsection_liquid_inlet_outlet(inpfile, ccxwriter): |
| |
|
| | if not ccxwriter.member.geos_fluidsection: |
| | return inpfile |
| |
|
| | |
| | |
| | |
| | |
| | |
| |
|
| | ccxwriter.FluidInletoutlet_ele = [] |
| | ccxwriter.fluid_inout_nodes_file = join( |
| | ccxwriter.dir_name, f"{ccxwriter.mesh_name}_inout_nodes.txt" |
| | ) |
| |
|
| | def get_fluidsection_inoutlet_obj_if_setdata(matgeoset): |
| | if ( |
| | matgeoset["ccx_elset"] |
| | and not isinstance(matgeoset["ccx_elset"], str) |
| | and "fluidsection_obj" in matgeoset |
| | ): |
| | fluidsec_obj = matgeoset["fluidsection_obj"] |
| | if fluidsec_obj.SectionType == "Liquid" and ( |
| | fluidsec_obj.LiquidSectionType == "PIPE INLET" |
| | or fluidsec_obj.LiquidSectionType == "PIPE OUTLET" |
| | ): |
| | return fluidsec_obj |
| | return None |
| |
|
| | def is_fluidsection_inoutlet_setnames_possible(mat_geo_sets): |
| | for matgeoset in mat_geo_sets: |
| | if matgeoset["ccx_elset"] and "fluidsection_obj" in matgeoset: |
| | fluidsec_obj = matgeoset["fluidsection_obj"] |
| | if fluidsec_obj.SectionType == "Liquid" and ( |
| | fluidsec_obj.LiquidSectionType == "PIPE INLET" |
| | or fluidsec_obj.LiquidSectionType == "PIPE OUTLET" |
| | ): |
| | return True |
| | return False |
| |
|
| | |
| | |
| | for matgeoset in ccxwriter.mat_geo_sets: |
| | fluidsec_obj = get_fluidsection_inoutlet_obj_if_setdata(matgeoset) |
| | if fluidsec_obj is None: |
| | continue |
| | elsetchanged = False |
| | counter = 0 |
| | for elid in matgeoset["ccx_elset"]: |
| | counter = counter + 1 |
| | if (elsetchanged is False) and (fluidsec_obj.LiquidSectionType == "PIPE INLET"): |
| | |
| | ccxwriter.FluidInletoutlet_ele.append( |
| | [str(elid), fluidsec_obj.LiquidSectionType, 0] |
| | ) |
| | elsetchanged = True |
| | elif (fluidsec_obj.LiquidSectionType == "PIPE OUTLET") and ( |
| | counter == len(matgeoset["ccx_elset"]) |
| | ): |
| | |
| | ccxwriter.FluidInletoutlet_ele.append( |
| | [str(elid), fluidsec_obj.LiquidSectionType, 0] |
| | ) |
| |
|
| | |
| | |
| | |
| | if is_fluidsection_inoutlet_setnames_possible(ccxwriter.mat_geo_sets) is not None: |
| | |
| | |
| | inpfile.close() |
| | meshtools.use_correct_fluidinout_ele_def( |
| | ccxwriter.FluidInletoutlet_ele, ccxwriter.femmesh_file, ccxwriter.fluid_inout_nodes_file |
| | ) |
| | inpfile = codecs.open(ccxwriter.file_name, "a", encoding="utf-8") |
| |
|
| | return inpfile |
| |
|
| |
|
| | |
| | |
| | |
| | |
| | def write_constraints_fluidsection(f, ccxwriter): |
| | if not ccxwriter.member.geos_fluidsection: |
| | return |
| | if ccxwriter.analysis_type not in ["thermomech"]: |
| | return |
| |
|
| | |
| | f.write("\n***********************************************************\n") |
| | f.write("** FluidSection constraints\n") |
| | if os.path.exists(ccxwriter.fluid_inout_nodes_file): |
| | inout_nodes_file = open(ccxwriter.fluid_inout_nodes_file) |
| | lines = inout_nodes_file.readlines() |
| | inout_nodes_file.close() |
| | else: |
| | FreeCAD.Console.PrintError( |
| | f"1DFlow inout nodes file not found: {ccxwriter.fluid_inout_nodes_file}\n" |
| | ) |
| | |
| | ccxwriter.get_constraints_fluidsection_nodes() |
| | for femobj in ccxwriter.member.geos_fluidsection: |
| | |
| | fluidsection_obj = femobj["Object"] |
| | f.write("** " + fluidsection_obj.Label + "\n") |
| | if fluidsection_obj.SectionType == "Liquid": |
| | if fluidsection_obj.LiquidSectionType == "PIPE INLET": |
| | f.write("**Fluid Section Inlet \n") |
| | if fluidsection_obj.InletPressureActive is True: |
| | f.write("*BOUNDARY \n") |
| | for n in femobj["Nodes"]: |
| | for line in lines: |
| | b = line.split(",") |
| | if int(b[0]) == n and b[3] == "PIPE INLET\n": |
| | |
| | f.write( |
| | "{},{},{},{}\n".format( |
| | b[0], "2", "2", fluidsection_obj.InletPressure |
| | ) |
| | ) |
| | if fluidsection_obj.InletFlowRateActive is True: |
| | f.write("*BOUNDARY,MASS FLOW \n") |
| | for n in femobj["Nodes"]: |
| | for line in lines: |
| | b = line.split(",") |
| | if int(b[0]) == n and b[3] == "PIPE INLET\n": |
| | |
| | |
| | f.write( |
| | "{},{},{},{}\n".format( |
| | b[1], "1", "1", fluidsection_obj.InletFlowRate * 0.001 |
| | ) |
| | ) |
| | elif fluidsection_obj.LiquidSectionType == "PIPE OUTLET": |
| | f.write("**Fluid Section Outlet \n") |
| | if fluidsection_obj.OutletPressureActive is True: |
| | f.write("*BOUNDARY \n") |
| | for n in femobj["Nodes"]: |
| | for line in lines: |
| | b = line.split(",") |
| | if int(b[0]) == n and b[3] == "PIPE OUTLET\n": |
| | |
| | f.write( |
| | "{},{},{},{}\n".format( |
| | b[0], "2", "2", fluidsection_obj.OutletPressure |
| | ) |
| | ) |
| | if fluidsection_obj.OutletFlowRateActive is True: |
| | f.write("*BOUNDARY,MASS FLOW \n") |
| | for n in femobj["Nodes"]: |
| | for line in lines: |
| | b = line.split(",") |
| | if int(b[0]) == n and b[3] == "PIPE OUTLET\n": |
| | |
| | |
| | f.write( |
| | "{},{},{},{}\n".format( |
| | b[1], "1", "1", fluidsection_obj.OutletFlowRate * 0.001 |
| | ) |
| | ) |
| |
|