LifeV
ExporterVTK< MeshType > Class Template Reference

ExporterVTK data exporter. More...

#include <ExporterVTK.hpp>

+ Inheritance diagram for ExporterVTK< MeshType >:
+ Collaboration diagram for ExporterVTK< MeshType >:

Public Types

enum  VTK_CELL {
  VTK_VERTEX = 1, VTK_POLY_VERTEX = 2, VTK_LINE = 3, VTK_POLY_LINE = 4,
  VTK_TRIANGLE = 5, VTK_TRIANGLE_STRIP = 6, VTK_POLYGON = 7, VTK_PIXEL = 8,
  VTK_QUAD = 9, VTK_TETRA = 10, VTK_VOXEL = 11, VTK_HEXAHEDRON = 12,
  VTK_WEDGE = 13, VTK_PYRAMID = 14, VTK_QUADRATIC_EDGE = 21, VTK_QUADRATIC_TRIANGLE = 22,
  VTK_QUADRATIC_QUAD = 23, VTK_QUADRATIC_TETRA = 24, VTK_QUADRATIC_HEXAHEDRON = 25
}
 
enum  EXPORT_MODE { ASCII_EXPORT = 1, BINARY_EXPORT = 2 }
 
enum  FLOAT_PRECISION { SINGLE_PRECISION = 1, DOUBLE_PRECISION = 2 }
 
typedef MeshType mesh_Type
 
typedef Exporter< mesh_Typesuper
 
typedef super::meshPtr_Type meshPtr_Type
 
typedef super::commPtr_Type commPtr_Type
 
typedef super::feSpacePtr_Type feSpacePtr_Type
 
typedef super::exporterData_Type exporterData_Type
 
typedef super::feTypeToDataIdMap_Type::iterator feTypeToDataIdMap_Type_Type
 
typedef const exporterData_Type::WhereEnumwhere_Type
 

Static members

static MapEpetraType const MapType
 returns the type of the map to use for the VectorEpetra More...
 

Constructors & Destructor

 ExporterVTK ()
 Default constructor. More...
 
 ExporterVTK (const GetPot &data_file, const std::string prefix)
 
virtual ~ExporterVTK ()
 Destructor. More...
 
 ExporterVTK (const ExporterVTK &example)
 Copy constructor. More...
 

Public Methods

virtual void postProcess (const Real &time)
 Post-process the variables added to the list. More...
 
virtual UInt importFromTime (const Real &)
 Import data from previous simulations at a certain time. More...
 
virtual void import (const Real &, const Real &)
 Import data from previous simulations and rebuild the internal time counters. More...
 
virtual void import (const Real &Tstart)
 Import data from previous simulations. More...
 
void exportPID (meshPtr_Type, commPtr_Type comm, const bool=false)
 temporary: the method should work form the Exporter class More...
 
virtual void setDataFromGetPot (const GetPot &dataFile, const std::string &section="exporter")
 Set data from file. More...
 

Get methods

virtual MapEpetraType mapType () const
 returns the type of the map to use for the VectorEpetra More...
 

Private methods

UInt whichCellType (const feSpacePtr_Type &_feSpacePtr)
 
void composePVTUStream (const exporterData_Type &dvar, std::stringstream &pVTUStringStream)
 
void createPointsMaps (const feSpacePtr_Type &_feSpacePtr, std::map< UInt, UInt > &globalToLocalPointsMap, std::map< UInt, UInt > &localToGlobalPointsMap, std::vector< Vector > &coordinatesOfPoints)
 
void composeVTKCollection (const std::string &variableName, std::stringstream &vtkCollectionStringStream)
 
void composeVTUHeaderStream (UInt numPoints, std::stringstream &vtuHeaderStringStream)
 
void composeVTUFooterStream (std::stringstream &vtuFooterStringStream)
 
void composeVTUGeoStream (const feSpacePtr_Type &_feSpacePtr, const std::map< UInt, UInt > &globalToLocalPointsMap, const std::vector< Vector > &coordinatesOfPoints, std::stringstream &vtuGeoStringStream)
 
void composeTypeDataHeaderStream (where_Type where, std::stringstream &typeDataHeaderStringStream)
 
void composeTypeDataFooterStream (where_Type where, std::stringstream &typeDataFooterStringStream)
 
void composeDataArrayStream (const exporterData_Type &dvar, const std::map< UInt, UInt > &localToGlobalMap, std::stringstream &dataArraysStringStream)
 
void composeDataArrayStream (where_Type where, std::stringstream &dataArraysStringStream)
 
