kill_switch.cpp
1 #include "kill_switch.hpp"
2 #include <fstream>
3 
4 using std::ofstream;
5 using std::ifstream;
6 using std::endl;
7 
8 KillSwitch::KillSwitch(const string& fname,
10  fname_(fname), tc_(tc)
11 {
12  ofstream f(fname.c_str());
13  f << '0' << endl;
14  f.close();
15 }
16 
17 bool KillSwitch::operator()(const hdsim& sim)
18 {
19  char buf;
20  ifstream f(fname_.c_str());
21  f >> buf;
22  return (buf=='0')&&(tc_(sim));
23 }
Newtonian hydrodynamic simulation.
Definition: hdsim2d.hpp:43
bool operator()(const hdsim &sim)
Returns true if the simulation should continue, false otherwise.
Definition: kill_switch.cpp:17
KillSwitch(const string &fname, TerminationCondition &tc)
Class constructor.
Definition: kill_switch.cpp:8
Allows user to manually terminate the main loop.
Abstract class for a termination condition for the main loop.