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[] 
)
9 {
10  // write manual if number of arguments is not right
11  const std::string manual = "Enter the prefix of the simulation you want to restart\n"
12  " and, optionally, the prefix of the output files.\n"
13  " e.g. restart2data input output\n"
14  " reads from input.restart and writes to output.data\n";
15  if (argc<2) logger(ERROR,manual);
16 
17  // first argument is used as prefix for the input
18  std::string in = argv[1];
19  //append .restart if necessary
20  if (in.find(".restart")==-1) in += ".restart";
21  logger(INFO,"Reading from %", in);
22 
23  // if second argument is given, use it as prefix for the output; otherwise, use input prefix
24  bool prefixGiven = argc>=3 && argv[2][0]!='-';
25  char* out = prefixGiven?argv[2]:argv[1];
26  logger(INFO,"Writing to %", out);
27 
28  //read in from restart file and output data file
30  if (problem.readRestartFile(in)) {
31  problem.setName(out);
32  problem.cgHandler.computeContactPoints();
33  problem.writeXBallsScript();
34  problem.writeDataFile();
35  problem.writeFStatFile();
36  problem.writeEneFile();
37  logger(INFO,"Written to %", problem.dataFile.getFullName());
38  } else if (problem.readRestartFile(std::string(in)+".restart.0")
39  || problem.readRestartFile(std::string(in)+".restart.0000")) {
40  do {
41  problem.setName(out);
42  problem.cgHandler.computeContactPoints();
43  problem.dataFile.setCounter(problem.restartFile.getCounter() - 1);
44  problem.fStatFile.setCounter(problem.restartFile.getCounter() - 1);
45  problem.eneFile.setCounter(problem.restartFile.getCounter() - 1);
46  //problem.writeXBallsScript();
47  problem.writeDataFile();
48  problem.writeFStatFile();
49  problem.writeEneFile();
50  logger(INFO,"Written to %", problem.dataFile.getFullName());
51  problem.setName(in);
52  } while (problem.readRestartFile());
53  } else {
54  logger(ERROR,"File % not found",in);
55  }
56 }
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
LL< Log::ERROR > ERROR
Error log level.
Definition: Logger.cc:32
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:16
#define INFO(i)
Definition: mumps_solver.h:54
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
Constructor for SteadyAxisymAdvectionDiffusion problem
Definition: steady_axisym_advection_diffusion.cc:213
std::ofstream out("Result.txt")

References ERROR, INFO, logger, out(), problem, and oomph::Global_string_for_annotation::string().