Fem: Add options for Elmer solver output file - fixes #17569

This commit is contained in:
marioalexis
2024-11-19 10:25:21 -03:00
committed by Chris Hennes
parent 5266a3b26d
commit babc88f40d
10 changed files with 118 additions and 4 deletions

View File

@@ -286,6 +286,53 @@ will be merged to make the volume boundaries invisible.</string>
</widget>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="gb_elmer_results">
<property name="title">
<string>Results</string>
</property>
<layout class="QGridLayout" name="gdl_results">
<item row="0" column="0">
<widget class="Gui::PrefCheckBox" name="ckb_elmer_format">
<property name="toolTip">
<string>Save result in binary format</string>
</property>
<property name="text">
<string>Use binary format</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>BinaryOutput</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Fem/Elmer</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="Gui::PrefCheckBox" name="ckb_elmer_geom_id">
<property name="toolTip">
<string>Save the index of geometric entities</string>
</property>
<property name="text">
<string>Save geometry IDs</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>SaveGeometryIndex</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Fem/Elmer</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>

View File

@@ -74,6 +74,8 @@ void DlgSettingsFemElmerImp::saveSettings()
ui->sb_elmer_num_cores->onSave();
ui->cb_elmer_filtering->onSave();
ui->ckb_elmer_format->onSave();
ui->ckb_elmer_geom_id->onSave();
}
void DlgSettingsFemElmerImp::loadSettings()
@@ -86,6 +88,8 @@ void DlgSettingsFemElmerImp::loadSettings()
ui->sb_elmer_num_cores->onRestore();
ui->cb_elmer_filtering->onRestore();
ui->ckb_elmer_format->onRestore();
ui->ckb_elmer_geom_id->onRestore();
}
/**

View File

@@ -1076,7 +1076,33 @@ class _SolverElmer(CommandManager):
self.accel = "S, E"
self.tooltip = Qt.QT_TRANSLATE_NOOP("FEM_SolverElmer", "Creates a FEM solver Elmer")
self.is_active = "with_analysis"
self.do_activated = "add_obj_on_gui_expand_noset_edit"
def Activated(self):
FreeCAD.ActiveDocument.openTransaction(f"Create Fem SolverElmer")
FreeCADGui.addModule("ObjectsFem")
FreeCADGui.addModule("FemGui")
# expand parent obj in tree view if selected
expandParentObject()
# add the object
FreeCADGui.doCommand("ObjectsFem.makeSolverElmer(FreeCAD.ActiveDocument)")
# select only added object
FreeCADGui.doCommand(
"FemGui.getActiveAnalysis().addObject(FreeCAD.ActiveDocument.ActiveObject)"
)
elmer_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem/Elmer")
bin_out = elmer_prefs.GetBool("BinaryOutput", False)
save_id = elmer_prefs.GetBool("SaveGeometryIndex", False)
FreeCADGui.doCommand(
"FreeCAD.ActiveDocument.ActiveObject.BinaryOutput = {}".format(bin_out)
)
FreeCADGui.doCommand(
"FreeCAD.ActiveDocument.ActiveObject.SaveGeometryIndex = {}".format(save_id)
)
FreeCADGui.Selection.clearSelection()
FreeCADGui.doCommand(
"FreeCADGui.Selection.addSelection(FreeCAD.ActiveDocument.ActiveObject)"
)
class _SolverMystran(CommandManager):

View File

@@ -99,7 +99,7 @@ class Proxy(solverbase.Proxy):
"Order of time stepping method 'BDF'",
)
# according to the Elmer manual recommended is order 2
# possible ranage is 1 - 5
# possible range is 1 - 5
obj.BDFOrder = (2, 1, 5, 1)
obj.addProperty(
@@ -156,6 +156,33 @@ class Proxy(solverbase.Proxy):
obj.addProperty("App::PropertyLink", "ElmerOutput", "Base", "", 4 | 8)
obj.addProperty(
"App::PropertyBool", "BinaryOutput", "Result File", "Save result in binary format"
)
obj.BinaryOutput = False
obj.addProperty(
"App::PropertyBool", "SaveGeometryIndex", "Result File", "Save geometry IDs"
)
obj.SaveGeometryIndex = False
def onDocumentRestored(self, obj):
# update old project with new properties
try:
obj.getPropertyByName("BinaryOutput")
except FreeCAD.Base.PropertyError:
obj.addProperty(
"App::PropertyBool", "BinaryOutput", "Result File", "Save result in binary format"
)
obj.BinaryOutput = False
try:
obj.getPropertyByName("SaveGeometryIndex")
except FreeCAD.Base.PropertyError:
obj.addProperty(
"App::PropertyBool", "SaveGeometryIndex", "Result File", "Save geometry IDs"
)
obj.SaveGeometryIndex = False
def createMachine(self, obj, directory, testmode=False):
return run.Machine(
solver=obj,

View File

@@ -795,7 +795,8 @@ class Writer:
s["Procedure"] = sifio.FileAttr("ResultOutputSolve/ResultOutputSolver")
s["Output File Name"] = sifio.FileAttr("FreeCAD")
s["Vtu Format"] = True
s["Ascii Output"] = True
s["Binary Output"] = self.solver.BinaryOutput
s["Save Geometry Ids"] = self.solver.SaveGeometryIndex
s["Vtu Time Collection"] = True
if self.unit_schema == Units.Scheme.SI2:
s["Coordinate Scaling Revert"] = True

View File

@@ -53,12 +53,13 @@ Equation 1
End
Solver 2
Ascii Output = Logical True
Binary Output = Logical False
Coordinate Scaling Revert = Logical True
Equation = String "ResultOutput"
Exec Solver = String "After simulation"
Output File Name = File "FreeCAD"
Procedure = File "ResultOutputSolve" "ResultOutputSolver"
Save Geometry Ids = Logical False
Vtu Format = Logical True
Vtu Time Collection = Logical True
End

View File

@@ -53,11 +53,13 @@ Equation 1
End
Solver 2
Binary Output = Logical False
Coordinate Scaling Revert = Logical True
Equation = String "ResultOutput"
Exec Solver = String "After simulation"
Output File Name = File "FreeCAD"
Procedure = File "ResultOutputSolve" "ResultOutputSolver"
Save Geometry Ids = Logical False
Vtu Format = Logical True
Vtu Time Collection = Logical True
End

View File

@@ -53,11 +53,13 @@ Equation 1
End
Solver 2
Binary Output = Logical False
Coordinate Scaling Revert = Logical True
Equation = String "ResultOutput"
Exec Solver = String "After simulation"
Output File Name = File "FreeCAD"
Procedure = File "ResultOutputSolve" "ResultOutputSolver"
Save Geometry Ids = Logical False
Vtu Format = Logical True
Vtu Time Collection = Logical True
End

View File

@@ -53,11 +53,13 @@ Equation 1
End
Solver 2
Binary Output = Logical False
Coordinate Scaling Revert = Logical True
Equation = String "ResultOutput"
Exec Solver = String "After simulation"
Output File Name = File "FreeCAD"
Procedure = File "ResultOutputSolve" "ResultOutputSolver"
Save Geometry Ids = Logical False
Vtu Format = Logical True
Vtu Time Collection = Logical True
End

View File

@@ -53,11 +53,13 @@ Equation 1
End
Solver 2
Binary Output = Logical False
Coordinate Scaling Revert = Logical True
Equation = String "ResultOutput"
Exec Solver = String "After simulation"
Output File Name = File "FreeCAD"
Procedure = File "ResultOutputSolve" "ResultOutputSolver"
Save Geometry Ids = Logical False
Vtu Format = Logical True
Vtu Time Collection = Logical True
End