#include <iostream>
#include <fstream>
#include <Logger.h>
#include "MercuryData.h"
#include "VTKData.h"
Go to the source code of this file.
int main |
( |
int argc |
, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 50 of file data2pvd.cpp.
References ERROR, FATAL, MercuryDataFile::isMercuryDataFile(), logger, and VERBOSE.
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 output files 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.");
89 if (infile.isMercuryDataFile<3>())
92 return transformMercuryToVTK<3>(infile, argv[2]);
94 else if (infile.isMercuryDataFile<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]);
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
LL< Log::ERROR > ERROR
Error log level.
LL< Log::FATAL > FATAL
Fatal log level.
LL< Log::VERBOSE > VERBOSE
Verbose information.
template<std::size_t NDIMS>
Templated version to automagically generate VTK output files.
this function reads the NDIMS-dimensional Mercury .data file, and writes all the corresponding VTK output files.
Definition at line 111 of file data2pvd.cpp.
References VTKPointDescriptor< T >::addProperty(), VTKCollection::append(), MercuryDataFile::as(), FATAL, INFO, logger, and WARN.
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()
LL< Log::WARN > WARN
Warning log level.
LL< Log::FATAL > FATAL
Fatal log level.
std::enable_if< std::is_array< DATATYPE >::value, VTKPointDescriptor & >::type addProperty(std::string name, DATATYPE T::*m, bool isPrimary=false)