walberla::vtk::internal::BlockCellDataWriter Class Referenceabstract

Detailed Description

Interface that is used by VTKOutput in order to write data to VTK files.

If one wants to write block data to a VTK file, one must implement a class that derives from vtk::internal::BlockCellDataWriter. An instance of this class then can be registered at a VTKOutput object. Every time the output function of this VTKOutput object is triggered, all registered BlockCellDataWriter objects are called.

Implementations of vtk::internal::BlockCellDataWriter are not supposed to inherit directly from vtk::internal::BlockCellDataWriter but from vtk::BlockCellDataWriter which provides a much nicer interface for the user to implement!

Every class derived from BlockCellDataWriter must implement two push functions that write one data element to either an output stream or a Base64Writer. Typically, a private "evaluate" function is implemented and called in both push functions:

void push( std::ostream& os, const cell_idx_t x, const cell_idx_t y, const cell_idx_t z, const cell_idx_t f )
{
vtk::toStream( os, evaluate(x,y,z,f) ); // to prevent the data output stream from writing ascii characters
// for [unsigned] char data instead of numbers
}
void push( Base64Writer& b64, const cell_idx_t x, const cell_idx_t y, const cell_idx_t z, const cell_idx_t f )
{
b64 << evaluate(x,y,z,f);
}
[DataType] evaluate( const cell_idx_t x, const cell_idx_t y, const cell_idx_t z, const cell_idx_t f ) { ... }

Both push functions always receive block local cell coordinates corresponding to the two protected members "block_" and "blockStorage_". The data elements which are pushed to the stream/Base64Writer must always be of the same type! Every data type is assigned a specific string in VTK. This string must be returned by the pure virtual member function "typeString()". This function should always be implemented by calling the utility function "vtk::typeToString()":

std::string typeString() const { return vtk::typeToString< [DataType] >(); }

Additionally, every class derived from BlockCellDataWriter can implement two further push functions that are used for resampling the data. The parameters passed to these two functions are as follows:

  • os/b64: the output stream/base64 writer
  • x/y/z: block local cell coordinates of the cell that contains the point (globalX,globalY,globalZ)
  • f: the "f value"/"dimension"/number of components
  • local[X/Y/Z]Cell: coordinates of the point (globalX,globalY,globalZ) in block local cell coordinates In contrast to x/y/z (which are discrete values!), these coordinates are continuous/exact.
  • global[X/Y/Z]: the center of the "resampled" cell in global coordinates (within the global 3D simulation space)
  • samplingD[x/y/z]: the size/extent of the "resampled" cell in x-/y-/z-direction If you do not provide your own implementation of these two functions, than the default implementation provided by class BlockCellDataWriter is used which performs a simple nearest neighbor interpolation:
    void push( std::ostream& os, const cell_idx_t x, const cell_idx_t y, const cell_idx_t z, const cell_idx_t f,
    const real_t, const real_t, const real_t, const real_t, const real_t, const real_t,
    const real_t, const real_t, const real_t ) { push( os, x, y, z, f ); }
    void push( Base64Writer& b64, const cell_idx_t x, const cell_idx_t y, const cell_idx_t z, const cell_idx_t f,
    const real_t, const real_t, const real_t, const real_t, const real_t, const real_t,
    const real_t, const real_t, const real_t ) { push( b64, x, y, z, f ); }

Every time "configure( const IBlock& block, const StructuredBlockStorage& sbs )" is called, the block and its corresponding structured block storage assigned to the BlockCellDataWriter may change. This triggers the call of a protected member function "configure()" which must be implemented and is intended for reacting to these changes.

#include <BlockCellDataWriter.h>

+ Inheritance diagram for walberla::vtk::internal::BlockCellDataWriter:

Public Member Functions

 BlockCellDataWriter (const std::string &id)
 
virtual ~BlockCellDataWriter ()=default
 
void configure (const IBlock &block, const StructuredBlockStorage &sbs)
 
virtual void push (std::ostream &os, const cell_idx_t x, const cell_idx_t y, const cell_idx_t z, const cell_idx_t f)=0
 For the documentation of this function, please refer to the documentation/general description of this class. More...
 
virtual void push (Base64Writer &b64, const cell_idx_t x, const cell_idx_t y, const cell_idx_t z, const cell_idx_t f)=0
 For the documentation of this function, please refer to the documentation/general description of this class. More...
 
virtual void push (std::ostream &os, const cell_idx_t x, const cell_idx_t y, const cell_idx_t z, const cell_idx_t f, const real_t localXCell, const real_t localYCell, const real_t localZCell, const real_t globalX, const real_t globalY, const real_t globalZ, const real_t samplingDx, const real_t samplingDy, const real_t samplingDz)
 For the documentation of this function, please refer to the documentation/general description of this class. More...
 
virtual void push (Base64Writer &b64, const cell_idx_t x, const cell_idx_t y, const cell_idx_t z, const cell_idx_t f, const real_t localXCell, const real_t localYCell, const real_t localZCell, const real_t globalX, const real_t globalY, const real_t globalZ, const real_t samplingDx, const real_t samplingDy, const real_t samplingDz)
 For the documentation of this function, please refer to the documentation/general description of this class. More...
 
uint_t xSize () const
 
uint_t ySize () const
 
uint_t zSize () const
 
virtual uint_t fSize () const =0
 must return the size of the fourth dimension More...
 
virtual std::string typeString () const =0
 Every data type is assigned a specific string in VTK. More...
 
