MercuryDPM  Alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mercury2pvd.cpp File Reference
#include "DPMBase.h"

Go to the source code of this file.

Classes

class  Mercury2PVD
 

Functions

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

Function Documentation

int main ( int argc  UNUSED,
char *argv[]  UNUSED 
)
Todo:
TW maybe this should be part of readRestartFile

Definition at line 37 of file mercury2pvd.cpp.

References BaseHandler< T >::clear(), Files::dataFile, FATAL, Files::fStatFile, File::getName(), Files::getName(), BaseHandler< T >::getNumberOfObjects(), DPMBase::getTime(), INFO, DPMBase::interactionHandler, logger, MULTIPLE_FILES, File::open(), DPMBase::particleHandler, DPMBase::readNextDataFile(), DPMBase::readRestartFile(), Files::restartFile, File::setCounter(), File::setName(), Files::setName(), InteractionHandler::setWriteVTK(), DPMBase::wallHandler, WARN, WallHandler::writeVTK(), and ParticleHandler::writeVTK().

38 {
39  Mercury2PVD m;
40 
41  //Check to see if we received one argument
42  if (argc == 2) {
43  std::string prefix = argv[1];
44  std::string::size_type pos = prefix.find(".restart");
45 
46  if (pos == std::string::npos) {
47  m.setName(argv[1]);
48  } else {
49  m.setName(prefix.substr(0,pos-1));
50  m.restartFile.setName(prefix);
51  logger(INFO, "restart file % given; prefix is %",m.restartFile.getName(),m.getName());
52  }
53 
54  } else {
55  m.setName("../Drivers/MercuryCG/NewtonsCradleSelfTest");
56  //We didn't. Print a usage and exit the program.
57  logger(WARN, "Usage: mercury2pvd [prefix] \n"
58  " This program converts MercuryDPM files into ParaView data files,\n"
59  " which can then be used to visualize your particles.\n"
60  "\n"
61  " prefix: Prefix to prepend to the i/o files.\n"
62  "\n"
63  " The following files will be generated:\n"
64  " - prefix.pvd\n"
65  " - prefix_0.vtu\n"
66  " - prefix_1.vtu\n"
67  " ( ... )\n"
68  " - prefix_987654321.vtu\n"
69  " depending on the amount of timesteps.", argv[0]);
70  }
71 
72  //Store path as it is overwritten by readRestartFile
74  std::string::size_type pos = m.getName().find_last_of("/");
75  std::string path = m.getName().substr(0,pos+1);
76  logger(INFO,"Path %",path);
77 
78  //Read restart file, and re-add path to data and fstat file name
79  logger(INFO,"Reading restart file %",m.restartFile.getName());
80  bool success = m.readRestartFile();
81  if (!success) logger(FATAL,"Reading restart file % failed",m.restartFile.getName());
82  m.dataFile.setName(path+m.dataFile.getName());
83  m.fStatFile.setName(path+m.fStatFile.getName());
84 
85  //prepare dpm class for reading in
86  m.dataFile.open(std::fstream::in);
87  m.fStatFile.open(std::fstream::in);
89  m.dataFile.setCounter(0);
90  m.fStatFile.setCounter(0);
92 
93  //read in
94  logger(INFO,"Reading data/fstat files %, %",m.dataFile.getName(), m.fStatFile.getName());
95  while (m.readNextDataFile())
96  {
97  //m.readNextFStatFile();
99  //m.writeOutputFiles()
101  //m.interactionHandler.writeVTK();
102  m.wallHandler.writeVTK();
103  }
104 }
void writeVTK() const
Writes all particles into a vtk file format (unstructured grid), consisting of particle positions...
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
bool readRestartFile(bool restarted=true)
Reads all the particle data corresponding to the current saved time step. Which is what the restart f...
Definition: DPMBase.cc:1629
LL< Log::INFO > INFO
Info log level.
Definition: Logger.cc:53
void setCounter(unsigned int counter)
Allows the user to set the file counter according to his need. Sets File::counter_.
Definition: File.cc:224
File restartFile
An instance of class File to handle in- and output into a .restart file.
Definition: Files.h:219
LL< Log::WARN > WARN
Warning log level.
Definition: Logger.cc:52
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: Files.cc:150
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1001
File fStatFile
An instance of class File to handle in- and output into a .fstat file.
Definition: Files.h:209
LL< Log::FATAL > FATAL
Fatal log level.
Definition: Logger.cc:50
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: Files.h:204
bool readNextDataFile(unsigned int format=0)
Reads the next data file with default format=0. However, one can modify the format based on whether t...
Definition: DPMBase.cc:1434
unsigned int getNumberOfObjects() const
Gets the number of Object in this BaseHandler.
Definition: BaseHandler.h:487
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1016
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1006
void setWriteVTK(FileType f)
bool open()
Checks if the file stream fstream_ has any issues while opening. Alongside, it also increments the ne...
Definition: File.cc:320
each time-step will be written into/read from separate files numbered consecutively: name_...
void setName(const std::string &name)
Sets the file name, e.g. "Name.data".
Definition: File.cc:196
Mdouble getTime() const
Access function for the time.
Definition: DPMBase.cc:169
const std::string & getName() const
Returns the name of the file. Does not allow to change it though.
Definition: Files.cc:132
const std::string & getName() const
Allows to access the file name, e.g., "problem.data".
Definition: File.cc:163
void writeVTK() const
Writes all walls into a vtk format, consisting of points (edges) and cells (faces).
Definition: WallHandler.cc:239
void clear()
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0...
Definition: BaseHandler.h:392