openEMS: abort conditions added
This commit is contained in:
parent
52feb7d299
commit
896c7f21f3
21
openems.cpp
21
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()<NrTS) && (change>endCrit))
|
||||
while ((FDTD_Eng->GetNumberOfTimesteps()<NrTS) && (change>endCrit) && !CheckAbortCond())
|
||||
{
|
||||
FDTD_Eng->IterateTS(step);
|
||||
step=PA->Process();
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user