Skip to content

Commit

Permalink
Fem: Make it possible to run CalculiX with one core - fixes FreeCAD#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
marioalexis84 authored and chennes committed Dec 13, 2024
1 parent 7550d54 commit c02aa87
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/Mod/Fem/Gui/DlgSettingsFemCcx.ui
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,11 @@
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<number>1</number>
<property name="toolTip">
<string>Set to zero to automatically use maximum number of available cores</string>
</property>
<property name="maximum">
<number>40</number>
<property name="minimum">
<number>0</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>AnalysisNumCPUs</cstring>
Expand Down
8 changes: 3 additions & 5 deletions src/Mod/Fem/femtaskpanels/task_solver_ccxtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,11 @@ def runCalculix(self):
# Set up for multi-threading. Note: same functionality as ccx_tools.py/start_ccx()
ccx_prefs = FreeCAD.ParamGet(self.PREFS_PATH)
env = QtCore.QProcessEnvironment.systemEnvironment()
num_cpu_pref = ccx_prefs.GetInt("AnalysisNumCPUs", 1)
if num_cpu_pref > 1:
num_cpu_pref = ccx_prefs.GetInt("AnalysisNumCPUs", 0)
if num_cpu_pref >= 1:
env.insert("OMP_NUM_THREADS", str(num_cpu_pref))
else:
cpu_count = os.cpu_count()
if cpu_count is not None and cpu_count > 1:
env.insert("OMP_NUM_THREADS", str(cpu_count))
env.insert("OMP_NUM_THREADS", str(QtCore.QThread.idealThreadCount()))
self.Calculix.setProcessEnvironment(env)

self.cwd = QtCore.QDir.currentPath()
Expand Down

0 comments on commit c02aa87

Please sign in to comment.