[FEM] fix broken Z88 part 1: don't hardcode solver

- especially don't hardcode the choly solver that fails quickly for finer meshes
- setting sorcg as default since it shows the best performance with the cantilever tests
This commit is contained in:
Uwe
2022-03-25 16:49:03 +01:00
parent 7734017cd6
commit d035bbc1ca
3 changed files with 180 additions and 109 deletions

View File

@@ -6,124 +6,170 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>97</height>
<width>423</width>
<height>128</height>
</rect>
</property>
<property name="windowTitle">
<string>Z88</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="gb_z88_param">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="title">
<string>Z88 binary</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<item>
<layout class="QGridLayout" name="gl_z88">
<item row="0" column="2">
<widget class="Gui::PrefCheckBox" name="cb_z88_binary_std">
<property name="text">
<string>Search in known binary directories</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>UseStandardZ88Location</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Fem/Z88</cstring>
</property>
</widget>
<widget class="QGroupBox" name="gb_z88_param">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="title">
<string>Z88 binary</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gl_z88">
<item row="2" column="2">
<widget class="Gui::PrefFileChooser" name="fc_z88_binary_path" native="true">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Leave blank to use default Z88 z88r binary file</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>z88BinaryPath</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Fem/Z88</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="l_z88_binary_path">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>z88r binary path:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="l_ccx_initial_time_step">
<property name="text">
<string>Solver method:</string>
</property>
</widget>
</item>
<item row="2" column="3">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="Gui::PrefCheckBox" name="cb_z88_binary_std">
<property name="text">
<string>Search in known binary directories</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>UseStandardZ88Location</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Fem/Z88</cstring>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="Gui::PrefComboBox" name="cmb_solver">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>solve to be used by Z88</string>
</property>
<property name="editable">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>Solver</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Fem/Z88</cstring>
</property>
<item>
<property name="text">
<string>Iteration solver with SOR preconditioning (-sorcg)</string>
</property>
</item>
<item row="0" column="0">
<widget class="QLabel" name="l_z88_binary_std">
<property name="text">
<string>z88r</string>
</property>
</widget>
<item>
<property name="text">
<string>Iteration solver with SIC preconditioning (-siccg)</string>
</property>
</item>
<item row="2" column="0">
<widget class="QLabel" name="l_z88_binary_path">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>z88r binary path</string>
</property>
</widget>
<item>
<property name="text">
<string>Simple Cholesky solver (-choly)</string>
</property>
</item>
<item row="2" column="2">
<widget class="Gui::PrefFileChooser" name="fc_z88_binary_path">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Leave blank to use default Z88 z88r binary file</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>z88BinaryPath</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Fem/Z88</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
@@ -157,6 +203,11 @@
<extends>Gui::FileChooser</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"/>

View File

@@ -24,6 +24,8 @@
#include "PreCompiled.h"
#include <Gui/Application.h>
#include "DlgSettingsFemZ88Imp.h"
#include "ui_DlgSettingsFemZ88.h"
@@ -46,12 +48,23 @@ void DlgSettingsFemZ88Imp::saveSettings()
{
ui->cb_z88_binary_std->onSave();
ui->fc_z88_binary_path->onSave();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Mod/Fem/Z88");
hGrp->SetInt("Solver", ui->cmb_solver->currentIndex());
ui->cmb_solver->onSave();
}
void DlgSettingsFemZ88Imp::loadSettings()
{
ui->cb_z88_binary_std->onRestore();
ui->fc_z88_binary_path->onRestore();
ui->cmb_solver->onRestore();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Mod/Fem/Z88");
int index = hGrp->GetInt("Solver", 0);
if (index > -1) ui->cmb_solver->setCurrentIndex(index);
}
/**

View File

@@ -42,6 +42,7 @@ from femmesh import meshsetsgetter
from femtools import femutils
from femtools import membertools
SOLVER_TYPES = ["sorcg", "siccg", "choly"]
class Check(run.Check):
@@ -102,6 +103,12 @@ class Solve(run.Solve):
binary = settings.get_binary("Z88")
if binary is None:
self.fail() # a print has been made in settings module
prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem/Z88")
solver = SOLVER_TYPES
solver = prefs.GetInt("Solver", 0)
solver = SOLVER_TYPES[solver]
self.pushStatus("used solver: " + solver + "\n")
# run solver test mode
# AFAIK: z88r needs to be run twice
@@ -111,7 +118,7 @@ class Solve(run.Solve):
# may be compare with the used ones
self.pushStatus("Executing solver in test mode...\n")
self._process = subprocess.Popen(
[binary, "-t", "-choly"],
[binary, "-t", "-" + solver],
cwd=self.directory,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
@@ -123,7 +130,7 @@ class Solve(run.Solve):
self.pushStatus("Executing solver in real mode...\n")
binary = settings.get_binary("Z88")
self._process = subprocess.Popen(
[binary, "-c", "-choly"],
[binary, "-c", "-" + solver],
cwd=self.directory,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)