From ebc0c0ae041c530885ea2828cb00639d674dbf79 Mon Sep 17 00:00:00 2001 From: Uwe Date: Fri, 25 Mar 2022 18:40:12 +0100 Subject: [PATCH] [FEM] fix broken Z88 part 3: don't hardcode memory - we must not hardcode the number of stiffness matrix places, especially not for the Cholesky solver The user must have a chance to change this setting in case of a solver error. This is also according to the Z88 docs that says it is a two step process: - the solver first computed the necessary places - the user must set the value accordingly in case it is too low - also some code style fixes --- src/Mod/Fem/Gui/DlgSettingsFemCcxImp.cpp | 14 +-- src/Mod/Fem/Gui/DlgSettingsFemZ88.ui | 111 ++++++++++++++++------- src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.cpp | 17 +++- src/Mod/Fem/femsolver/z88/tasks.py | 2 +- src/Mod/Fem/femsolver/z88/writer.py | 19 ++-- 5 files changed, 109 insertions(+), 54 deletions(-) diff --git a/src/Mod/Fem/Gui/DlgSettingsFemCcxImp.cpp b/src/Mod/Fem/Gui/DlgSettingsFemCcxImp.cpp index ab71f36942..defb261e8a 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemCcxImp.cpp +++ b/src/Mod/Fem/Gui/DlgSettingsFemCcxImp.cpp @@ -50,8 +50,8 @@ DlgSettingsFemCcxImp::~DlgSettingsFemCcxImp() void DlgSettingsFemCcxImp::saveSettings() { - ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath - ("User parameter:BaseApp/Preferences/Mod/Fem/Ccx"); + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/Preferences/Mod/Fem/Ccx"); hGrp->SetInt("Solver", ui->cmb_solver->currentIndex()); hGrp->SetInt("AnalysisType", ui->cb_analysis_type->currentIndex()); @@ -102,12 +102,14 @@ void DlgSettingsFemCcxImp::loadSettings() ui->fc_ccx_binary_path->onRestore(); ui->cb_split_inp_writer->onRestore(); - ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath - ("User parameter:BaseApp/Preferences/Mod/Fem/Ccx"); + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/Preferences/Mod/Fem/Ccx"); int index = hGrp->GetInt("Solver", 0); - if (index > -1) ui->cmb_solver->setCurrentIndex(index); + if (index > -1) + ui->cmb_solver->setCurrentIndex(index); index = hGrp->GetInt("AnalysisType", 0); - if (index > -1) ui->cb_analysis_type->setCurrentIndex(index); + if (index > -1) + ui->cb_analysis_type->setCurrentIndex(index); } /** diff --git a/src/Mod/Fem/Gui/DlgSettingsFemZ88.ui b/src/Mod/Fem/Gui/DlgSettingsFemZ88.ui index f0c80fb5ca..4f8daa5e83 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemZ88.ui +++ b/src/Mod/Fem/Gui/DlgSettingsFemZ88.ui @@ -6,8 +6,8 @@ 0 0 - 423 - 128 + 452 + 154 @@ -74,25 +74,19 @@ - - - + + + + Search in known binary directories + + true - - - 0 - 0 - + + UseStandardZ88Location - - - 0 - 0 - - - - z88r binary path: + + Mod/Fem/Z88 @@ -116,22 +110,6 @@ - - - - Search in known binary directories - - - true - - - UseStandardZ88Location - - - Mod/Fem/Z88 - - - @@ -166,6 +144,66 @@ + + + + true + + + + 0 + 0 + + + + + 0 + 0 + + + + z88r binary path: + + + + + + + Maximal places in stiffnes matrix. +You might need to increase this when using the +Colesky solver and you get the error message +that "MAXGS" needs to be increased. + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 6000000 + + + 2147483647 + + + 10000000 + + + 100000000 + + + MaxGS + + + Mod/Fem/Z88 + + + + + + + Max places in stiffnes matrix + + + @@ -208,6 +246,11 @@ QComboBox
Gui/PrefWidgets.h
+ + Gui::PrefSpinBox + QSpinBox +
Gui/PrefWidgets.h
+
diff --git a/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.cpp b/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.cpp index 37a14e0c50..475545c209 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.cpp +++ b/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.cpp @@ -49,10 +49,12 @@ 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"); + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/Preferences/Mod/Fem/Z88"); hGrp->SetInt("Solver", ui->cmb_solver->currentIndex()); ui->cmb_solver->onSave(); + hGrp->SetInt("MaxGS", ui->sb_Z88_MaxGS->value()); + ui->sb_Z88_MaxGS->onSave(); } void DlgSettingsFemZ88Imp::loadSettings() @@ -60,11 +62,16 @@ void DlgSettingsFemZ88Imp::loadSettings() ui->cb_z88_binary_std->onRestore(); ui->fc_z88_binary_path->onRestore(); ui->cmb_solver->onRestore(); + ui->sb_Z88_MaxGS->onRestore(); - ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath - ("User parameter:BaseApp/Preferences/Mod/Fem/Z88"); + 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); + if (index > -1) + ui->cmb_solver->setCurrentIndex(index); + int places = hGrp->GetInt("MaxGS", 100000000); + if (places > -1) + ui->sb_Z88_MaxGS->setValue(places); } /** diff --git a/src/Mod/Fem/femsolver/z88/tasks.py b/src/Mod/Fem/femsolver/z88/tasks.py index a9a2b3bc7a..0d54810cfa 100644 --- a/src/Mod/Fem/femsolver/z88/tasks.py +++ b/src/Mod/Fem/femsolver/z88/tasks.py @@ -108,7 +108,7 @@ class Solve(run.Solve): solver = SOLVER_TYPES solver = prefs.GetInt("Solver", 0) solver = SOLVER_TYPES[solver] - self.pushStatus("used solver: " + solver + "\n") + self.pushStatus("Used solver: " + solver + "\n") # run solver test mode # AFAIK: z88r needs to be run twice diff --git a/src/Mod/Fem/femsolver/z88/writer.py b/src/Mod/Fem/femsolver/z88/writer.py index 1824e26c88..ef5a43e426 100644 --- a/src/Mod/Fem/femsolver/z88/writer.py +++ b/src/Mod/Fem/femsolver/z88/writer.py @@ -288,16 +288,19 @@ class FemInputWriterZ88(writerbase.FemInputWriter): # ******************************************************************************************** def write_z88_memory_parameter(self): - # self.z88_param_maxgs = 6000000 - self.z88_param_maxgs = 50000000 # vierkantrohr + prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem/Z88") + MaxGS = prefs.GetInt("MaxGS", 100000000) global z88_dyn_template - z88_dyn_template = z88_dyn_template.replace( - "$z88_param_maxgs", - "{}".format(self.z88_param_maxgs) - ) + templateArray = z88_dyn_template.splitlines() + output = "" + for line in templateArray: + if line.find("MAXGS") > -1: + line = " MAXGS " + str(MaxGS) + output += line + "\n" + solver_parameter_file_path = self.file_name + ".dyn" f = open(solver_parameter_file_path, "w") - f.write(z88_dyn_template) + f.write(output) f.close() @@ -366,7 +369,7 @@ Common entries for all modules gemeinsame Daten fuer alle Module --------------------------------------------------------------------------- COMMON START - MAXGS $z88_param_maxgs + MAXGS 100000000 MAXKOI 1200000 MAXK 60000 MAXE 300000