Peano 4
Loading...
Searching...
No Matches
tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter Class Reference

Plot Peano's mesh data in Peano's text file format. More...

#include <PeanoTextPatchFileWriter.h>

Inheritance diagram for tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter:
Collaboration diagram for tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter:

Data Structures

class  CellDataWriter
 
class  VertexDataWriter
 

Public Types

enum class  IndexFileMode { CreateNew , AppendNewData , NoIndexFile }
 

Public Member Functions

 PeanoTextPatchFileWriter (int dimension, const std::string &fileName, const std::string &indexFileName, IndexFileMode appendToIndexFile, double timeStamp)
 Create a new Peano text file output.
 
virtual ~PeanoTextPatchFileWriter ()
 Destructor.
 
virtual CellDataWritercreateCellDataWriter (const std::string &identifier, int unknownsPerAxis, int recordsPerCell, const std::string &description) override
 Caller has to destroy this instance manually.
 
virtual CellDataWritercreateCellDataWriter (const std::string &identifier, int unknownsPerAxis, int recordsPerCell, const std::string &description, const std::string &metaData) override
 
virtual CellDataWritercreateCellDataWriter (const std::string &identifier, int unknownsPerAxis, int recordsPerCell, const std::string &description, const std::string &metaData, double *mapping) override
 
virtual VertexDataWritercreateVertexDataWriter (const std::string &identifier, int unknownsPerAxis, int recordsPerVertex, const std::string &description) override
 Caller has to destroy this instance manually.
 
virtual VertexDataWritercreateVertexDataWriter (const std::string &identifier, int unknownsPerAxis, int recordsPerVertex, const std::string &description, const std::string &metaData) override
 
virtual VertexDataWritercreateVertexDataWriter (const std::string &identifier, int unknownsPerAxis, int recordsPerVertex, const std::string &description, const std::string &metaData, double *mapping) override
 
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.
 

Protected Member Functions

void writeMetaData (const std::string &metaData)
 
void writeMapping (int totalEntries, double *values)
 
void createBackupOfMetaFile ()
 
void createEmptyIndexFile ()
 
void addNewDatasetToIndexFile (double timestamp)
 
void addNewFileToCurrentDataSetInIndexFile (const std::string &filename)
 
double getLatestTimeStepInIndexFile () const
 Find latest time step in index file.
 

Protected Attributes

std::string _fileName
 
std::string _indexFile
 
bool _writtenToFile
 
int _dimensions
 
int _patchCounter
 
std::stringstream _snapshotFileOut
 
bool _haveWrittenAtLeastOnePatch
 

Static Protected Attributes

static tarch::logging::Log _log
 
static const std::string HEADER
 

Detailed Description

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:

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 66 of file PeanoTextPatchFileWriter.h.

Member Enumeration Documentation

◆ IndexFileMode

Enumerator
CreateNew 
AppendNewData 
NoIndexFile 

Definition at line 217 of file PeanoTextPatchFileWriter.h.

Constructor & Destructor Documentation

◆ PeanoTextPatchFileWriter()

tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::PeanoTextPatchFileWriter ( int dimension,
const std::string & fileName,
const std::string & indexFileName,
IndexFileMode appendToIndexFile,
double timeStamp )

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.

Parameters
dimensionI 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.
fileNameName of the file to write. Has to be unique per dump.
indexFileNameName of the index file. Can we empty if you select NoIndexFile.

Definition at line 131 of file PeanoTextPatchFileWriter.cpp.

References _fileName, _indexFile, _snapshotFileOut, addNewDatasetToIndexFile(), addNewFileToCurrentDataSetInIndexFile(), AppendNewData, assertion, clear(), createBackupOfMetaFile(), createEmptyIndexFile(), CreateNew, getLatestTimeStepInIndexFile(), logDebug, logInfo, logWarning, NoIndexFile, tarch::la::relativeEpsNormaledAgainstValueGreaterOne(), and tarch::la::smaller().

Here is the call graph for this function:

◆ ~PeanoTextPatchFileWriter()

tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::~PeanoTextPatchFileWriter ( )
virtual

Destructor.

The destructor is empty, i.e. if you destroy this object, your data are lost. You have to dump the data beforehand manually by calling writeToFile().

Definition at line 214 of file PeanoTextPatchFileWriter.cpp.

Member Function Documentation

◆ addNewDatasetToIndexFile()

void tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::addNewDatasetToIndexFile ( double timestamp)
protected

Definition at line 65 of file PeanoTextPatchFileWriter.cpp.

Referenced by PeanoTextPatchFileWriter().

Here is the caller graph for this function:

◆ addNewFileToCurrentDataSetInIndexFile()

void tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::addNewFileToCurrentDataSetInIndexFile ( const std::string & filename)
protected

Definition at line 76 of file PeanoTextPatchFileWriter.cpp.

References assertion2, logDebug, and logWarning.

Referenced by PeanoTextPatchFileWriter().

Here is the caller graph for this function:

◆ clear()

void tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::clear ( )
overridevirtual

Clear local data.

Clear the writer, i.e. erase all the data. However, as the writer does not track how many vertex and cell writers you've created, it's up to you to ensure that none of these instances is left. So we clear the core data, but we do not clear the data within any data writer which you have created by calling routines such as createCellDataWriter().

Implements tarch::plotter::griddata::blockstructured::PatchWriter.

Definition at line 383 of file PeanoTextPatchFileWriter.cpp.

Referenced by peano4.output.Makefile.Makefile::__init__(), and PeanoTextPatchFileWriter().

Here is the caller graph for this function:

◆ createBackupOfMetaFile()

void tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::createBackupOfMetaFile ( )
protected