const std::string & identifier () const
 

Protected Member Functions

virtual void configure ()=0
 Every time "configure( const IBlock& block, const StructuredBlockStorage& sbs )" is called, the block and its corresponding structured block storage assigned to the BlockCellDataWriter may change. More...
 
void setIdentifier (const std::string &id)
 

Protected Attributes

const IBlockblock_
 
const StructuredBlockStorageblockStorage_
 
std::string identifier_
 

Private Member Functions

 BlockCellDataWriter ()=default
 

Constructor & Destructor Documentation

◆ BlockCellDataWriter() [1/2]

walberla::vtk::internal::BlockCellDataWriter::BlockCellDataWriter ( const std::string &  id)
inline

◆ ~BlockCellDataWriter()

◆ BlockCellDataWriter() [2/2]

walberla::vtk::internal::BlockCellDataWriter::BlockCellDataWriter ( )
privatedefault

Member Function Documentation

◆ configure() [1/2]

virtual void walberla::vtk::internal::BlockCellDataWriter::configure ( )
protectedpure virtual

Every time "configure( const IBlock& block, const StructuredBlockStorage& sbs )" is called, the block and its corresponding structured block storage assigned to the BlockCellDataWriter may change.

This triggers the call of this function which must be implemented and is intended for reacting to these changes.

Implemented in walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::GlobalCoordVTKWriter, walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::LocalCoordVTKWriter, walberla::field::StabilityChecker< Field_T, Filter_T, CheckFunction_T >::FValueVTKWriter, walberla::field::VTKWriter< Field_T, OutputType >, walberla::lbm::VelocityMagnitudeVTKWriter< LatticeModel_T, OutputType >, walberla::field::FlagFieldMapping< FlagField_T, T >, walberla::lbm::NonEqulibriumVTKWriter< LatticeModel_T, OutputType >, walberla::lbm::DensityVTKWriter< LatticeModel_T, OutputType >, walberla::lbm::VelocityVTKWriter< LatticeModel_T, OutputType >, walberla::vtk::DumpBlockStructureProcess, walberla::vtk::DumpBlockStructureLevel, walberla::lbm::VelocitySIMagnitudeVTKWriter< LatticeModel_T, OutputType >, walberla::lbm::VelocitySIVTKWriter< LatticeModel_T, OutputType >, walberla::field::BinarizationFieldWriter< FieldType, TargetType >, walberla::lbm::DensitySIVTKWriter< LatticeModel_T, OutputType >, walberla::lbm::VorticityComponentVTKWriter< VelocityField_T, Filter_T, OutputType >, walberla::lbm::CurlMagnitudeVTKWriter< VelocityField_T, Filter_T, OutputType >, walberla::lbm::PressureTensorVTKWriter< LatticeModel_T, OutputType >, and walberla::lbm::QCriterionVTKWriter< VelocityField_T, Filter_T, OutputType >.

◆ configure() [2/2]

void walberla::vtk::internal::BlockCellDataWriter::configure ( const IBlock block,
const StructuredBlockStorage sbs 
)
inline

◆ fSize()

virtual uint_t walberla::vtk::internal::BlockCellDataWriter::fSize ( ) const
pure virtual

must return the size of the fourth dimension

(data fields storing scalar values return "1", data fields storing vector data return the size of the vector)

Implemented in walberla::vtk::BlockCellDataWriter< T, F_SIZE_ARG >.

◆ identifier()

const std::string& walberla::vtk::internal::BlockCellDataWriter::identifier ( ) const
inline

◆ push() [1/4]

◆ push() [2/4]

◆ push() [3/4]

◆ push() [4/4]

◆ setIdentifier()

void walberla::vtk::internal::BlockCellDataWriter::setIdentifier ( const std::string &  id)
inlineprotected

◆ typeString()

virtual std::string walberla::vtk::internal::BlockCellDataWriter::typeString ( ) const
pure virtual

Every data type is assigned a specific string in VTK.

This string must be returned by this function, which should always be implemented by calling the utility function "vtk::typeToString()":

std::string typeString() const { return vtk::typeToString< [DataType] >(); }

Implemented in walberla::vtk::BlockCellDataWriter< T, F_SIZE_ARG >.

◆ xSize()

uint_t walberla::vtk::internal::BlockCellDataWriter::xSize ( ) const
inline

◆ ySize()

uint_t walberla::vtk::internal::BlockCellDataWriter::ySize ( ) const
inline

◆ zSize()

uint_t walberla::vtk::internal::BlockCellDataWriter::zSize ( ) const
inline

Member Data Documentation

◆ block_

const IBlock* walberla::vtk::internal::BlockCellDataWriter::block_
protected

◆ blockStorage_

const StructuredBlockStorage* walberla::vtk::internal::BlockCellDataWriter::blockStorage_
protected

◆ identifier_

std::string walberla::vtk::internal::BlockCellDataWriter::identifier_
protected

The documentation for this class was generated from the following file:
virtual std::string typeString() const =0
Every data type is assigned a specific string in VTK.
virtual void push(std::ostream &os, const cell_idx_t x, const cell_idx_t y, const cell_idx_t z, const cell_idx_t f)=0
For the documentation of this function, please refer to the documentation/general description of this...
int cell_idx_t
Definition: DataTypes.h:151
float real_t
Definition: DataTypes.h:167
void toStream(std::ostream &os, const T value)
Definition: UtilityFunctions.h:38