|
| | PeanoTextPatchFileWriter (int dimension, const std::string &fileName, const std::string &indexFileName, IndexFileMode appendToIndexFile, double timeStamp, int precision=6) |
| | Create a new Peano text file output.
|
| virtual | ~PeanoTextPatchFileWriter () |
| | Destructor.
|
| virtual CellDataWriter * | createCellDataWriter (const std::string &identifier, int unknownsPerAxis, int recordsPerCell, const std::string &description) override |
| | Caller has to destroy this instance manually.
|
| virtual CellDataWriter * | createCellDataWriter (const std::string &identifier, int unknownsPerAxis, int recordsPerCell, const std::string &description, const std::string &metaData) override |
| | Create cell data writer.
|
| virtual CellDataWriter * | createCellDataWriter (const std::string &identifier, int unknownsPerAxis, int recordsPerCell, const std::string &description, const std::string &metaData, double *mapping) override |
| | Create writer.
|
| virtual VertexDataWriter * | createVertexDataWriter (const std::string &identifier, int unknownsPerAxis, int recordsPerVertex, const std::string &description) override |
| | Caller has to destroy this instance manually.
|
| virtual VertexDataWriter * | createVertexDataWriter (const std::string &identifier, int unknownsPerAxis, int recordsPerVertex, const std::string &description, const std::string &metaData) override |
| | Create vertex data writer.
|
| virtual VertexDataWriter * | createVertexDataWriter (const std::string &identifier, int unknownsPerAxis, int recordsPerVertex, const std::string &description, const std::string &metaData, double *mapping) override |
| | Create writer.
|
| virtual int | plotPatch (const tarch::la::Vector< 2, double > &offset, const tarch::la::Vector< 2, double > &size) override |
| virtual int | plotPatch (const tarch::la::Vector< 3, double > &offset, const tarch::la::Vector< 3, double > &size) override |
| virtual bool | writeToFile () override |
| virtual bool | isOpen () override |
| virtual void | clear () override |
| | Clear local data.
|
| virtual | ~PatchWriter ()=default |
Plot Peano's mesh data in Peano's text file format.
Consult the general plotting remarks on rationale and patterns behind the realisation of this class. This is a technical view. If you are interested in the file format that is written, you have to read the documentation of the Peano patch file format.
Meta file construction modes
There are different configuration modes. They are passed as an argument to the constructor:
- IndexFileMode::CreateNew Create a new index file. The old one is thrown away.
- IndexFileMode::NoIndexFile Ignore the whole index file stuff. Every instance of the plotter dumps its own data and they do not synchronise in any way.
- IndexFileMode::AppendNewData Try to append a new data set to a given index file.
The last one is the most sophisticated variant and deserves further explanation. First of all, the code searches for the index (or meta) file. If there is none, the code basically falls back to IndexFileMode::CreateNew, i.e. creates a new index file.
If there is a file, we open it and look what the latest time stamp in there is. For this, we call getLatestTimeStepInIndexFile(). If that time stamp is bigger than the current time stamp, we know that this index file is from a previous run. We create a backup (some people do appreciate if we do so) and then again create a new index file.
If our own time stamp matches the last time stamp in the index file, we know that the current dump is one (of many) dumps by a spacetree which contributes towards the overall picture. That is, we add our own data set to the existing time stamp.
If our own time stamp is bigger than the last one, we know that we are the first plotter of all the plotters out there which started to dump the data of the next time stamp. We append a new section for a new dump and add our own file there.
Definition at line 73 of file PeanoTextPatchFileWriter.h.
| tarch.plotter::griddata::blockstructured::PeanoTextPatchFileWriter::PeanoTextPatchFileWriter |
( |
int | dimension, |
|
|
const std::string & | fileName, |
|
|
const std::string & | indexFileName, |
|
|
IndexFileMode | appendToIndexFile, |
|
|
double | timeStamp, |
|
|
int | precision = 6 ) |
Create a new Peano text file output.
An instance of this class has to be owned by each action set that wants to dump data.
AppendNewData and the order of operations
If appendToIndexFile is IndexFileMode::AppendNewData and no index file exists yet, the constructor has to both create that index file (which, via createEmptyIndexFile(), already writes one dataset section for timeStamp) and decide whether the current writer's own timeStamp is "newer" than whatever is already in the index file, to decide if a further, separate dataset section is required. That decision has to be made by calling getLatestTimeStepInIndexFile() after the index file has been (re)created if it had to be - not before. Comparing against the "no data yet" state that getLatestTimeStepInIndexFile() reports for a file that does not exist yet would make the writer for the very first data set of a run believe it also has to open a second, empty dataset section for its own (freshly written) time stamp, and every later writer for that same time stamp would then register its data in that spurious second section rather than the first, correct one. If you touch the ordering of operations in the AppendNewData branch of the implementation, preserve this "decide only after creating/recreating" order.
- Parameters
-
| dimension | I make this a free parameter, even though most codes will pass in the compile time parameter Dimensions. However, there are codes which plot submanifolds for example or want to write 3d data within a 2d code, as they implement a 2.5d model. |
| fileName | Name of the file to write. Has to be unique per dump. |
| indexFileName | Name of the index file. Can we empty if you select NoIndexFile. |
| precision | Number of significant digits of all floating point numbers in the file: patch offsets and sizes, mappings and data. The cell and vertex data writers start with this precision and can lower or raise it via CellDataWriter::setPrecision(). The writer does not round or truncate any value beyond this precision. Small values are written as they are (no flush to zero), so a file written with 17 digits (std::numeric_limits<double>::max_digits10) holds the doubles bit-exact, e.g. for a checkpoint. Keep at least six digits on deep adaptive meshes, as the patch offsets otherwise become imprecise. |