Fem: Add preference entry to set Gmsh number of threads
This commit is contained in:
@@ -151,6 +151,32 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_threads">
|
||||
<property name="text">
|
||||
<string>Number of threads</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="Gui::PrefSpinBox" name="sb_threads">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeft|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Number of threads used for meshing</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>NumOfThreads</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Fem/Gmsh</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -193,6 +219,11 @@
|
||||
<extends>QComboBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="Resources/Fem.qrc"/>
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#include <QMessageBox>
|
||||
#include <QThread>
|
||||
#endif
|
||||
|
||||
#include <App/Application.h>
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user