diff --git a/src/Mod/Fem/Gui/DlgSettingsFemGmsh.ui b/src/Mod/Fem/Gui/DlgSettingsFemGmsh.ui
index e6981dc9f2..eceddf9a99 100644
--- a/src/Mod/Fem/Gui/DlgSettingsFemGmsh.ui
+++ b/src/Mod/Fem/Gui/DlgSettingsFemGmsh.ui
@@ -151,6 +151,32 @@
+ -
+
+
+ Number of threads
+
+
+
+ -
+
+
+ Qt::AlignLeft|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+ Number of threads used for meshing
+
+
+ 1
+
+
+ NumOfThreads
+
+
+ Mod/Fem/Gmsh
+
+
+
@@ -193,6 +219,11 @@
QComboBox
+
+ Gui::PrefSpinBox
+ QSpinBox
+
+
diff --git a/src/Mod/Fem/Gui/DlgSettingsFemGmshImp.cpp b/src/Mod/Fem/Gui/DlgSettingsFemGmshImp.cpp
index 3c0f8b6d91..c5b789f117 100644
--- a/src/Mod/Fem/Gui/DlgSettingsFemGmshImp.cpp
+++ b/src/Mod/Fem/Gui/DlgSettingsFemGmshImp.cpp
@@ -25,6 +25,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
#include
+#include
#endif
#include
@@ -53,6 +54,7 @@ void DlgSettingsFemGmshImp::saveSettings()
ui->cb_gmsh_binary_std->onSave();
ui->fc_gmsh_binary_path->onSave();
ui->cb_log_verbosity->onSave();
+ ui->sb_threads->onSave();
}
void DlgSettingsFemGmshImp::loadSettings()
@@ -60,6 +62,11 @@ void DlgSettingsFemGmshImp::loadSettings()
ui->cb_gmsh_binary_std->onRestore();
ui->fc_gmsh_binary_path->onRestore();
+ ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
+ "User parameter:BaseApp/Preferences/Mod/Fem/Gmsh");
+ // determine number of CPU threads
+ ui->sb_threads->setValue(hGrp->GetInt("NumOfThreads", QThread::idealThreadCount()));
+
populateLogVerbosity();
ui->cb_log_verbosity->onRestore();
}
diff --git a/src/Mod/Fem/femmesh/gmshtools.py b/src/Mod/Fem/femmesh/gmshtools.py
index 33093165b2..1ea5a11813 100644
--- a/src/Mod/Fem/femmesh/gmshtools.py
+++ b/src/Mod/Fem/femmesh/gmshtools.py
@@ -30,7 +30,7 @@ __url__ = "https://www.freecad.org"
import os
import re
import subprocess
-from PySide.QtCore import QProcess
+from PySide.QtCore import QProcess, QThread
import FreeCAD
from FreeCAD import Console
@@ -737,11 +737,12 @@ class GmshTools:
geo.write("// geo file for meshing with Gmsh meshing software created by FreeCAD\n")
geo.write("\n")
- cpu_count = os.cpu_count()
- if cpu_count is not None and cpu_count > 1:
- geo.write("// enable multi-core processing\n")
- geo.write(f"General.NumThreads = {cpu_count};\n")
- geo.write("\n")
+ cpu_count = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem/Gmsh").GetInt(
+ "NumOfThreads", QThread.idealThreadCount()
+ )
+ geo.write("// enable multi-core processing\n")
+ geo.write(f"General.NumThreads = {cpu_count};\n")
+ geo.write("\n")
geo.write("// open brep geometry\n")
# explicit use double quotes in geo file