diff --git a/python/openEMS/_nf2ff.pxd b/python/openEMS/_nf2ff.pxd index 7e1b764..859f062 100644 --- a/python/openEMS/_nf2ff.pxd +++ b/python/openEMS/_nf2ff.pxd @@ -24,9 +24,9 @@ cimport cython.numeric cdef extern from "openEMS/nf2ff.h": cdef cppclass cpp_nf2ff "nf2ff": - cpp_nf2ff(vector[float] freq, vector[float] theta, vector[float] phi, vector[float] center, unsigned int numThreads) except + + cpp_nf2ff(vector[float] freq, vector[float] theta, vector[float] phi, vector[float] center, unsigned int numThreads) nogil except + - bool AnalyseFile(string E_Field_file, string H_Field_file) + bool AnalyseFile(string E_Field_file, string H_Field_file) nogil void SetRadius(float radius) void SetPermittivity(vector[float] permittivity); @@ -41,7 +41,7 @@ cdef extern from "openEMS/nf2ff.h": complex[double]** GetEPhi(size_t f_idx) double** GetRadPower(size_t f_idx) - bool Write2HDF5(string filename) + bool Write2HDF5(string filename) nogil void SetVerboseLevel(int level) diff --git a/python/openEMS/_nf2ff.pyx b/python/openEMS/_nf2ff.pyx index 8016694..14408b9 100644 --- a/python/openEMS/_nf2ff.pyx +++ b/python/openEMS/_nf2ff.pyx @@ -40,7 +40,11 @@ cdef class _nf2ff: def AnalyseFile(self, e_file, h_file): assert os.path.exists(e_file) assert os.path.exists(h_file) - return self.thisptr.AnalyseFile(e_file.encode('UTF-8'), h_file.encode('UTF-8')) + cdef string e_fn = e_file.encode('UTF-8') + cdef string h_fn = h_file.encode('UTF-8') + with nogil: + ok = self.thisptr.AnalyseFile(e_fn, h_fn) + return ok def SetMirror(self, mirr_type, ny, pos): if mirr_type<=0: diff --git a/python/openEMS/openEMS.pxd b/python/openEMS/openEMS.pxd index a307152..d9ef0e9 100644 --- a/python/openEMS/openEMS.pxd +++ b/python/openEMS/openEMS.pxd @@ -23,7 +23,7 @@ from CSXCAD.CSXCAD cimport _ContinuousStructure, ContinuousStructure cdef extern from "openEMS/openems.h": cdef cppclass _openEMS "openEMS": - _openEMS() except + + _openEMS() nogil except + void SetNumberOfTimeSteps(unsigned int val) void SetCSX(_ContinuousStructure* csx) @@ -49,13 +49,15 @@ cdef extern from "openEMS/openems.h": void SetGaussExcite(double f0, double fc) - void SetVerboseLevel(int level) - void DebugPEC() - void DebugMaterial() - void DebugCSX() + void SetAbort(bool val) - int SetupFDTD() - void RunFDTD() + void SetVerboseLevel(int level) + void DebugPEC() nogil + void DebugMaterial() nogil + void DebugCSX() nogil + + int SetupFDTD() nogil + void RunFDTD() nogil @staticmethod void WelcomeScreen() diff --git a/python/openEMS/openEMS.pyx b/python/openEMS/openEMS.pyx index 4d2aff3..44bc493 100644 --- a/python/openEMS/openEMS.pyx +++ b/python/openEMS/openEMS.pyx @@ -432,15 +432,21 @@ cdef class openEMS: if verbose is not None: self.thisptr.SetVerboseLevel(verbose) if debug_pec: - self.thisptr.DebugPEC() + with nogil: + self.thisptr.DebugPEC() if 'numThreads' in kw: self.thisptr.SetNumberOfThreads(int(kw['numThreads'])) assert os.getcwd() == sim_path _openEMS.WelcomeScreen() cdef int EC - EC = self.thisptr.SetupFDTD() + with nogil: + EC = self.thisptr.SetupFDTD() if EC!=0: print('Run: Setup failed, error code: {}'.format(EC)) if setup_only or EC!=0: return EC - self.thisptr.RunFDTD() + with nogil: + self.thisptr.RunFDTD() + + def SetAbort(self, val): + self.thisptr.SetAbort(val)