revision: v0.14
RestartToData.cpp File Reference
#include <iostream>
#include "Mercury3D.h"

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int argc  ,
char argv[] 
)
30 {
31  // write manual if number of arguments is not right
32  const std::string manual = "Enter the prefix of the simulation you want to restart\n"
33  " and, optionally, the prefix of the output files.\n"
34  " e.g. restart2data input output\n"
35  " reads from input.restart and writes to output.data\n";
36  if (argc<2) logger(ERROR,manual);
37 
38  // first argument is used as prefix for the input
39  std::string in = argv[1];
40  //append .restart if necessary
41  if (in.find(".restart")==-1) in += ".restart";
42  logger(INFO,"Reading from %", in);
43 
44  // if second argument is given, use it as prefix for the output; otherwise, use input prefix
45  bool prefixGiven = argc>=3 && argv[2][0]!='-';
46  char* out = prefixGiven?argv[2]:argv[1];
47  logger(INFO,"Writing to %", out);
48 
49  //read in from restart file and output data file
50  Mercury3D problem;
51  if (problem.readRestartFile(in)) {
52  problem.setName(out);
54  problem.writeXBallsScript();
55  problem.writeDataFile();
56  problem.writeFStatFile();
57  problem.writeEneFile();
58  logger(INFO,"Written to %", problem.dataFile.getFullName());
59  } else if (problem.readRestartFile(std::string(in)+".restart.0")
60  || problem.readRestartFile(std::string(in)+".restart.0000")) {
61  do {
62  problem.setName(out);
64  problem.dataFile.setCounter(problem.restartFile.getCounter() - 1);
65  problem.fStatFile.setCounter(problem.restartFile.getCounter() - 1);
66  problem.eneFile.setCounter(problem.restartFile.getCounter() - 1);
67  //problem.writeXBallsScript();
68  problem.writeDataFile();
69  problem.writeFStatFile();
70  problem.writeEneFile();
71  logger(INFO,"Written to %", problem.dataFile.getFullName());
72  problem.setName(in);
73  } while (problem.readRestartFile());
74  } else {
75  logger(ERROR,"File % not found",in);
76  }
77 }

References DPMBase::cgHandler, CGHandler::computeContactPoints(), DPMBase::dataFile, DPMBase::eneFile, ERROR, DPMBase::fStatFile, File::getCounter(), File::getFullName(), INFO, logger, DPMBase::readRestartFile(), DPMBase::restartFile, File::setCounter(), DPMBase::setName(), DPMBase::writeDataFile(), DPMBase::writeEneFile(), DPMBase::writeFStatFile(), and DPMBase::writeXBallsScript().

DPMBase::setName
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:420
DPMBase::readRestartFile
bool readRestartFile(ReadOptions opt=ReadOptions::ReadAll)
Reads all the particle data corresponding to a given, existing . restart file (for more details regar...
Definition: DPMBase.cc:2921
logger
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
DPMBase::cgHandler
CGHandler cgHandler
Object of the class cgHandler.
Definition: DPMBase.h:1431
CGHandler::computeContactPoints
void computeContactPoints()
Definition: CGHandler.cc:194
File::getCounter
unsigned int getCounter() const
In case of multiple files, File::getCounter() returns the the number (FILE::Counter_) of the next fil...
Definition: File.cc:223
DPMBase::writeXBallsScript
virtual void writeXBallsScript() const
This writes a script which can be used to load the xballs problem to display the data just generated.
Mercury3D
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:37
DPMBase::restartFile
File restartFile
An instance of class File to handle in- and output into a .restart file.
Definition: DPMBase.h:1451
INFO
LL< Log::INFO > INFO
Info log level.
Definition: Logger.cc:55
DPMBase::fStatFile
File fStatFile
An instance of class File to handle in- and output into a .fstat file.
Definition: DPMBase.h:1441
DPMBase::writeEneFile
void writeEneFile()
Definition: DPMBase.cc:2873
ERROR
LL< Log::ERROR > ERROR
Error log level.
Definition: Logger.cc:53
DPMBase::writeFStatFile
void writeFStatFile()
Definition: DPMBase.cc:2883
DPMBase::writeDataFile
void writeDataFile()
Definition: DPMBase.cc:2864
DPMBase::eneFile
File eneFile
An instance of class File to handle in- and output into a .ene file.
Definition: DPMBase.h:1446
File::setCounter
void setCounter(unsigned int counter)
Allows the user to set the file counter according to his need. Sets File::counter_.
Definition: File.cc:231
DPMBase::dataFile
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: DPMBase.h:1436
File::getFullName
const std::string getFullName() const
Also allows to access the file name, however with additional information which is the file counter,...
Definition: File.cc:170