Skip to content

Commit 3bed526

Browse files
committed
Fem: Load heat flux from CalculiX results - fixes FreeCAD#12117
1 parent cf57d0a commit 3bed526

File tree

5 files changed

+43
-3
lines changed

5 files changed

+43
-3
lines changed

src/Mod/Fem/App/FemVTKTools.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,7 @@ std::map<std::string, std::string> _getFreeCADMechResultVectorProperties()
659659
resFCVecProp["PS1Vector"] = "Major Principal Stress Vector";
660660
resFCVecProp["PS2Vector"] = "Intermediate Principal Stress Vector";
661661
resFCVecProp["PS3Vector"] = "Minor Principal Stress Vector";
662+
resFCVecProp["HeatFlux"] = "Heat Flux";
662663

663664
return resFCVecProp;
664665
}

src/Mod/Fem/feminout/importCcxFrdResults.py

+21
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ def read_frd_result(
311311
mode_strain = {}
312312
mode_peeq = {}
313313
mode_temp = {}
314+
mode_heatflux = {}
314315
mode_massflow = {}
315316
mode_networkpressure = {}
316317

@@ -322,6 +323,7 @@ def read_frd_result(
322323
mode_strain_found = False
323324
mode_peeq_found = False
324325
mode_temp_found = False
326+
mode_heatflux_found = False
325327
mode_massflow_found = False
326328
mode_networkpressure_found = False
327329
end_of_section_found = False
@@ -641,6 +643,19 @@ def read_frd_result(
641643
temperature = float(line[13:25])
642644
mode_temp[elem] = (temperature)
643645

646+
# Check if we found heat flux section
647+
if line[5:9] == "FLUX":
648+
mode_heatflux_found = True
649+
if mode_heatflux_found and (line[1:3] == "-1"):
650+
# we found a heat_flux line
651+
elem = int(line[4:13])
652+
mode_heatflux_x = float(line[13:25])
653+
mode_heatflux_y = float(line[25:37])
654+
mode_heatflux_z = float(line[37:49])
655+
mode_heatflux[elem] = FreeCAD.Vector(mode_heatflux_x, mode_heatflux_y, mode_heatflux_z)
656+
657+
658+
644659
# Check if we found a mass flow section
645660
if line[5:11] == "MAFLOW":
646661
mode_massflow_found = True
@@ -713,6 +728,12 @@ def read_frd_result(
713728
mode_temp_found = False
714729
node_element_section = False
715730

731+
if mode_heatflux_found:
732+
mode_results["heatflux"] = mode_heatflux
733+
mode_heatflux = {}
734+
mode_heatflux_found = False
735+
node_element_section = False
736+
716737
if mode_massflow_found:
717738
mode_results["mflow"] = mode_massflow
718739
mode_massflow = {}

src/Mod/Fem/feminout/importToolsFem.py

+5
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,11 @@ def fill_femresult_mechanical(
455455
res_obj.Temperature = list(map((lambda x: x), Temperature.values()))
456456
res_obj.Time = step_time
457457

458+
if "heatflux" in result_set:
459+
HeatFlux = result_set["heatflux"]
460+
if HeatFlux:
461+
res_obj.HeatFlux = list(map((lambda x: x), HeatFlux.values()))
462+
458463
# fill res_obj.MassFlow
459464
if "mflow" in result_set:
460465
MassFlow = result_set["mflow"]

src/Mod/Fem/femobjects/result_mechanical.py

+10
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,16 @@ def __init__(self, obj):
230230
"Temperature field",
231231
True
232232
)
233+
obj.addProperty(
234+
"App::PropertyVectorList",
235+
"HeatFlux",
236+
"NodeData",
237+
"List of heat flux vectors",
238+
True
239+
)
240+
obj.setPropertyStatus("HeatFlux", "LockDynamic")
241+
242+
233243
obj.setPropertyStatus("Temperature", "LockDynamic")
234244
obj.addProperty(
235245
"App::PropertyFloatList",

src/Mod/Fem/femsolver/calculix/write_step_output.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,13 @@ def write_step_output(f, ccxwriter):
5151
f.write("U\n")
5252
if not ccxwriter.member.geos_fluidsection:
5353
f.write("*EL FILE\n")
54+
variables = "S, E"
55+
if ccxwriter.analysis_type == "thermomech":
56+
variables += ", HFL"
5457
if ccxwriter.solver_obj.MaterialNonlinearity == "nonlinear":
55-
f.write("S, E, PEEQ\n")
56-
else:
57-
f.write("S, E\n")
58+
variables += ", PEEQ"
59+
60+
f.write(variables + "\n")
5861

5962
# dat file
6063
# reaction forces: freecad.org/tracker/view.php?id=2934

0 commit comments

Comments
 (0)