Commit Graph

79 Commits (5b8cf2f2ed52567e2696d67e647bf906843cef7c)

Author SHA1 Message Date
Yifeng Li 840c9755d5 Handle SIGINT for openEMS and Python, with graceful exit support.
Currently, openEMS doesn't have any special code to handle SIGINT (which
is raised by pressing Control-C). By default, the program is terminated
without saving data. This worked okay in the past, but now its
limitations are becoming obvious.

1. When openEMS is used as a Python module, Control-C stops working
because SIGINT is now managed by Python in order to generate
KeyboardInterrupt exceptions, normally this isn't a problem, but if
we are running an external C++ (Cython) function such as openEMS, the
Python interpreter mainloop has no control until we return. As a
result, SIGINT is received but never handled. In Cython, programs are
expected to call PyErr_CheckSignals() in its blocking loop periodically
to temporally transfer control back to Python to handle signals. But
this introduces a dependency of Cython in the FDTD mainloop.

2. During a simulation, it's not possible to abort it gracefully by
pressing Control-C, this is a limitation of openEMS itself, it's
always a force exit. Currently the only supported method for graceful
exit is creating a file called "ABORT" in the simulation directory.
If we already need to implement a signal handler, adding a graceful
exit at the same time would be a good idea.

This commit installs SIGINT handlers during SetupFDTD() and RunFDTD().

1. In RunFDTD(), if SIGINT is received once, a status flag is set, which
is then checked in CheckAbortCond(), allowing a graceful exit with the
same effect of an "ABORT" file. If SIGINT is received twice, openEMS
force exit without saving data (just like the old default behavior).

2. In SetupFDTD(), if SIGINT is received, openEMS immediately force
exit without saving data, identical to the old behavior. In a huge
simulation, initializing and compressing operators may have a long
time. so we want an early exit before RunFDTD().

3. Before RunFDTD() and SetupFDTD() return, the original signal handler
for SIGINT is restored. This is important since when we're acting as
a shared library. When a program (such as the Python interpreter) calls
us, changing the SIGINT handler unilaterally may overwrite the original
handler and affect the functionality of the original program. For
example, Python would never be able to raise KeyboardInterrupt again.
Thus, we save the original handler and restore it later.

Signed-off-by: Yifeng Li <tomli@tomli.me>
2023-11-18 12:32:44 +01:00
luz paz 026f12355f Fix various typos
Found via `codespell -q 3 -L adress,imag`
2022-12-11 11:32:04 +01:00
Thorsten Liebig e7475a3bd1 python+MSVC: reorganize headers to reduce req. includes
Signed-off-by: Thorsten Liebig <liebig@imst.de>
2019-12-30 20:04:22 +01:00
Thorsten Liebig fbfccc4110 adaptations for win32 with MSVC
* missing __declspec import/export for openEMS.dll/nf2ff.dll creation
* SEE2 needs __m128 and operators (see tools/array_ops.h)
* array creation needs new/delete for compile time unknown sizes
* no gettimeofday and Winsock2 instead of sys/time
* missing math defines

