|
|
|
|
@@ -27,39 +27,43 @@ __url__ = "https://www.freecadweb.org"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def write_femelement_geometry(f, ccxwriter):
|
|
|
|
|
|
|
|
|
|
# floats read from ccx should use {:.13G}, see comment in writer module
|
|
|
|
|
|
|
|
|
|
f.write("\n{}\n".format(59 * "*"))
|
|
|
|
|
f.write("** Sections\n")
|
|
|
|
|
for ccx_elset in ccxwriter.ccx_elsets:
|
|
|
|
|
if ccx_elset["ccx_elset"]:
|
|
|
|
|
elsetdef = "ELSET={}, ".format(ccx_elset["ccx_elset_name"])
|
|
|
|
|
material = "MATERIAL={}".format(ccx_elset["mat_obj_name"])
|
|
|
|
|
|
|
|
|
|
if "beamsection_obj"in ccx_elset: # beam mesh
|
|
|
|
|
beamsec_obj = ccx_elset["beamsection_obj"]
|
|
|
|
|
elsetdef = "ELSET=" + ccx_elset["ccx_elset_name"] + ", "
|
|
|
|
|
material = "MATERIAL=" + ccx_elset["mat_obj_name"]
|
|
|
|
|
normal = ccx_elset["beam_normal"]
|
|
|
|
|
if beamsec_obj.SectionType == "Rectangular":
|
|
|
|
|
height = beamsec_obj.RectHeight.getValueAs("mm")
|
|
|
|
|
width = beamsec_obj.RectWidth.getValueAs("mm")
|
|
|
|
|
height = beamsec_obj.RectHeight.getValueAs("mm").Value
|
|
|
|
|
width = beamsec_obj.RectWidth.getValueAs("mm").Value
|
|
|
|
|
section_type = ", SECTION=RECT"
|
|
|
|
|
section_geo = str(height) + ", " + str(width) + "\n"
|
|
|
|
|
section_geo = "{:.13G},{:.13G}\n".format(height, width)
|
|
|
|
|
section_def = "*BEAM SECTION, {}{}{}\n".format(
|
|
|
|
|
elsetdef,
|
|
|
|
|
material,
|
|
|
|
|
section_type
|
|
|
|
|
)
|
|
|
|
|
elif beamsec_obj.SectionType == "Circular":
|
|
|
|
|
radius = 0.5 * beamsec_obj.CircDiameter.getValueAs("mm")
|
|
|
|
|
radius = 0.5 * beamsec_obj.CircDiameter.getValueAs("mm").Value
|
|
|
|
|
section_type = ", SECTION=CIRC"
|
|
|
|
|
section_geo = str(radius) + "\n"
|
|
|
|
|
section_geo = "{:.13G}\n".format(radius)
|
|
|
|
|
section_def = "*BEAM SECTION, {}{}{}\n".format(
|
|
|
|
|
elsetdef,
|
|
|
|
|
material,
|
|
|
|
|
section_type
|
|
|
|
|
)
|
|
|
|
|
elif beamsec_obj.SectionType == "Pipe":
|
|
|
|
|
radius = 0.5 * beamsec_obj.PipeDiameter.getValueAs("mm")
|
|
|
|
|
thickness = beamsec_obj.PipeThickness.getValueAs("mm")
|
|
|
|
|
radius = 0.5 * beamsec_obj.PipeDiameter.getValueAs("mm").Value
|
|
|
|
|
thickness = beamsec_obj.PipeThickness.getValueAs("mm").Value
|
|
|
|
|
section_type = ", SECTION=PIPE"
|
|
|
|
|
section_geo = str(radius) + ", " + str(thickness) + "\n"
|
|
|
|
|
section_geo = "{:.13G},{:.13G}\n".format(radius, thickness)
|
|
|
|
|
section_def = "*BEAM GENERAL SECTION, {}{}{}\n".format(
|
|
|
|
|
elsetdef,
|
|
|
|
|
material,
|
|
|
|
|
@@ -67,7 +71,7 @@ def write_femelement_geometry(f, ccxwriter):
|
|
|
|
|
)
|
|
|
|
|
# see forum topic for output formatting of rotation
|
|
|
|
|
# https://forum.freecadweb.org/viewtopic.php?f=18&t=46133&p=405142#p405142
|
|
|
|
|
section_nor = "{:f}, {:f}, {:f}\n".format(
|
|
|
|
|
section_nor = "{:.13G}, {:.13G}, {:.13G}\n".format(
|
|
|
|
|
normal[0],
|
|
|
|
|
normal[1],
|
|
|
|
|
normal[2]
|
|
|
|
|
@@ -77,8 +81,6 @@ def write_femelement_geometry(f, ccxwriter):
|
|
|
|
|
f.write(section_nor)
|
|
|
|
|
elif "fluidsection_obj"in ccx_elset: # fluid mesh
|
|
|
|
|
fluidsec_obj = ccx_elset["fluidsection_obj"]
|
|
|
|
|
elsetdef = "ELSET=" + ccx_elset["ccx_elset_name"] + ", "
|
|
|
|
|
material = "MATERIAL=" + ccx_elset["mat_obj_name"]
|
|
|
|
|
if fluidsec_obj.SectionType == "Liquid":
|
|
|
|
|
section_type = fluidsec_obj.LiquidSectionType
|
|
|
|
|
if (section_type == "PIPE INLET") or (section_type == "PIPE OUTLET"):
|
|
|
|
|
@@ -101,16 +103,13 @@ def write_femelement_geometry(f, ccxwriter):
|
|
|
|
|
f.write(section_geo)
|
|
|
|
|
elif "shellthickness_obj"in ccx_elset: # shell mesh
|
|
|
|
|
shellth_obj = ccx_elset["shellthickness_obj"]
|
|
|
|
|
elsetdef = "ELSET=" + ccx_elset["ccx_elset_name"] + ", "
|
|
|
|
|
material = "MATERIAL=" + ccx_elset["mat_obj_name"]
|
|
|
|
|
section_def = "*SHELL SECTION, " + elsetdef + material + "\n"
|
|
|
|
|
section_geo = str(shellth_obj.Thickness.getValueAs("mm")) + "\n"
|
|
|
|
|
section_def = "*SHELL SECTION, {}{}\n".format(elsetdef, material)
|
|
|
|
|
thickness = shellth_obj.Thickness.getValueAs("mm").Value
|
|
|
|
|
section_geo = "{:.13G}\n".format(thickness)
|
|
|
|
|
f.write(section_def)
|
|
|
|
|
f.write(section_geo)
|
|
|
|
|
else: # solid mesh
|
|
|
|
|
elsetdef = "ELSET=" + ccx_elset["ccx_elset_name"] + ", "
|
|
|
|
|
material = "MATERIAL=" + ccx_elset["mat_obj_name"]
|
|
|
|
|
section_def = "*SOLID SECTION, " + elsetdef + material + "\n"
|
|
|
|
|
section_def = "*SOLID SECTION, {}{}\n".format(elsetdef, material)
|
|
|
|
|
f.write(section_def)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -118,37 +117,41 @@ def write_femelement_geometry(f, ccxwriter):
|
|
|
|
|
# Helpers
|
|
|
|
|
def liquid_section_def(obj, section_type):
|
|
|
|
|
if section_type == "PIPE MANNING":
|
|
|
|
|
manning_area = str(obj.ManningArea.getValueAs("mm^2").Value)
|
|
|
|
|
manning_radius = str(obj.ManningRadius.getValueAs("mm"))
|
|
|
|
|
manning_coefficient = str(obj.ManningCoefficient)
|
|
|
|
|
section_geo = manning_area + "," + manning_radius + "," + manning_coefficient + "\n"
|
|
|
|
|
manning_area = obj.ManningArea.getValueAs("mm^2").Value
|
|
|
|
|
manning_radius = obj.ManningRadius.getValueAs("mm").Value
|
|
|
|
|
manning_coefficient = obj.ManningCoefficient
|
|
|
|
|
section_geo = "{:.13G},{:.13G},{:.13G}\n".format(
|
|
|
|
|
manning_area,
|
|
|
|
|
manning_radius,
|
|
|
|
|
manning_coefficient
|
|
|
|
|
)
|
|
|
|
|
return section_geo
|
|
|
|
|
elif section_type == "PIPE ENLARGEMENT":
|
|
|
|
|
enlarge_area1 = str(obj.EnlargeArea1.getValueAs("mm^2").Value)
|
|
|
|
|
enlarge_area2 = str(obj.EnlargeArea2.getValueAs("mm^2").Value)
|
|
|
|
|
section_geo = enlarge_area1 + "," + enlarge_area2 + "\n"
|
|
|
|
|
enlarge_area1 = obj.EnlargeArea1.getValueAs("mm^2").Value
|
|
|
|
|
enlarge_area2 = obj.EnlargeArea2.getValueAs("mm^2").Value
|
|
|
|
|
section_geo = "{:.13G},{:.13G}\n".format(enlarge_area1, enlarge_area2)
|
|
|
|
|
return section_geo
|
|
|
|
|
elif section_type == "PIPE CONTRACTION":
|
|
|
|
|
contract_area1 = str(obj.ContractArea1.getValueAs("mm^2").Value)
|
|
|
|
|
contract_area2 = str(obj.ContractArea2.getValueAs("mm^2").Value)
|
|
|
|
|
section_geo = contract_area1 + "," + contract_area2 + "\n"
|
|
|
|
|
contract_area1 = obj.ContractArea1.getValueAs("mm^2").Value
|
|
|
|
|
contract_area2 = obj.ContractArea2.getValueAs("mm^2").Value
|
|
|
|
|
section_geo = "{:.13G},{:.13G}\n".format(contract_area1, contract_area2)
|
|
|
|
|
return section_geo
|
|
|
|
|
elif section_type == "PIPE ENTRANCE":
|
|
|
|
|
entrance_pipe_area = str(obj.EntrancePipeArea.getValueAs("mm^2").Value)
|
|
|
|
|
entrance_area = str(obj.EntranceArea.getValueAs("mm^2").Value)
|
|
|
|
|
section_geo = entrance_pipe_area + "," + entrance_area + "\n"
|
|
|
|
|
entrance_pipe_area = obj.EntrancePipeArea.getValueAs("mm^2").Value
|
|
|
|
|
entrance_area = obj.EntranceArea.getValueAs("mm^2").Value
|
|
|
|
|
section_geo = "{:.13G},{:.13G}\n".format(entrance_pipe_area, entrance_area)
|
|
|
|
|
return section_geo
|
|
|
|
|
elif section_type == "PIPE DIAPHRAGM":
|
|
|
|
|
diaphragm_pipe_area = str(obj.DiaphragmPipeArea.getValueAs("mm^2").Value)
|
|
|
|
|
diaphragm_area = str(obj.DiaphragmArea.getValueAs("mm^2").Value)
|
|
|
|
|
section_geo = diaphragm_pipe_area + "," + diaphragm_area + "\n"
|
|
|
|
|
diaphragm_pipe_area = obj.DiaphragmPipeArea.getValueAs("mm^2").Value
|
|
|
|
|
diaphragm_area = obj.DiaphragmArea.getValueAs("mm^2").Value
|
|
|
|
|
section_geo = "{:.13G},{:.13G}\n".format(diaphragm_pipe_area, diaphragm_area)
|
|
|
|
|
return section_geo
|
|
|
|
|
elif section_type == "PIPE BEND":
|
|
|
|
|
bend_pipe_area = str(obj.BendPipeArea.getValueAs("mm^2").Value)
|
|
|
|
|
bend_radius_diameter = str(obj.BendRadiusDiameter)
|
|
|
|
|
bend_angle = str(obj.BendAngle)
|
|
|
|
|
bend_loss_coefficient = str(obj.BendLossCoefficient)
|
|
|
|
|
section_geo = ("{},{},{},{}\n".format(
|
|
|
|
|
bend_pipe_area = obj.BendPipeArea.getValueAs("mm^2").Value
|
|
|
|
|
bend_radius_diameter = obj.BendRadiusDiameter
|
|
|
|
|
bend_angle = obj.BendAngle
|
|
|
|
|
bend_loss_coefficient = obj.BendLossCoefficient
|
|
|
|
|
section_geo = ("{:.13G},{:.13G},{:.13G},{:.13G}\n".format(
|
|
|
|
|
bend_pipe_area,
|
|
|
|
|
bend_radius_diameter,
|
|
|
|
|
bend_angle,
|
|
|
|
|
@@ -156,16 +159,16 @@ def liquid_section_def(obj, section_type):
|
|
|
|
|
))
|
|
|
|
|
return section_geo
|
|
|
|
|
elif section_type == "PIPE GATE VALVE":
|
|
|
|
|
gatevalve_pipe_area = str(obj.GateValvePipeArea.getValueAs("mm^2").Value)
|
|
|
|
|
gatevalve_closing_coeff = str(obj.GateValveClosingCoeff)
|
|
|
|
|
section_geo = gatevalve_pipe_area + "," + gatevalve_closing_coeff + "\n"
|
|
|
|
|
gatevalve_pipe_area = obj.GateValvePipeArea.getValueAs("mm^2").Value
|
|
|
|
|
gatevalve_closing_coeff = obj.GateValveClosingCoeff
|
|
|
|
|
section_geo = "{:.13G},{:.13G}\n".format(gatevalve_pipe_area, gatevalve_closing_coeff)
|
|
|
|
|
return section_geo
|
|
|
|
|
elif section_type == "PIPE WHITE-COLEBROOK":
|
|
|
|
|
colebrooke_area = str(obj.ColebrookeArea.getValueAs("mm^2").Value)
|
|
|
|
|
colebrooke_diameter = str(2 * obj.ColebrookeRadius.getValueAs("mm"))
|
|
|
|
|
colebrooke_grain_diameter = str(obj.ColebrookeGrainDiameter.getValueAs("mm"))
|
|
|
|
|
colebrooke_form_factor = str(obj.ColebrookeFormFactor)
|
|
|
|
|
section_geo = ("{},{},{},{},{}\n".format(
|
|
|
|
|
colebrooke_area = obj.ColebrookeArea.getValueAs("mm^2").Value
|
|
|
|
|
colebrooke_diameter = 2 * obj.ColebrookeRadius.getValueAs("mm")
|
|
|
|
|
colebrooke_grain_diameter = obj.ColebrookeGrainDiameter.getValueAs("mm")
|
|
|
|
|
colebrooke_form_factor = obj.ColebrookeFormFactor
|
|
|
|
|
section_geo = ("{:.13G},{:.13G},{},{:.13G},{:.13G}\n".format(
|
|
|
|
|
colebrooke_area,
|
|
|
|
|
colebrooke_diameter,
|
|
|
|
|
"-1",
|
|
|
|
|
@@ -176,10 +179,10 @@ def liquid_section_def(obj, section_type):
|
|
|
|
|
elif section_type == "LIQUID PUMP":
|
|
|
|
|
section_geo = ""
|
|
|
|
|
for i in range(len(obj.PumpFlowRate)):
|
|
|
|
|
flow_rate = str(obj.PumpFlowRate[i])
|
|
|
|
|
top = str(obj.PumpHeadLoss[i])
|
|
|
|
|
section_geo = section_geo + flow_rate + "," + top + ","
|
|
|
|
|
section_geo = section_geo + "\n"
|
|
|
|
|
flow_rate = obj.PumpFlowRate[i]
|
|
|
|
|
top = obj.PumpHeadLoss[i]
|
|
|
|
|
section_geo = "{:.13G},{:.13G},\n".format(section_geo + flow_rate, top)
|
|
|
|
|
section_geo = "{}\n".format(section_geo)
|
|
|
|
|
return section_geo
|
|
|
|
|
else:
|
|
|
|
|
return ""
|
|
|
|
|
|