virtual void readScalar (ExporterData< mesh_Type > &)
 The scalar reader (specialization of the parent class method) More...
 
virtual void readVector (ExporterData< mesh_Type > &)
 The vector reader (specialization of the parent class method) More...
 
void readVTUFiles (exporterData_Type &dvar)
 The reader for VTU files. More...
 
void readBinaryData (const std::string &line, std::vector< Real > &values, const UInt &numBits)
 A routine for loading values stored in binary format in a VTU file. More...
 
void readASCIIData (const std::string &line, std::vector< Real > &values)
 A routine for loading values stored in ASCII format in a VTU file. More...
 

Private members

EXPORT_MODE M_exportMode
 
FLOAT_PRECISION M_floatPrecision
 
std::map< std::string, std::list< std::string > > M_pvtuFiles
 

Additional Inherited Members

- Public Types inherited from Exporter< MeshType >
typedef MeshType mesh_Type
 
typedef std::shared_ptr< MeshTypemeshPtr_Type
 
typedef Epetra_Comm comm_Type
 
typedef std::shared_ptr< comm_TypecommPtr_Type
 
typedef ExporterData< mesh_TypeexporterData_Type
 
typedef exporterData_Type::vector_Type vector_Type
 
typedef exporterData_Type::vectorPtr_Type vectorPtr_Type
 
typedef exporterData_Type::feSpace_Type feSpace_Type
 
typedef exporterData_Type::feSpacePtr_Type feSpacePtr_Type
 
typedef exporterData_Type::WhereEnum WhereEnum
 
typedef exporterData_Type::FieldTypeEnum FieldTypeEnum
 
typedef exporterData_Type::FieldRegimeEnum FieldRegimeEnum
 
typedef std::vector< exporterData_TypedataVector_Type
 
typedef dataVector_Type::iterator dataVectorIterator_Type
 
typedef std::multimap< WhereEnum, UIntwhereToDataIdMap_Type
 
typedef std::multimap< FE_TYPE, UIntfeTypeToDataIdMap_Type
 
- Public Member Functions inherited from Exporter< MeshType >
 Exporter ()
 Empty constructor for Exporter. More...
 
 Exporter (const GetPot &dfile, const std::string &prefix)
 Constructor for Exporter without prefix and procID. More...
 
virtual ~Exporter ()
 Destructor. More...
 
void addVariable (const FieldTypeEnum &type, const std::string &variableName, const feSpacePtr_Type &feSpacePtr, const vectorPtr_Type &vectorPtr, const UInt &start, const FieldRegimeEnum &regime=exporterData_Type::UnsteadyRegime, const WhereEnum &where=exporterData_Type::Node)
 Adds a new variable to be post-processed. More...
 
virtual void readVariable (exporterData_Type &dvar)
 
virtual void exportPID (meshPtr_Type &mesh, commPtr_Type &comm, const bool binaryFormat=false)
 Export the Processor ID as P0 variable. More...
 
void exportRegionMarkerID (std::shared_ptr< MeshType > mesh, std::shared_ptr< Epetra_Comm > comm)
 Export the region marker ID as P0 variable. More...
 
virtual void exportFlags (std::shared_ptr< MeshType > mesh, std::shared_ptr< Epetra_Comm > comm, flag_Type const &flag=EntityFlags::ALL)
 Export entity flags. More...
 
void setPrefix (const std::string &prefix)
 Set prefix. More...
 
void setPostDir (const std::string &Directory)
 Set the folder for pre/postprocessing. More...
 
void setTimeIndex (const UInt &timeIndex)
 Set the current time index. More...
 
void setTimeIndexStart (const UInt &timeIndexStart)
 Set the time index of the first file. More...
 
void setSave (const UInt &save)
 Set how many time step between two snapshots. More...
 
void setMultimesh (const bool &multimesh)
 Set if to save the mesh at each time step. More...
 
virtual void setMeshProcId (const meshPtr_Type mesh, const int &procId)
 
virtual void closeFile ()
 Close the output file. More...
 
const UIntsave () const
 returns how many time steps between two snapshots More...
 
const UInttimeIndexStart () const
 returns the time index of the first snapshot More...
 
const UInttimeIndex () const
 returns the time index of the current snapshot More...
 
- Protected Member Functions inherited from Exporter< MeshType >
void computePostfix ()
 compute postfix More...
 
virtual void readScalar (exporterData_Type &dvar)=0
 A method to read a scalar field (to be implemented in derived classes) More...
 
virtual void readVector (exporterData_Type &dvar)=0
 A method to read a vector field (to be implemented in derived classes) More...
 
