◆ DataFiles()
DataFiles::DataFiles |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
|
inline |
opens the input and output data files
41 size_t dot =
name.find_last_of(
'.');
43 if (dot==std::string::npos) {
48 dot =
name.find_last_of(
'.');
49 char afterDot =
name[dot + 1];
51 if (afterDot >=
'0' && afterDot <=
'9') {
58 size_t dot =
name.find_last_of(
'.');
63 for(
unsigned processorID = 0;
true; ++processorID) {
65 std::string fileName =
name +
".data" + std::to_string(processorID) +
ending;
66 auto* file =
new std::ifstream(fileName.c_str());
70 iFiles.emplace_back(file,0);
77 std::string oFileName =
name +
".data" +
ending;
78 oFile.open(oFileName);
82 logger(
INFO,
"Opened % for output", oFileName);
std::string getName(int argc, char *argv[])
Definition: CombineParallelDataFiles.cpp:12
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
std::ofstream oFile
Definition: CombineParallelDataFiles.cpp:27
std::vector< IFile > iFiles
Definition: CombineParallelDataFiles.cpp:26
void write()
Definition: CombineParallelDataFiles.cpp:100
std::string ending
Definition: CombineParallelDataFiles.cpp:29
std::string name
Definition: MercuryProb.h:48
References ending, ERROR, getName(), iFiles, INFO, logger, units::name, oFile, and write().
◆ ~DataFiles()
DataFiles::~DataFiles |
( |
| ) |
|
|
inline |
closes the input/output data files
92 for (
auto iFile :
iFiles) {
References iFiles.
◆ write()
void DataFiles::write |
( |
| ) |
|
|
inline |
write all time steps
bool writeTimeStep()
Definition: CombineParallelDataFiles.cpp:110
unsigned oCount
Definition: CombineParallelDataFiles.cpp:28
References INFO, logger, oCount, and writeTimeStep().
Referenced by DataFiles().
◆ writeTimeStep()
bool DataFiles::writeTimeStep |
( |
| ) |
|
|
inlineprivate |
writes single timestep
115 for(
auto& iFile :
iFiles) {
117 *iFile.file >> iFile.n;
120 *iFile.file >> iFile.time;
122 if (iFile.file->fail())
return false;
124 std::getline(*iFile.file, line);
126 static std::string headerLine = line;
129 if (line != headerLine || iFile.time < time) {
131 *iFile.file >> iFile.n;
133 *iFile.file >> iFile.time;
134 if (iFile.file->fail())
return false;
135 std::getline(*iFile.file, line);
136 }
while (line != headerLine || iFile.time < time);
137 logger(
WARN,
"Mistake detected; moving forward to time %",iFile.time);
145 oFile <<
n <<
' ' << time << line <<
'\n';
148 for(
auto& iFile :
iFiles) {
149 for (
unsigned i=0;
i<iFile.n; ++
i) {
150 std::getline(*iFile.file, line);
151 oFile << line <<
'\n';
const unsigned n
Definition: CG3DPackingUnitTest.cpp:32
double Mdouble
Definition: GeneralDefine.h:34
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
References constants::i, iFiles, INFO, logger, n, oCount, oFile, and WARN.
Referenced by write().
◆ ending
std::string DataFiles::ending = "" |
|
private |
◆ iFiles
std::vector<IFile> DataFiles::iFiles |
|
private |
◆ oCount
unsigned DataFiles::oCount = 0 |
|
private |
◆ oFile
std::ofstream DataFiles::oFile |
|
private |
The documentation for this class was generated from the following file: