MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RestartToData.cpp File Reference
#include <iostream>
#include "Mercury3D.h"

Go to the source code of this file.


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

Function Documentation

int main ( int  argc,
char *  argv[] 

Definition at line 29 of file RestartToData.cpp.

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().

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\n";
36  if (argc<2) logger(ERROR,manual);
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);
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);
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 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Info log level.
void setCounter(unsigned int counter)
Allows the user to set the file counter according to his need. Sets File::counter_.
const std::string getFullName() const
Also allows to access the file name, however with additional information which is the file counter...
Error log level.
void writeFStatFile()
unsigned int getCounter() const
In case of multiple files, File::getCounter() returns the the number (FILE::Counter_) of the next fil...
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: DPMBase.h:1370
File fStatFile
An instance of class File to handle in- and output into a .fstat file.
Definition: DPMBase.h:1375
CGHandler cgHandler
Object of the class cgHandler.
Definition: DPMBase.h:1365
void writeEneFile()
void computeContactPoints()
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:36
virtual void writeXBallsScript() const
This writes a script which can be used to load the xballs problem to display the data just generated...
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
void writeDataFile()
File eneFile
An instance of class File to handle in- and output into a .ene file.
Definition: DPMBase.h:1380
File restartFile
An instance of class File to handle in- and output into a .restart file.
Definition: DPMBase.h:1385
bool readRestartFile(ReadOptions opt=ReadOptions::ReadAll)
Reads all the particle data corresponding to a given, existing . restart file (for more details regar...