openEMS is a free and open-source electromagnetic field solver using the EC-FDTD method.
 
 
 
 
 
 
Go to file
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
Analyse example updates 2010-03-16 21:43:11 +01:00
Common Fix various typos 2022-12-11 11:32:04 +01:00
FDTD Lumped RLC parallel & series implementation (openEMS) (#121) 2023-11-18 12:23:15 +01:00
TESTSUITE fixed testsuite (Coax.m) 2012-11-30 23:06:23 +01:00
cmake/Modules add CMake to openEMS 2014-09-18 21:12:50 +02:00
linux Fix various typos 2022-12-11 11:32:04 +01:00
matlab fix hdf5 search to not find opencv hdf5.h 2023-01-06 16:43:21 +01:00
nf2ff nf2ff main: update year info 2023-02-19 12:47:33 +01:00
python openEMS.pyx: check canonical path in assert, close #113. 2023-05-03 18:46:29 +02:00
tools Handle SIGINT for openEMS and Python, with graceful exit support. 2023-11-18 12:32:44 +01:00
.gitattributes add gitattributes 2015-06-18 20:37:13 +02:00
.gitignore python: replace distutils with setuptools 2021-07-13 19:17:15 +02:00
CMakeLists.txt version 0.0.36 2023-10-22 16:25:51 +02:00
COPYING GPL licensing 2010-03-11 16:47:40 +01:00
Doxyfile simplified the dot diagrams in doxygen output 2011-01-07 09:59:10 +01:00
INSTALL Fix various typos 2022-12-11 11:32:04 +01:00
NEWS news update 2013-09-03 14:13:37 +02:00
README version v0.0.33-rc1 2015-08-05 21:23:31 +02:00
TODO Fix various typos 2022-12-11 11:32:04 +01:00
astyle.sh shell script to invoke the source code formatter astyle 2010-08-26 15:32:25 +02:00
known_bugs new: known_bugs/problems lists 2010-03-11 15:35:28 +01:00
known_problems new: known_bugs/problems lists 2010-03-11 15:35:28 +01:00
main.cpp A few fixes for MPI 2016-12-02 19:03:35 +01:00
openEMS.sh Fixes in openEMS.sh 2021-08-18 23:46:45 -07:00
openEMS_MPI.sh initial MPI support 2011-03-10 10:39:07 +01:00
openems.cpp Handle SIGINT for openEMS and Python, with graceful exit support. 2023-11-18 12:32:44 +01:00
openems.h engine: try to find optimal number of engine threads 2023-01-06 20:01:07 +01:00
openems_global.h python+MSVC: reorganize headers to reduce req. includes 2019-12-30 20:04:22 +01:00

README

*
* openEMS - a free and open electromagnetic field solver
*
* Copyright (C) 2010-2015 Thorsten Liebig
*

openEMS is licensed under the terms of the GPLv3, see <http://www.gnu.org/licenses/>.


Website:   http://openems.de
Forum:     http://openems.de/forum/
Tutorials: http://openems.de/index.php/Tutorials


To use openEMS from Matlab or Octave, you need to include the <openEMS-install-folder>/matlab folder in the respective environment:
> addpath( '<openEMS-install-folder>/matlab' );

To verify the correct installation follow the instructions at:
http://openems.de/index.php/Tutorial:_First_Steps