35 template<std::
size_t NDIMS>
50 int main(
int argc,
char** argv)
57 " This program converts MercuryDPM .data files to ParaView .pvd data files.\n"
58 " which can then be used directly into ParaView, to visualize your particles.\n"
60 " infile: MercuryDPM .data file\n"
62 " outfilePrefix: Prefix to prepend to the outputfiles generated.\n"
63 " The following files will be generated:\n"
68 " - prefix_987654321.vtu\n"
69 " depending on the amount of timesteps.", argv[0]);
79 "Please make sure the file exists and you have the appropriate rights.", argv[1]);
83 if (std::string(argv[2]).back() ==
'/')
85 logger(
ERROR,
"The output prefix ends in a slash. This is not allowed.");
92 return transformMercuryToVTK<3>(infile, argv[2]);
97 return transformMercuryToVTK<2>(infile, argv[2]);
101 logger(
ERROR,
"The file '%' does not seem to be a Mercury .data file.\n"
102 "Please make sure you are reading the correct file.", argv[1]);
110 template<std::
size_t NDIMS>
133 logger(
FATAL,
"Could not open '%.pvd' for output.\n"
134 "Please make sure you have the appropriate permissions and try again.", prefix);
136 std::size_t timestepCount = 0;
142 std::ostringstream filename;
143 filename << prefix <<
'_' << ts.getTimeStepID() <<
".vtu";
149 logger(
WARN,
"Could not open '%' for output.\n"
150 "Please make sure you have the appropriate permissions and try again.", filename.str());
157 logger(
WARN,
"An IOError occurred during the reading of the input file.\n"
158 "Please make sure you are feeding this tool mercury data files.");
164 timeStepFile.write(ts);
169 std::string strippedPath = filename.str();
172 std::string::size_type slashPosition = strippedPath.rfind(
'/');
175 if (slashPosition != std::string::npos)
176 strippedPath = strippedPath.substr(slashPosition + 1);
178 collection.
append(strippedPath);
183 logger(
INFO,
"Written % timesteps in a %D system.", timestepCount, NDIMS);
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
LL< Log::INFO > INFO
Info log level.
IteratorProxy< NDIMS > as()
bool isMercuryDataFile()
Checks if this file is a valid Mercury 3D data file. This function jumps to the start of the file...
LL< Log::ERROR > ERROR
Error log level.
LL< Log::WARN > WARN
Warning log level.
void append(std::string filename)
LL< Log::FATAL > FATAL
Fatal log level.
LL< Log::VERBOSE > VERBOSE
Verbose information.
std::enable_if< std::is_array< DATATYPE >::value, VTKPointDescriptor & >::type addProperty(std::string name, DATATYPE T::*m, bool isPrimary=false)
int transformMercuryToVTK(MercuryDataFile &file, std::string prefix)
Templated version to automagically generate VTK output files.
int main(int argc, char **argv)