Signed-off-by: Thorsten Liebig <liebig@imst.de>
2019-12-30 17:12:51 +01:00
Stefan Brüns da8137f90d Fix build error due to ambigous overload of isnan/isinf
In case the code is build with -std=c++11, there may be conflicting
definitions of isnan/isinf vs std::isnan/std::isinf, due to the using
namespace std directive.
This happens for glibc versions 2.25 and older, see
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48891 for details.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
2018-03-27 03:57:22 +02:00
georgmichel 6a7db1917a clean up HDF5 interface for v1.8+, hdf5readatt_octave.cc still needs to be done but has to wait for upstream Octave fix 2016-08-26 10:06:24 +00:00
Dmitry Roshchin 5b2f5352eb #if check for vtk >= 6 2016-03-21 11:35:36 +03:00
Thorsten Liebig 8ff7ed4075 split openEMS into libopenEMS and openEMS binary
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2015-12-19 15:01:56 +01:00
Thorsten Liebig f06cc293dc remove using namespace std from header files
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2015-06-18 21:45:22 +02:00
Thorsten Liebig 29ffbb66ab cmake: improve build system and support win32
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2015-05-19 22:13:28 +02:00
Thorsten Liebig 9ef6510d3e nf2ff: add boundary mirroring
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2014-10-09 21:20:31 +02:00
Thorsten Liebig 4a89e3932d cmake: more options & update gitignore
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2014-09-21 20:19:21 +02:00
Guilherme Brondani Torri 480e6c430f add CMake to openEMS 2014-09-18 21:12:50 +02:00
Thorsten Liebig 6da9213e62 initial support for vtk 6.x
run qmake with vtk-version given, e.g.:
qmake VTK_6_VERSION=6.1
or put this in localPaths.pri

Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2014-01-29 14:51:00 +01:00
Thorsten Liebig eda30bacd3 SAR: fix typo for SAR av. method
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2013-07-24 17:19:35 +02:00
Thorsten Liebig 1a9690a252 useful: use own matrix determinant and invert instead of vtkMatrix3x3
The only reason for this is that vtkMatrix3x3 would require vtk > v5.4

Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2013-06-10 16:19:01 +02:00
Thorsten Liebig 6db63bdd19 fix to LinePlaneIntersection function
- (u+v)<=1 would only allow an intersection of the triangle p0/p1/p2

Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2013-06-06 15:56:06 +02:00
Thorsten Liebig 3f70a49a0a some new useful functions
- function to calculate the cross product
- function to calculate the scalar product
- function to calculate the intersection of a line an a plane

Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2013-06-05 11:44:51 +02:00
Thorsten Liebig a607bc6969 more options to setup SAR averaging method
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2013-05-15 16:02:30 +02:00
Thorsten Liebig dea4065ca1 hdf5 reader: fix return value
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2013-02-12 08:58:50 +01:00
Thorsten Liebig 920118ea5f SAR: increase accuracy in intermediate values
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2013-01-30 14:16:23 +01:00
Thorsten Liebig c22665e529 match SAR debug level to gobal verbose level
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2013-01-30 14:13:54 +01:00
Thorsten Liebig c536e1f344 process fields: new SAR calculation
todo: needs much testing and evaluation

Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2012-11-29 16:45:48 +01:00
Sebastian Held 013f92ba26 fixed some warnings of gcc-4.7 2012-11-15 21:44:43 +01:00
Thorsten Liebig 36d869a41a global: arrange show and parse arguments; doc update 2012-09-24 15:19:16 +02:00
Thorsten Liebig 0de3d0caf0 useful functions: split string to double added 2012-09-17 13:21:32 +02:00
Thorsten Liebig f29ac7aa84 hdf5 reader: read frequency as double; doc updates 2012-09-17 13:21:32 +02:00
Thorsten Liebig 4818e836b7 hdf5 writer: allow data write for double data
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2012-09-17 13:21:32 +02:00
Thorsten Liebig 8dc581a314 hdf5: reader can now read FD data & other improvements 2012-07-31 14:24:11 +02:00
Thorsten Liebig 833ceb37ec hdf5 reader: fixed some warnings 2012-07-30 11:15:20 +02:00
Thorsten Liebig f20a36863c hdf5: some fixes and minor improvements for hdf5 reader & writer 2012-07-30 11:11:41 +02:00
Thorsten Liebig 18775c8315 hdf5 writer: more attribute write options 2012-02-17 12:31:31 +01:00
Thorsten Liebig aacbf33e63 hdf5 writer: set and create current group 2012-02-17 12:30:58 +01:00
Thorsten Liebig 645ef9a38b fix: make sure to close opened hdf5 properties
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2012-02-06 14:09:51 +01:00
Thorsten Liebig 5d0f08aaec new function to split string into a float-vector 2012-02-02 11:40:42 +01:00
Thorsten Liebig 807786b2d2 reorganized vtk writer and new hdf5 file writer & reader 2012-02-02 10:20:49 +01:00
Thorsten Liebig a82e392338 new debug level 3, update to debug level 2011-11-16 11:24:25 +01:00
Thorsten Liebig 830f7494c8 console output cleanup: use verbose level ('-v') for old verbose style 2011-11-08 11:49:14 +01:00
Thorsten Liebig 0a19e9942d missing 1D array f4vector init 2011-11-07 11:46:22 +01:00
Thorsten Liebig 906800c057 file-IO support native field dumps 2011-04-13 12:18:03 +02:00
Thorsten Liebig 3dc19c1f4d new dump file IO class concept 2011-04-01 15:08:56 +02:00
Thorsten Liebig 9d3761b1d0 Init style: applied astyle.sh
astyle --style=allman --indent=tab --indent-cases {} \;

please apply this style prior to any future commit

Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2010-12-06 15:31:11 +01:00
Thorsten Liebig ab1119f468 new: Engine_Interface
This is a new common class designed as an interface between an engine
and the processing routines which should become a part of common as well.

todo:
 - migrate all processings to use this interface only
 - lots of testing...

Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
2010-12-06 10:00:08 +01:00
Thorsten Liebig 0bbb5cc3ee new global verbose flag 2010-12-06 10:00:08 +01:00
Thorsten Liebig 907ac3cff2 default debug flag and update/fix for cylindrical coords 2010-10-27 14:49:16 +02:00
Thorsten Liebig 430a04e9e4 new/better method to assign jobs to working threads 2010-10-05 17:24:36 +02:00
Thorsten Liebig 8870a20787 fixed extensions handling for cylindrical multigrid 2010-09-22 16:08:39 +02:00
Thorsten Liebig 54dd06590b fixed warning in aligned_allocator 2010-09-20 08:12:24 +02:00
Thorsten Liebig 1e78e5c2d6 fix vtk-dump: vector fields consider mesh type
furthermore:
- new argument: --nativeFieldDumps to dump original FDTD field components for debugging purposes
- show global arguments on startup
2010-09-17 15:34:39 +02:00
Sebastian Held b0a0d69faf bugfix 32-bit SSE-compressed: aligned allocator for STL vector 2010-09-17 15:06:09 +02:00