- Protected Attributes inherited from Exporter< MeshType >
std::string M_prefix
 the file prefix More...
 
std::string M_postDir
 the name of the folder where to read or write files More...
 
UInt M_timeIndexStart
 the time index of the first snapshot More...
 
UInt M_timeIndex
 the time index of the current snapshot More...
 
UInt M_save
 how many time steps between subsequent snapshots More...
 
bool M_multimesh
 do we want to save the mesh with each snapshot? More...
 
UInt M_timeIndexWidth
 how many digits (in the file suffix) for the time index More...
 
meshPtr_Type M_mesh
 a pointer to the mesh More...
 
Int M_procId
 the ID of the process More...
 
std::string M_postfix
 the file suffix More...
 
UInt M_numImportProc
 how many processes produced the data that we want to import More...
 
whereToDataIdMap_Type M_whereToDataIdMap
 a map to retrieve all data located in the same geo entities (node or element) More...
 
feTypeToDataIdMap_Type M_feTypeToDataIdMap
 a map to retrieve all data defined in the same FE space More...
 
dataVector_Type M_dataVector
 the vector of ExporterData objects More...
 
std::list< RealM_timeSteps
 the list of time steps (for use in import procedures) More...
 

Detailed Description

template<typename MeshType>
class LifeV::ExporterVTK< MeshType >

ExporterVTK data exporter.

Definition at line 57 of file ExporterVTK.hpp.

Member Typedef Documentation

◆ mesh_Type

Definition at line 113 of file ExporterVTK.hpp.

◆ super

Definition at line 114 of file ExporterVTK.hpp.

◆ meshPtr_Type

Definition at line 115 of file ExporterVTK.hpp.

◆ commPtr_Type

Definition at line 116 of file ExporterVTK.hpp.

◆ feSpacePtr_Type

Definition at line 117 of file ExporterVTK.hpp.

◆ exporterData_Type

Definition at line 118 of file ExporterVTK.hpp.

◆ feTypeToDataIdMap_Type_Type

typedef super::feTypeToDataIdMap_Type::iterator feTypeToDataIdMap_Type_Type

Definition at line 120 of file ExporterVTK.hpp.

◆ where_Type

Definition at line 121 of file ExporterVTK.hpp.

Member Enumeration Documentation

◆ VTK_CELL

enum VTK_CELL

A list of the cell types admitted in VTK

Enumerator
VTK_VERTEX 
VTK_POLY_VERTEX 
VTK_LINE 
VTK_POLY_LINE 
VTK_TRIANGLE 
VTK_TRIANGLE_STRIP 
VTK_POLYGON 
VTK_PIXEL 
VTK_QUAD 
VTK_TETRA 
VTK_VOXEL 
VTK_HEXAHEDRON 
VTK_WEDGE 
VTK_PYRAMID 
VTK_QUADRATIC_EDGE 
VTK_QUADRATIC_TRIANGLE 
VTK_QUADRATIC_QUAD 
VTK_QUADRATIC_TETRA 
VTK_QUADRATIC_HEXAHEDRON 

Definition at line 68 of file ExporterVTK.hpp.

◆ EXPORT_MODE

The export modes currently supported are ascii and binary

Enumerator
ASCII_EXPORT 
BINARY_EXPORT 

Definition at line 98 of file ExporterVTK.hpp.

◆ FLOAT_PRECISION

Currently supported are single and double precision

Enumerator
SINGLE_PRECISION 
DOUBLE_PRECISION 

Definition at line 107 of file ExporterVTK.hpp.

Constructor & Destructor Documentation

◆ ExporterVTK() [1/3]

Default constructor.

Definition at line 399 of file ExporterVTK.hpp.

◆ ExporterVTK() [2/3]

ExporterVTK ( const GetPot data_file,
const std::string  prefix 
)

Constructor for ExporterVTK

Parameters
data_filethe GetPot data file where you must provide an [exporter] section with: "start" (start index for filenames 0 for 000, 1 for 001 etc.), "save" (how many time steps per postprocessing) "multimesh" (=true if the mesh has to be saved at each post-processing step)
theprefix for the output file (ex. "test" for test.vtu)

Definition at line 407 of file ExporterVTK.hpp.

◆ ExporterVTK() [3/3]

ExporterVTK ( const ExporterVTK< MeshType > &  example)
private

Copy constructor.

◆ ~ExporterVTK()

~ExporterVTK ( )
virtual

Destructor.

Definition at line 455 of file ExporterVTK.hpp.

Member Function Documentation

◆ postProcess()

void postProcess ( const Real time)
virtual

Post-process the variables added to the list.

