Fem: Add option to select default solver when creating Analysis
This commit is contained in:
@@ -364,6 +364,73 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_6_defaults">
|
||||
<property name="title">
|
||||
<string>Defaults</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gl_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="l_def_solver">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Default solver</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::PrefComboBox" name="cmb_def_solver">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Default solver used by the analysis container</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>DefaultSolver</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Fem/General</cstring>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>None</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>CalculiX</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Elmer</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Mystran</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Z88</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
@@ -403,6 +470,11 @@
|
||||
<extends>QCheckBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="Resources/Fem.qrc"/>
|
||||
|
||||
@@ -55,6 +55,7 @@ void DlgSettingsFemGeneralImp::saveSettings()
|
||||
ui->cb_wd_custom->onSave();
|
||||
ui->le_wd_custom->onSave();
|
||||
ui->cb_overwrite_solver_working_directory->onSave();
|
||||
ui->cmb_def_solver->onSave();
|
||||
}
|
||||
|
||||
void DlgSettingsFemGeneralImp::loadSettings()
|
||||
@@ -70,6 +71,7 @@ void DlgSettingsFemGeneralImp::loadSettings()
|
||||
ui->cb_wd_custom->onRestore();
|
||||
ui->le_wd_custom->onRestore();
|
||||
ui->cb_overwrite_solver_working_directory->onRestore();
|
||||
ui->cmb_def_solver->onRestore();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,7 +37,7 @@ from .manager import CommandManager
|
||||
from femsolver import settings
|
||||
from femtools.femutils import expandParentObject
|
||||
from femtools.femutils import is_of_type
|
||||
|
||||
from femsolver.settings import get_default_solver
|
||||
|
||||
# Python command definitions:
|
||||
# for C++ command definitions see src/Mod/Fem/Command.cpp
|
||||
@@ -59,7 +59,7 @@ class _Analysis(CommandManager):
|
||||
self.accel = "S, A"
|
||||
self.tooltip = Qt.QT_TRANSLATE_NOOP(
|
||||
"FEM_Analysis",
|
||||
"Creates an analysis container with standard solver CalculiX"
|
||||
"Creates an analysis container with default solver"
|
||||
)
|
||||
self.is_active = "with_document"
|
||||
|
||||
@@ -69,16 +69,12 @@ class _Analysis(CommandManager):
|
||||
FreeCADGui.addModule("ObjectsFem")
|
||||
FreeCADGui.doCommand("ObjectsFem.makeAnalysis(FreeCAD.ActiveDocument, 'Analysis')")
|
||||
FreeCADGui.doCommand("FemGui.setActiveAnalysis(FreeCAD.ActiveDocument.ActiveObject)")
|
||||
# if there is no Elmer or Z88 binary create a CalculiX ccx tools solver for
|
||||
# new analysis to be on the safe side for new users
|
||||
binary = settings.get_binary("ElmerSolver")
|
||||
if binary is None:
|
||||
binary = settings.get_binary("Z88")
|
||||
if binary is None:
|
||||
FreeCADGui.doCommand("ObjectsFem.makeSolverCalculixCcxTools(FreeCAD.ActiveDocument)")
|
||||
if get_default_solver():
|
||||
FreeCADGui.doCommand("ObjectsFem.makeSolver{}(FreeCAD.ActiveDocument)"
|
||||
.format(get_default_solver()))
|
||||
FreeCADGui.doCommand(
|
||||
"FemGui.getActiveAnalysis().addObject(FreeCAD.ActiveDocument.ActiveObject)"
|
||||
)
|
||||
"FemGui.getActiveAnalysis().addObject(FreeCAD.ActiveDocument.ActiveObject)")
|
||||
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
|
||||
|
||||
@@ -165,6 +165,12 @@ def get_dir_setting():
|
||||
return DirSetting.CUSTOM
|
||||
return DirSetting.TEMPORARY
|
||||
|
||||
def get_default_solver():
|
||||
""" Return default solver name.
|
||||
"""
|
||||
solver_map = {0: None, 1: "CalculixCcxTools", 2: "Elmer", 3: "Mystran", 4: "Z88"}
|
||||
param_group = FreeCAD.ParamGet(_GENERAL_PARAM)
|
||||
return solver_map[param_group.GetInt("DefaultSolver", 0)]
|
||||
|
||||
class _SolverDlg(object):
|
||||
""" Internal query logic for solver specific settings.
|
||||
|
||||
Reference in New Issue
Block a user