27 #ifndef MERCURY3DRESTART_H
28 #define MERCURY3DRESTART_H
78 if (!strcmp(argv[i],
"-restart") || !strcmp(argv[i],
"-r"))
83 std::size_t found =
getName().find(
".restart");
84 if (found==std::string::npos) {
88 std::cout <<
"Reading file " << argv[i + 1] << std::endl;
91 std::cout <<
"Read file " <<
getName() << std::endl;
93 std::cout <<
"tmax= " <<
getTimeMax() << std::endl;
110 if (gettimeofday(&time, NULL))
112 std::cerr <<
"Error in getWallTime: Wall time could not be read" << std::endl;
115 return (
double) time.tv_sec + (double) time.tv_usec * .000001;
133 std::cout <<
"Exiting for restarting after "
137 std::stringstream com(
"");
140 std::size_t found =
getName().find(
'.');
141 if (found==std::string::npos) {
147 std::cout <<
"system output:" << system(com.str().c_str()) << std::endl;
std::string clusterCommand_
Command required to execute code on a cluster; for einder, the command is ~/bin/sclusterscriptexecute...
bool readRestartFile(bool restarted=true)
Reads all the particle data corresponding to the current saved time step. Which is what the restart f...
File restartFile
An instance of class File to handle in- and output into a .restart file.
void closeFiles()
Closes all files (ene, data, fstat, restart, stat) that were opened to read or write.
void setClusterCommand(std::string clusterCommand)
void setAppend(bool newAppendFlag)
Allows to set the append option.
virtual void writeOutputFiles()
Writes the simulation data onto all the files i.e. .data, .ene, .fstat ...
double getWallTime() const
Returns wall time (uses sys command, thus might not work on Windows)
double initialWallTime_
Internal variable (i.e.
void setMaxWallTime(Mdouble maxWallTime)
std::fstream & getFstream()
Allows to access the member variable File::fstream_.
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
This adds on the hierarchical grid code for 3D problems.
bool readNextArgument(int &i, int argc, char *argv[]) override
Reads the next command line argument.
Mdouble getInitialWallTime() const
virtual void actionsAfterSolve()
A virtual function which allows to define operations to be executed after the solve().
std::string getClusterCommand() const
virtual void printTime() const
Displays the current simulation time onto your screen for example.
void writeOutputFiles()
Writes the simulation data onto all the files i.e. .data, .ene, .fstat ...
This class adds to Mercury3D the ability to restart after a certain wall time.
int readNextArgument(int &i, int argc, char *argv[])
the -r option is used to restart the code; this should probably be moved to DPMBase ...
double maxWallTime_
Time in seconds after which the code is automatically restarted for einder, this should be set to ~10...
virtual void finishStatistics()
no implementation but can be overidden in its derived classes.
const std::string & getName() const
Returns the name of the file. Does not allow to change it though.
Mdouble getMaxWallTime() const
Mdouble getTimeMax() const
Allows the user to access the total simulation time during the simulation. Cannot change it though...
const std::string & getName() const
Allows to access the file name, e.g., "problem.data".