Parameters
timethe solver time

Implements Exporter< MeshType >.

Definition at line 493 of file ExporterVTK.hpp.

◆ importFromTime()

virtual UInt importFromTime ( const Real )
inlinevirtual

Import data from previous simulations at a certain time.

Parameters
Timethe time of the data to be imported

Not yet implemented for ExporterVTK

Implements Exporter< MeshType >.

Definition at line 173 of file ExporterVTK.hpp.

◆ import() [1/2]

virtual void import ( const Real ,
const Real  
)
inlinevirtual

Import data from previous simulations and rebuild the internal time counters.

Parameters
importTimethe time of the snapshot to be imported
dtthe time step, is used to rebuild the history up to now

Not yet implemented for ExporterVTK

Implements Exporter< MeshType >.

Definition at line 186 of file ExporterVTK.hpp.

◆ import() [2/2]

void import ( const Real Tstart)
virtual

Import data from previous simulations.

Parameters
importTimethe time of the snapshot to be imported

Implements Exporter< MeshType >.

Definition at line 577 of file ExporterVTK.hpp.

◆ exportPID()

void exportPID ( meshPtr_Type  ,
commPtr_Type  comm,
const bool  = false 
)
inline

temporary: the method should work form the Exporter class

Definition at line 198 of file ExporterVTK.hpp.

◆ setDataFromGetPot()

void setDataFromGetPot ( const GetPot dataFile,
const std::string &  section = "exporter" 
)
virtual

Set data from file.

Parameters
dataFiledata file.
sectionsection in the data file.

Reimplemented from Exporter< MeshType >.

Definition at line 418 of file ExporterVTK.hpp.

◆ mapType()

MapEpetraType mapType ( ) const
virtual

returns the type of the map to use for the VectorEpetra

Implements Exporter< MeshType >.

Definition at line 608 of file ExporterVTK.hpp.

◆ whichCellType()

UInt whichCellType ( const feSpacePtr_Type _feSpacePtr)
private
Parameters
_feSpacePtra point to the FE space descriptor
Returns
the identifier of the VTK elementary cell

Definition at line 619 of file ExporterVTK.hpp.

+ Here is the caller graph for this function:

◆ composePVTUStream()

void composePVTUStream ( const exporterData_Type dvar,
std::stringstream &  pVTUStringStream 
)
private

This method fills a buffer for the *.pvtu file. We will have a PVTU file for each ExporterData object, basically listing the names of the VTU files containing the "partitioned" data.

Parameters
dvarthe ExporterData object
[out]pVTUStringStreamthe stringstream object (a file buffer)

Definition at line 1054 of file ExporterVTK.hpp.

◆ createPointsMaps()

void createPointsMaps ( const feSpacePtr_Type _feSpacePtr,
std::map< UInt, UInt > &  globalToLocalPointsMap,
std::map< UInt, UInt > &  localToGlobalPointsMap,
std::vector< Vector > &  coordinatesOfPoints 
)
private

This method creates the data structures needed by each processor to retrieve the point global IDs and coordinates.

Parameters
_feSpacePtra pointer to the FE Space descriptor
[out]globalToLocalPointsMapthe key of this map is the global ID of the point, the value is the position in the local data structure
[out]localToGlobalPointsMapthe key of this map is the position in the local data structure, the value is the global ID of the point
[out]coordinatesOfPointsa nDimensionsxnumPoints matrix, storing the nDimensions coordinates of the numPoints points

Definition at line 1153 of file ExporterVTK.hpp.

◆ composeVTKCollection()

void composeVTKCollection ( const std::string &  variableName,
std::stringstream &  vtkCollectionStringStream 
)
private

This method fills a buffer for the VTK collection (a *.pvd file).

Parameters
timethe current time
[out]vtkCollectionStringStreamthe stringstream object (a file buffer)

Definition at line 1237 of file ExporterVTK.hpp.

◆ composeVTUHeaderStream()

void composeVTUHeaderStream ( UInt  numPoints,
std::stringstream &  vtuHeaderStringStream 
)
private

This method fills a buffer for the header part of a *.vtu file.

Parameters
numPointswe need to specify the dimension of the data set written in the VTU file
[out]vtuHeaderStringStreamthe stringstream object (a file buffer)

Definition at line 1342 of file ExporterVTK.hpp.

◆ composeVTUFooterStream()

void composeVTUFooterStream ( std::stringstream &  vtuFooterStringStream)
private

This method fills a buffer for the footer part of a *.vtu file.

Parameters
[out]vtuHeaderStringStreamthe stringstream object (a file buffer)

