From 896c7f21f3008f3fd1abc5df5f75617e75e9a768 Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Mon, 18 Oct 2010 13:26:25 +0200 Subject: [PATCH] openEMS: abort conditions added --- openems.cpp | 21 ++++++++++++++++++++- openems.h | 7 +++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/openems.cpp b/openems.cpp index 8114858..0c37bf4 100644 --- a/openems.cpp +++ b/openems.cpp @@ -65,6 +65,8 @@ openEMS::openEMS() m_engine = EngineType_Standard; m_engine_numThreads = 0; + + m_Abort = false; } openEMS::~openEMS() @@ -551,6 +553,23 @@ string FormatTime(int sec) return ss.str(); } +bool openEMS::CheckAbortCond() +{ + if (m_Abort) //abort was set externally + return true; + + //check whether the file "ABORT" exist in current working directory + ifstream ifile("ABORT"); + if (ifile) + { + ifile.close(); + cerr << "openEMS::CheckAbortCond(): Found file \"ABORT\", aborting simulation..." << endl; + return true; + } + + return false; +} + void openEMS::RunFDTD() { cout << "Running FDTD engine... this may take a while... grab a cup of coffee?!?" << endl; @@ -579,7 +598,7 @@ void openEMS::RunFDTD() int step=PA->Process(); if ((step<0) || (step>(int)NrTS)) step=NrTS; - while ((FDTD_Eng->GetNumberOfTimesteps()endCrit)) + while ((FDTD_Eng->GetNumberOfTimesteps()endCrit) && !CheckAbortCond()) { FDTD_Eng->IterateTS(step); step=PA->Process(); diff --git a/openems.h b/openems.h index 53d0faf..bb89df4 100644 --- a/openems.h +++ b/openems.h @@ -51,6 +51,11 @@ public: //! Get informations about external libs used by openEMS static string GetExtLibsInfo(); + //! Set this to about FDTD iteration process + void SetAbort(bool val) {m_Abort=val;} + //! Check for abort conditions + bool CheckAbortCond(); + protected: bool CylinderCoords; @@ -67,6 +72,8 @@ protected: Engine* FDTD_Eng; ProcessingArray* PA; + bool m_Abort; + enum EngineType {EngineType_Standard, EngineType_SSE, EngineType_SSE_Compressed, EngineType_Multithreaded}; EngineType m_engine; unsigned int m_engine_numThreads;