diff --git a/src/Mod/Fem/Gui/DlgSettingsFemElmer.ui b/src/Mod/Fem/Gui/DlgSettingsFemElmer.ui
index ced7c677c8..187c14405d 100644
--- a/src/Mod/Fem/Gui/DlgSettingsFemElmer.ui
+++ b/src/Mod/Fem/Gui/DlgSettingsFemElmer.ui
@@ -286,6 +286,53 @@ will be merged to make the volume boundaries invisible.
-
+
+
+ Results
+
+
+
-
+
+
+ Save result in binary format
+
+
+ Use binary format
+
+
+ false
+
+
+ BinaryOutput
+
+
+ Mod/Fem/Elmer
+
+
+
+ -
+
+
+ Save the index of geometric entities
+
+
+ Save geometry IDs
+
+
+ false
+
+
+ SaveGeometryIndex
+
+
+ Mod/Fem/Elmer
+
+
+
+
+
+
+ -
Qt::Vertical
diff --git a/src/Mod/Fem/Gui/DlgSettingsFemElmerImp.cpp b/src/Mod/Fem/Gui/DlgSettingsFemElmerImp.cpp
index 40b40466e7..bd7e9ed950 100644
--- a/src/Mod/Fem/Gui/DlgSettingsFemElmerImp.cpp
+++ b/src/Mod/Fem/Gui/DlgSettingsFemElmerImp.cpp
@@ -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();
}
/**
diff --git a/src/Mod/Fem/femcommands/commands.py b/src/Mod/Fem/femcommands/commands.py
index 38998f99ae..c7ad19a824 100644
--- a/src/Mod/Fem/femcommands/commands.py
+++ b/src/Mod/Fem/femcommands/commands.py
@@ -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):
diff --git a/src/Mod/Fem/femsolver/elmer/solver.py b/src/Mod/Fem/femsolver/elmer/solver.py
index 9b4602a0f4..6f7f7aafb0 100644
--- a/src/Mod/Fem/femsolver/elmer/solver.py
+++ b/src/Mod/Fem/femsolver/elmer/solver.py
@@ -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,
diff --git a/src/Mod/Fem/femsolver/elmer/writer.py b/src/Mod/Fem/femsolver/elmer/writer.py
index 8f16f5997b..c08f701e35 100644
--- a/src/Mod/Fem/femsolver/elmer/writer.py
+++ b/src/Mod/Fem/femsolver/elmer/writer.py
@@ -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
diff --git a/src/Mod/Fem/femtest/data/elmer/box_static_0_mm.sif b/src/Mod/Fem/femtest/data/elmer/box_static_0_mm.sif
index e1e19c2022..c4d947fb9c 100644
--- a/src/Mod/Fem/femtest/data/elmer/box_static_0_mm.sif
+++ b/src/Mod/Fem/femtest/data/elmer/box_static_0_mm.sif
@@ -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
diff --git a/src/Mod/Fem/femtest/data/elmer/ccxcantilever_faceload_0_mm.sif b/src/Mod/Fem/femtest/data/elmer/ccxcantilever_faceload_0_mm.sif
index c8dfbdf43d..002456e3f9 100644
--- a/src/Mod/Fem/femtest/data/elmer/ccxcantilever_faceload_0_mm.sif
+++ b/src/Mod/Fem/femtest/data/elmer/ccxcantilever_faceload_0_mm.sif
@@ -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
diff --git a/src/Mod/Fem/femtest/data/elmer/ccxcantilever_faceload_1_si.sif b/src/Mod/Fem/femtest/data/elmer/ccxcantilever_faceload_1_si.sif
index c8dfbdf43d..002456e3f9 100644
--- a/src/Mod/Fem/femtest/data/elmer/ccxcantilever_faceload_1_si.sif
+++ b/src/Mod/Fem/femtest/data/elmer/ccxcantilever_faceload_1_si.sif
@@ -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
diff --git a/src/Mod/Fem/femtest/data/elmer/ccxcantilever_nodeload_0_mm.sif b/src/Mod/Fem/femtest/data/elmer/ccxcantilever_nodeload_0_mm.sif
index 6a480ea518..360037f839 100644
--- a/src/Mod/Fem/femtest/data/elmer/ccxcantilever_nodeload_0_mm.sif
+++ b/src/Mod/Fem/femtest/data/elmer/ccxcantilever_nodeload_0_mm.sif
@@ -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
diff --git a/src/Mod/Fem/femtest/data/elmer/ccxcantilever_prescribeddisplacement_0_mm.sif b/src/Mod/Fem/femtest/data/elmer/ccxcantilever_prescribeddisplacement_0_mm.sif
index 4db843c99b..f783e8b29d 100644
--- a/src/Mod/Fem/femtest/data/elmer/ccxcantilever_prescribeddisplacement_0_mm.sif
+++ b/src/Mod/Fem/femtest/data/elmer/ccxcantilever_prescribeddisplacement_0_mm.sif
@@ -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