Definition at line 1358 of file ExporterVTK.hpp.

◆ composeVTUGeoStream()

void composeVTUGeoStream ( const feSpacePtr_Type _feSpacePtr,
const std::map< UInt, UInt > &  globalToLocalPointsMap,
const std::vector< Vector > &  coordinatesOfPoints,
std::stringstream &  vtuGeoStringStream 
)
private

This method writes in a buffer (according to the VTK XML format) 1- the list of points' coordinates 2- the connectivity of the cells 3- the offsets of the connectivity list 4- the type of each cell

Parameters
_feSpacePtra pointer to the FE Space descriptor
globalToLocalPointsMapthe key of this map is the global ID of the point, the value is the position in the local data structure
coordinatesOfPointsa nDimensionsxnumPoints matrix, storing the nDimensions coordinates of the numPoints points

Definition at line 1268 of file ExporterVTK.hpp.

◆ composeTypeDataHeaderStream()

void composeTypeDataHeaderStream ( where_Type  where,
std::stringstream &  typeDataHeaderStringStream 
)
private

This method writes in a buffer (according to the VTK XML format) the header of the Data section of the file. This section may be named PointData or CellData, and to allow for several DataArrays to be grouped inside a single PointData or CellData environment, we need a separate method taking care of the header (footer)

Parameters
whereNode or Cell
typeDataHeaderStringStreamthe stringstream object (a file buffer)

Definition at line 1373 of file ExporterVTK.hpp.

◆ composeTypeDataFooterStream()

void composeTypeDataFooterStream ( where_Type  where,
std::stringstream &  typeDataFooterStringStream 
)
private
See also
composeTypeDataHeaderStream
Parameters
whereNode or Cell
typeDataHeaderStringStreamthe stringstream object (a file buffer)

Definition at line 1399 of file ExporterVTK.hpp.

◆ composeDataArrayStream() [1/2]

void composeDataArrayStream ( const exporterData_Type dvar,
const std::map< UInt, UInt > &  localToGlobalMap,
std::stringstream &  dataArraysStringStream 
)
private

This method writes in a buffer (according to the VTK XML format) the content of the Data section of the file.

Parameters
dvarthe ExporterData object
localToGlobalMapa map to query the dvar object for global IDs
dataArraysStringStreamthe stringstream object (a file buffer)

Definition at line 666 of file ExporterVTK.hpp.

◆ composeDataArrayStream() [2/2]

void composeDataArrayStream ( where_Type  where,
std::stringstream &  dataArraysStringStream 
)
private

Definition at line 981 of file ExporterVTK.hpp.

◆ readScalar()

virtual void readScalar ( ExporterData< mesh_Type > &  )
inlineprivatevirtual

The scalar reader (specialization of the parent class method)

Parameters
dvarthe ExporterData object

Definition at line 343 of file ExporterVTK.hpp.

◆ readVector()

virtual void readVector ( ExporterData< mesh_Type > &  )
inlineprivatevirtual

The vector reader (specialization of the parent class method)

Parameters
dvarthe ExporterData object

Definition at line 351 of file ExporterVTK.hpp.

◆ readVTUFiles()

void readVTUFiles ( exporterData_Type dvar)
private

The reader for VTU files.

Parameters
dvarthe ExporterData object

Definition at line 783 of file ExporterVTK.hpp.

◆ readBinaryData()

void readBinaryData ( const std::string &  line,
std::vector< Real > &  values,
const UInt numBits 
)
private

A routine for loading values stored in binary format in a VTU file.

Parameters
linea line read from file
valuesthe list of values extracted from the line
numBitsthe size of data to be read

Definition at line 890 of file ExporterVTK.hpp.

◆ readASCIIData()

void readASCIIData ( const std::string &  line,
std::vector< Real > &  values 
)
private

A routine for loading values stored in ASCII format in a VTU file.

Parameters
linea line read from file
valuesthe list of values extracted from the line

Definition at line 960 of file ExporterVTK.hpp.

Field Documentation

◆ MapType

MapEpetraType const MapType
static

returns the type of the map to use for the VectorEpetra

Definition at line 127 of file ExporterVTK.hpp.

◆ M_exportMode

EXPORT_MODE M_exportMode
private

Definition at line 377 of file ExporterVTK.hpp.

◆ M_floatPrecision

FLOAT_PRECISION M_floatPrecision
private

Definition at line 379 of file ExporterVTK.hpp.

◆ M_pvtuFiles

std::map< std::string, std::list<std::string> > M_pvtuFiles
private

Definition at line 381 of file ExporterVTK.hpp.


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