Definition at line 29 of file PeanoTextPatchFileWriter.cpp.

References _indexFile.

Referenced by PeanoTextPatchFileWriter().

Here is the caller graph for this function:

◆ createCellDataWriter() [1/3]

tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::CellDataWriter * tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::createCellDataWriter ( const std::string & identifier,
int unknownsPerAxis,
int recordsPerCell,
const std::string & description )
overridevirtual

Caller has to destroy this instance manually.

Implements tarch::plotter::griddata::blockstructured::PatchWriter.

Definition at line 237 of file PeanoTextPatchFileWriter.cpp.

◆ createCellDataWriter() [2/3]

tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::CellDataWriter * tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::createCellDataWriter ( const std::string & identifier,
int unknownsPerAxis,
int recordsPerCell,
const std::string & description,
const std::string & metaData )
overridevirtual

◆ createCellDataWriter() [3/3]

tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::CellDataWriter * tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::createCellDataWriter ( const std::string & identifier,
int unknownsPerAxis,
int recordsPerCell,
const std::string & description,
const std::string & metaData,
double * mapping )
overridevirtual

◆ createEmptyIndexFile()

void tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::createEmptyIndexFile ( )
protected

Definition at line 112 of file PeanoTextPatchFileWriter.cpp.

References logError, and logInfo.

Referenced by PeanoTextPatchFileWriter().

Here is the caller graph for this function:

◆ createVertexDataWriter() [1/3]

tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::VertexDataWriter * tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::createVertexDataWriter ( const std::string & identifier,
int unknownsPerAxis,
int recordsPerVertex,
const std::string & description )
overridevirtual

Caller has to destroy this instance manually.

Implements tarch::plotter::griddata::blockstructured::PatchWriter.

Definition at line 267 of file PeanoTextPatchFileWriter.cpp.

◆ createVertexDataWriter() [2/3]

tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::VertexDataWriter * tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::createVertexDataWriter ( const std::string & identifier,
int unknownsPerAxis,
int recordsPerVertex,
const std::string & description,
const std::string & metaData )
overridevirtual

◆ createVertexDataWriter() [3/3]

tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::VertexDataWriter * tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::createVertexDataWriter ( const std::string & identifier,
int unknownsPerAxis,
int recordsPerVertex,
const std::string & description,
const std::string & metaData,
double * mapping )
overridevirtual

◆ getLatestTimeStepInIndexFile()

double tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::getLatestTimeStepInIndexFile ( ) const
protected

Find latest time step in index file.

This routine runs through the index file and searches for the latest entry in there which looks similar to

timestamp 0.000000000000000000000000e+00

It will then return the value of this time stamp.

Definition at line 37 of file PeanoTextPatchFileWriter.cpp.

References logError.

Referenced by PeanoTextPatchFileWriter().

Here is the caller graph for this function:

◆ isOpen()

bool tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::isOpen ( )
overridevirtual
Returns
Whether writer is ready to accept data.

Implements tarch::plotter::griddata::blockstructured::PatchWriter.

Definition at line 381 of file PeanoTextPatchFileWriter.cpp.

◆ plotPatch() [1/2]

int tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::plotPatch ( const tarch::la::Vector< 2, double > & offset,
const tarch::la::Vector< 2, double > & size )
overridevirtual
Returns
Patch index, i.e. unique number of this patch

Implements tarch::plotter::griddata::blockstructured::PatchWriter.

Definition at line 297 of file PeanoTextPatchFileWriter.cpp.

◆ plotPatch() [2/2]

int tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::plotPatch ( const tarch::la::Vector< 3, double > & offset,
const tarch::la::Vector< 3, double > & size )
overridevirtual
Returns
Patch index, i.e. unique number of this patch

Implements tarch::plotter::griddata::blockstructured::PatchWriter.

Definition at line 330 of file PeanoTextPatchFileWriter.cpp.

References assertion.

◆ writeMapping()

void tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::writeMapping ( int totalEntries,
double * values )
protected

◆ writeMetaData()

void tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::writeMetaData ( const std::string & metaData)
protected

◆ writeToFile()

bool tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::writeToFile ( )
overridevirtual
Returns
Write has been successful

Implements tarch::plotter::griddata::blockstructured::PatchWriter.

Definition at line 359 of file PeanoTextPatchFileWriter.cpp.

References assertion, logDebug, and logError.

Field Documentation

◆ _dimensions

◆ _fileName

std::string tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::_fileName
protected

Definition at line 71 of file PeanoTextPatchFileWriter.h.

Referenced by PeanoTextPatchFileWriter().

◆ _haveWrittenAtLeastOnePatch

bool tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::_haveWrittenAtLeastOnePatch
protected

Definition at line 81 of file PeanoTextPatchFileWriter.h.

◆ _indexFile

std::string tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::_indexFile
protected

Definition at line 72 of file PeanoTextPatchFileWriter.h.

Referenced by createBackupOfMetaFile(), and PeanoTextPatchFileWriter().

◆ _log

tarch::logging::Log tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::_log
staticprotected

Definition at line 68 of file PeanoTextPatchFileWriter.h.

◆ _patchCounter

int tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::_patchCounter
protected

Definition at line 78 of file PeanoTextPatchFileWriter.h.

◆ _snapshotFileOut

◆ _writtenToFile

bool tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::_writtenToFile
protected

Definition at line 74 of file PeanoTextPatchFileWriter.h.

◆ HEADER

const std::string tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::HEADER
staticprotected
Initial value:
= "# \n"
"# Peano patch file \n"
"# Version 0.2 \n"
"# \n"

Definition at line 69 of file PeanoTextPatchFileWriter.h.


The documentation for this class was generated from the following files: