diff --git a/openems.cpp b/openems.cpp index a3c15d2..e8291db 100644 --- a/openems.cpp +++ b/openems.cpp @@ -217,7 +217,7 @@ bool openEMS::parseCommandLineArgument( const char *argv ) } else if (strncmp(argv,"--numThreads=",13)==0) { - m_engine_numThreads = atoi(argv+13); + this->SetNumberOfThreads(atoi(argv+13)); cout << "openEMS - fixed number of threads: " << m_engine_numThreads << endl; return true; } diff --git a/openems.h b/openems.h index 1f6941a..6600e06 100644 --- a/openems.h +++ b/openems.h @@ -70,6 +70,8 @@ public: void SetTimeStepFactor(double val) {m_TS_fac=val;} void SetMaxTime(double val) {m_maxTime=val;} + void SetNumberOfThreads(unsigned int val) {m_engine_numThreads = val;} + void DebugMaterial() {DebugMat=true;} void DebugOperator() {DebugOp=true;} void DebugBox() {m_debugBox=true;} diff --git a/python/openEMS/openEMS.pxd b/python/openEMS/openEMS.pxd index 1b484ea..a307152 100644 --- a/python/openEMS/openEMS.pxd +++ b/python/openEMS/openEMS.pxd @@ -39,6 +39,8 @@ cdef extern from "openEMS/openems.h": void SetTimeStepFactor(double val) void SetMaxTime(double val) + void SetNumberOfThreads(int val) + void Set_BC_Type(int idx, int _type) int Get_BC_Type(int idx) void Set_BC_PML(int idx, unsigned int size) diff --git a/python/openEMS/openEMS.pyx b/python/openEMS/openEMS.pyx index a449a34..bb41bff 100644 --- a/python/openEMS/openEMS.pyx +++ b/python/openEMS/openEMS.pyx @@ -410,7 +410,7 @@ cdef class openEMS: continue grid.AddLine(n, hint[n]) - def Run(self, sim_path, cleanup=False, setup_only=False, debug_pec=False, verbose=None): + def Run(self, sim_path, cleanup=False, setup_only=False, debug_pec=False, verbose=None, **kw): """ Run(sim_path, cleanup=False, setup_only=False, verbose=None) Run the openEMS FDTD simulation. @@ -419,6 +419,9 @@ cdef class openEMS: :param cleanup: bool -- remove exisiting sim_path to cleanup old results :param setup_only: bool -- only perform FDTD setup, do not run simulation :param verbose: int -- set the openEMS verbosity level 0..3 + + Additional keyword parameter: + :param numThreads: int -- set the number of threads (default 0 --> max) """ if cleanup and os.path.exists(sim_path): shutil.rmtree(sim_path) @@ -431,6 +434,8 @@ cdef class openEMS: self.thisptr.SetVerboseLevel(verbose) if debug_pec: self.thisptr.DebugPEC() + if 'numThreads' in kw: + self.thisptr.SetNumberOfThreads(int(kw['numThreads'])) assert os.getcwd() == sim_path _openEMS.WelcomeScreen() cdef int EC