MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
mfem::DataCollection Class Reference

#include <datacollection.hpp>

Inheritance diagram for mfem::DataCollection:
[legend]
Collaboration diagram for mfem::DataCollection:
[legend]

Public Types

enum  Format { SERIAL_FORMAT = 0 , PARALLEL_FORMAT = 1 }
 Format constants to be used with SetFormat(). More...
 
enum  { NO_ERROR = 0 , No_Error = 0 , READ_ERROR = 1 , WRITE_ERROR = 2 }
 Errors returned by Error() More...
 
typedef GFieldMap::MapType FieldMapType
 
typedef GFieldMap::iterator FieldMapIterator
 
typedef GFieldMap::const_iterator FieldMapConstIterator
 
typedef QFieldMap::MapType QFieldMapType
 
typedef QFieldMap::iterator QFieldMapIterator
 
typedef QFieldMap::const_iterator QFieldMapConstIterator
 

Public Member Functions

 DataCollection (const std::string &collection_name, Mesh *mesh_=NULL)
 Initialize the collection with its name and Mesh.
 
virtual void RegisterField (const std::string &field_name, GridFunction *gf)
 Add a grid function to the collection.
 
virtual void DeregisterField (const std::string &field_name)
 Remove a grid function from the collection.
 
virtual void RegisterQField (const std::string &q_field_name, QuadratureFunction *qf)
 Add a QuadratureFunction to the collection.
 
virtual void DeregisterQField (const std::string &field_name)
 Remove a QuadratureFunction from the collection.
 
bool HasField (const std::string &field_name) const
 Check if a grid function is part of the collection.
 
GridFunctionGetField (const std::string &field_name)
 Get a pointer to a grid function in the collection.
 
MPI_Comm GetComm () const
 Return the associated MPI communicator or MPI_COMM_NULL.
 
ParGridFunctionGetParField (const std::string &field_name)
 Get a pointer to a parallel grid function in the collection.
 
bool HasQField (const std::string &q_field_name) const
 Check if a QuadratureFunction with the given name is in the collection.
 
QuadratureFunctionGetQField (const std::string &q_field_name)
 Get a pointer to a QuadratureFunction in the collection.
 
const FieldMapTypeGetFieldMap () const
 Get a const reference to the internal field map.
 
const QFieldMapTypeGetQFieldMap () const
 Get a const reference to the internal q-field map.
 
MeshGetMesh ()
 Get a pointer to the mesh in the collection.
 
virtual void SetMesh (Mesh *new_mesh)
 Set/change the mesh associated with the collection.
 
virtual void SetMesh (MPI_Comm comm, Mesh *new_mesh)
 Set/change the mesh associated with the collection.
 
void SetCycle (int c)
 Set time cycle (for time-dependent simulations)
 
void SetTime (real_t t)
 Set physical time (for time-dependent simulations)
 
void SetTimeStep (real_t ts)
 Set the simulation time step (for time-dependent simulations)
 
int GetCycle () const
 Get time cycle (for time-dependent simulations)
 
real_t GetTime () const
 Get physical time (for time-dependent simulations)
 
real_t GetTimeStep () const
 Get the simulation time step (for time-dependent simulations)
 
const std::string & GetCollectionName () const
 Get the name of the collection.
 
void SetOwnData (bool o)
 Set the ownership of collection data.
 
void SetPrecision (int prec)
 Set the precision (number of digits) used for the text output of doubles.
 
virtual void SetPadDigits (int digits)
 Set the number of digits used for both the cycle and the MPI rank.
 
virtual void SetPadDigitsCycle (int digits)
 Set the number of digits used for the cycle.
 
virtual void SetPadDigitsRank (int digits)
 Set the number of digits used for the MPI rank in filenames.
 
virtual void SetFormat (int fmt)
 Set the desired output mesh and data format.
 
virtual void SetCompression (bool comp)
 Set the flag for use of gz compressed files.
 
void SetPrefixPath (const std::string &prefix)
 Set the path where the DataCollection will be saved.
 
const std::string & GetPrefixPath () const
 Get the path where the DataCollection will be saved.
 
virtual void Save ()
 Save the collection to disk.
 
virtual void SaveMesh ()
 Save the mesh, creating the collection directory.
 
virtual void SaveField (const std::string &field_name)
 Save one field, assuming the collection directory already exists.
 
virtual void SaveQField (const std::string &q_field_name)
 Save one q-field, assuming the collection directory already exists.
 
virtual void Load (int cycle_=0)
 Load the collection. Not implemented in the base class DataCollection.
 
virtual ~DataCollection ()
 Delete the mesh and fields if owned by the collection.
 
int Error () const
 Get the current error state.
 
void ResetError (int err_state=No_Error)
 Reset the error state.
 

Protected Member Functions

void DeleteData ()
 Delete data owned by the DataCollection keeping field information.
 
void DeleteAll ()
 Delete data owned by the DataCollection including field information.
 
std::string GetMeshShortFileName () const
 
std::string GetMeshFileName () const
 
std::string GetFieldFileName (const std::string &field_name) const
 
void SaveOneField (const FieldMapIterator &it)
 Save one field to disk, assuming the collection directory exists.
 
void SaveOneQField (const QFieldMapIterator &it)
 Save one q-field to disk, assuming the collection directory exists.
 

Static Protected Member Functions

static int create_directory (const std::string &dir_name, const Mesh *mesh, int myid)
 

Protected Attributes

std::string name
 Name of the collection, used as a directory name when saving.
 
std::string prefix_path
 A path where the directory with results is saved. If not empty, it has '/' at the end.
 
GFieldMap field_map
 
QFieldMap q_field_map
 
Meshmesh
 The (common) mesh for the collected fields.
 
int cycle
 Time cycle; for time-dependent simulations cycle >= 0, otherwise = -1.
 
real_t time
 Physical time (for time-dependent simulations)
 
real_t time_step
 Time step i.e. delta_t (for time-dependent simulations)
 
bool serial
 Serial or parallel run? False iff mesh is a ParMesh.
 
bool appendRankToFileName
 Append rank to any output file names.
 
int myid
 MPI rank (in parallel)
 
int num_procs
 Number of MPI ranks (in parallel)
 
MPI_Comm m_comm
 Associated MPI communicator.
 
int precision
 Precision (number of digits) used for the text output of doubles.
 
int pad_digits_cycle
 Number of digits used for the cycle and MPI rank in filenames.
 
int pad_digits_rank
 
int format
 Output mesh format: see the Format enumeration.
 
int compression
 
bool own_data
 Should the collection delete its mesh and fields.
 
int error
 Error state.
 

Static Protected Attributes

static const int precision_default = 6
 Default value for precision.
 
static const int pad_digits_default = 6
 Default value for pad_digits_*.
 

Friends

class ParMesh
 

Detailed Description

A class for collecting finite element data that is part of the same simulation. Currently, this class groups together grid functions (fields), quadrature functions (q-fields), and the mesh that they are defined on.

Definition at line 128 of file datacollection.hpp.

Member Typedef Documentation

◆ FieldMapConstIterator

◆ FieldMapIterator

◆ FieldMapType

◆ QFieldMapConstIterator

◆ QFieldMapIterator

◆ QFieldMapType

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Errors returned by Error()

Enumerator
NO_ERROR 
No_Error 
READ_ERROR 
WRITE_ERROR 

Definition at line 381 of file datacollection.hpp.

◆ Format

Format constants to be used with SetFormat().

Derived classes can define their own format enumerations and override the method SetFormat() to perform input validation.

Enumerator
SERIAL_FORMAT 

MFEM's serial ascii format, using the methods Mesh::Print() / ParMesh::Print(), and GridFunction::Save() / ParGridFunction::Save().

PARALLEL_FORMAT 

MFEM's parallel ascii format, using the methods ParMesh::ParPrint() and GridFunction::Save() / ParGridFunction::Save().

Definition at line 148 of file datacollection.hpp.

Constructor & Destructor Documentation

◆ DataCollection()

mfem::DataCollection::DataCollection ( const std::string & collection_name,
Mesh * mesh_ = NULL )
explicit

Initialize the collection with its name and Mesh.

When mesh_ is NULL, then the real mesh can be set with SetMesh().

Definition at line 75 of file datacollection.cpp.

◆ ~DataCollection()

mfem::DataCollection::~DataCollection ( )
virtual

Delete the mesh and fields if owned by the collection.

Definition at line 338 of file datacollection.cpp.

Member Function Documentation

◆ create_directory()

int mfem::DataCollection::create_directory ( const std::string & dir_name,
const Mesh * mesh,
int myid )
staticprotected

Definition at line 34 of file datacollection.cpp.

◆ DeleteAll()

void mfem::DataCollection::DeleteAll ( )
protected

Delete data owned by the DataCollection including field information.

Definition at line 331 of file datacollection.cpp.

◆ DeleteData()

void mfem::DataCollection::DeleteData ( )
protected

Delete data owned by the DataCollection keeping field information.

Definition at line 321 of file datacollection.cpp.

◆ DeregisterField()

virtual void mfem::DataCollection::DeregisterField ( const std::string & field_name)
inlinevirtual

Remove a grid function from the collection.

Reimplemented in mfem::SidreDataCollection.

Definition at line 248 of file datacollection.hpp.

◆ DeregisterQField()

virtual void mfem::DataCollection::DeregisterQField ( const std::string & field_name)
inlinevirtual

Remove a QuadratureFunction from the collection.

Definition at line 258 of file datacollection.hpp.

◆ Error()

int mfem::DataCollection::Error ( ) const
inline

Get the current error state.

Definition at line 396 of file datacollection.hpp.

◆ GetCollectionName()

const std::string & mfem::DataCollection::GetCollectionName ( ) const
inline

Get the name of the collection.

Definition at line 334 of file datacollection.hpp.

◆ GetComm()

MPI_Comm mfem::DataCollection::GetComm ( ) const
inline

Return the associated MPI communicator or MPI_COMM_NULL.

Definition at line 272 of file datacollection.hpp.

◆ GetCycle()

int mfem::DataCollection::GetCycle ( ) const
inline

Get time cycle (for time-dependent simulations)

Definition at line 327 of file datacollection.hpp.

◆ GetField()

GridFunction * mfem::DataCollection::GetField ( const std::string & field_name)
inline

Get a pointer to a grid function in the collection.

Returns NULL if field_name is not in the collection.

Definition at line 267 of file datacollection.hpp.

◆ GetFieldFileName()

std::string mfem::DataCollection::GetFieldFileName ( const std::string & field_name) const
protected

Definition at line 261 of file datacollection.cpp.

◆ GetFieldMap()

const FieldMapType & mfem::DataCollection::GetFieldMap ( ) const
inline

Get a const reference to the internal field map.

The keys in the map are the field names and the values are pointers to GridFunctions.

Definition at line 294 of file datacollection.hpp.

◆ GetMesh()

Mesh * mfem::DataCollection::GetMesh ( )
inline

Get a pointer to the mesh in the collection.

Definition at line 304 of file datacollection.hpp.

◆ GetMeshFileName()

std::string mfem::DataCollection::GetMeshFileName ( ) const
protected

Definition at line 256 of file datacollection.cpp.

◆ GetMeshShortFileName()

std::string mfem::DataCollection::GetMeshShortFileName ( ) const
protected

Definition at line 251 of file datacollection.cpp.

◆ GetParField()

ParGridFunction * mfem::DataCollection::GetParField ( const std::string & field_name)
inline

Get a pointer to a parallel grid function in the collection.

Returns NULL if field_name is not in the collection.

Note
The GridFunction pointer stored in the collection is statically cast to ParGridFunction pointer.

Definition at line 278 of file datacollection.hpp.

◆ GetPrefixPath()

const std::string & mfem::DataCollection::GetPrefixPath ( ) const
inline

Get the path where the DataCollection will be saved.

Definition at line 360 of file datacollection.hpp.

◆ GetQField()

QuadratureFunction * mfem::DataCollection::GetQField ( const std::string & q_field_name)
inline

Get a pointer to a QuadratureFunction in the collection.

Returns NULL if field_name is not in the collection.

Definition at line 288 of file datacollection.hpp.

◆ GetQFieldMap()

const QFieldMapType & mfem::DataCollection::GetQFieldMap ( ) const
inline

Get a const reference to the internal q-field map.

The keys in the map are the q-field names and the values are pointers to QuadratureFunctions.

Definition at line 300 of file datacollection.hpp.

◆ GetTime()

real_t mfem::DataCollection::GetTime ( ) const
inline

Get physical time (for time-dependent simulations)

Definition at line 329 of file datacollection.hpp.

◆ GetTimeStep()

real_t mfem::DataCollection::GetTimeStep ( ) const
inline

Get the simulation time step (for time-dependent simulations)

Definition at line 331 of file datacollection.hpp.

◆ HasField()

bool mfem::DataCollection::HasField ( const std::string & field_name) const
inline

Check if a grid function is part of the collection.

Definition at line 262 of file datacollection.hpp.

◆ HasQField()

bool mfem::DataCollection::HasQField ( const std::string & q_field_name) const
inline

Check if a QuadratureFunction with the given name is in the collection.

Definition at line 283 of file datacollection.hpp.

◆ Load()

void mfem::DataCollection::Load ( int cycle_ = 0)
virtual

Load the collection. Not implemented in the base class DataCollection.

Reimplemented in mfem::ConduitDataCollection, mfem::FMSDataCollection, mfem::ParaViewDataCollection, mfem::SidreDataCollection, and mfem::VisItDataCollection.

Definition at line 191 of file datacollection.cpp.

◆ RegisterField()

virtual void mfem::DataCollection::RegisterField ( const std::string & field_name,
GridFunction * gf )
inlinevirtual

Add a grid function to the collection.

Reimplemented in mfem::SidreDataCollection, and mfem::VisItDataCollection.

Definition at line 244 of file datacollection.hpp.

◆ RegisterQField()

virtual void mfem::DataCollection::RegisterQField ( const std::string & q_field_name,
QuadratureFunction * qf )
inlinevirtual

Add a QuadratureFunction to the collection.

Reimplemented in mfem::VisItDataCollection.

Definition at line 252 of file datacollection.hpp.

◆ ResetError()

void mfem::DataCollection::ResetError ( int err_state = No_Error)
inline

Reset the error state.

Definition at line 398 of file datacollection.hpp.

◆ Save()

void mfem::DataCollection::Save ( )
virtual

Save the collection to disk.

By default, everything is saved in the "prefix_path" directory with subdirectory name "collection_name" or "collection_name_cycle" for time-dependent simulations.

Reimplemented in mfem::ADIOS2DataCollection, mfem::ConduitDataCollection, mfem::FMSDataCollection, mfem::ParaViewDataCollection, mfem::SidreDataCollection, and mfem::VisItDataCollection.

Definition at line 196 of file datacollection.cpp.

◆ SaveField()

void mfem::DataCollection::SaveField ( const std::string & field_name)
virtual

Save one field, assuming the collection directory already exists.

Definition at line 303 of file datacollection.cpp.

◆ SaveMesh()

void mfem::DataCollection::SaveMesh ( )
virtual

Save the mesh, creating the collection directory.

Definition at line 215 of file datacollection.cpp.

◆ SaveOneField()

void mfem::DataCollection::SaveOneField ( const FieldMapIterator & it)
protected

Save one field to disk, assuming the collection directory exists.

Definition at line 277 of file datacollection.cpp.

◆ SaveOneQField()

void mfem::DataCollection::SaveOneQField ( const QFieldMapIterator & it)
protected

Save one q-field to disk, assuming the collection directory exists.

Definition at line 290 of file datacollection.cpp.

◆ SaveQField()

void mfem::DataCollection::SaveQField ( const std::string & q_field_name)
virtual

Save one q-field, assuming the collection directory already exists.

Definition at line 312 of file datacollection.cpp.

◆ SetCompression()

void mfem::DataCollection::SetCompression ( bool comp)
virtual

Set the flag for use of gz compressed files.

Reimplemented in mfem::ParaViewDataCollection.

Definition at line 167 of file datacollection.cpp.

◆ SetCycle()

void mfem::DataCollection::SetCycle ( int c)
inline

Set time cycle (for time-dependent simulations)

Definition at line 319 of file datacollection.hpp.

◆ SetFormat()

void mfem::DataCollection::SetFormat ( int fmt)
virtual

Set the desired output mesh and data format.

See the enumeration Format for valid options. Derived classes can define their own format enumerations and override this method to perform input validation.

Definition at line 154 of file datacollection.cpp.

◆ SetMesh() [1/2]

void mfem::DataCollection::SetMesh ( Mesh * new_mesh)
virtual

Set/change the mesh associated with the collection.

When passed a Mesh, assumes the serial case: MPI rank id is set to 0 and MPI num_procs is set to 1. When passed a ParMesh, MPI info from the ParMesh is used to set the DataCollection's MPI rank and num_procs.

Reimplemented in mfem::SidreDataCollection, and mfem::VisItDataCollection.

Definition at line 117 of file datacollection.cpp.

◆ SetMesh() [2/2]

void mfem::DataCollection::SetMesh ( MPI_Comm comm,
Mesh * new_mesh )
virtual

Set/change the mesh associated with the collection.

For this case, comm is used to set the DataCollection's MPI rank id and MPI num_procs, which influences the how files are saved for domain decomposed meshes.

Reimplemented in mfem::SidreDataCollection, and mfem::VisItDataCollection.

Definition at line 141 of file datacollection.cpp.

◆ SetOwnData()

void mfem::DataCollection::SetOwnData ( bool o)
inline

Set the ownership of collection data.

Definition at line 336 of file datacollection.hpp.

◆ SetPadDigits()

virtual void mfem::DataCollection::SetPadDigits ( int digits)
inlinevirtual

Set the number of digits used for both the cycle and the MPI rank.

Reimplemented in mfem::VisItDataCollection.

Definition at line 341 of file datacollection.hpp.

◆ SetPadDigitsCycle()

virtual void mfem::DataCollection::SetPadDigitsCycle ( int digits)
inlinevirtual

Set the number of digits used for the cycle.

Definition at line 344 of file datacollection.hpp.

◆ SetPadDigitsRank()

virtual void mfem::DataCollection::SetPadDigitsRank ( int digits)
inlinevirtual

Set the number of digits used for the MPI rank in filenames.

Definition at line 346 of file datacollection.hpp.

◆ SetPrecision()

void mfem::DataCollection::SetPrecision ( int prec)
inline

Set the precision (number of digits) used for the text output of doubles.

Definition at line 339 of file datacollection.hpp.

◆ SetPrefixPath()

void mfem::DataCollection::SetPrefixPath ( const std::string & prefix)

Set the path where the DataCollection will be saved.

Definition at line 175 of file datacollection.cpp.

◆ SetTime()

void mfem::DataCollection::SetTime ( real_t t)
inline

Set physical time (for time-dependent simulations)

Definition at line 321 of file datacollection.hpp.

◆ SetTimeStep()

void mfem::DataCollection::SetTimeStep ( real_t ts)
inline

Set the simulation time step (for time-dependent simulations)

Definition at line 324 of file datacollection.hpp.

Friends And Related Symbol Documentation

◆ ParMesh

friend class ParMesh
friend

Definition at line 401 of file datacollection.hpp.

Member Data Documentation

◆ appendRankToFileName

bool mfem::DataCollection::appendRankToFileName
protected

Append rank to any output file names.

Definition at line 187 of file datacollection.hpp.

◆ compression

int mfem::DataCollection::compression
protected

Definition at line 210 of file datacollection.hpp.

◆ cycle

int mfem::DataCollection::cycle
protected

Time cycle; for time-dependent simulations cycle >= 0, otherwise = -1.

When cycle >= 0, it is appended to directory names.

Definition at line 177 of file datacollection.hpp.

◆ error

int mfem::DataCollection::error
protected

Error state.

Definition at line 216 of file datacollection.hpp.

◆ field_map

GFieldMap mfem::DataCollection::field_map
protected

A FieldMap mapping registered field names to GridFunction pointers.

Definition at line 167 of file datacollection.hpp.

◆ format

int mfem::DataCollection::format
protected

Output mesh format: see the Format enumeration.

Definition at line 209 of file datacollection.hpp.

◆ m_comm

MPI_Comm mfem::DataCollection::m_comm
protected

Associated MPI communicator.

Definition at line 195 of file datacollection.hpp.

◆ mesh

Mesh* mfem::DataCollection::mesh
protected

The (common) mesh for the collected fields.

Definition at line 173 of file datacollection.hpp.

◆ myid

int mfem::DataCollection::myid
protected

MPI rank (in parallel)

Definition at line 190 of file datacollection.hpp.

◆ name

std::string mfem::DataCollection::name
protected

Name of the collection, used as a directory name when saving.

Definition at line 160 of file datacollection.hpp.

◆ num_procs

int mfem::DataCollection::num_procs
protected

Number of MPI ranks (in parallel)

Definition at line 192 of file datacollection.hpp.

◆ own_data

bool mfem::DataCollection::own_data
protected

Should the collection delete its mesh and fields.

Definition at line 213 of file datacollection.hpp.

◆ pad_digits_cycle

int mfem::DataCollection::pad_digits_cycle
protected

Number of digits used for the cycle and MPI rank in filenames.

Definition at line 201 of file datacollection.hpp.

◆ pad_digits_default

const int mfem::DataCollection::pad_digits_default = 6
staticprotected

Default value for pad_digits_*.

Definition at line 206 of file datacollection.hpp.

◆ pad_digits_rank

int mfem::DataCollection::pad_digits_rank
protected

Definition at line 201 of file datacollection.hpp.

◆ precision

int mfem::DataCollection::precision
protected

Precision (number of digits) used for the text output of doubles.

Definition at line 199 of file datacollection.hpp.

◆ precision_default

const int mfem::DataCollection::precision_default = 6
staticprotected

Default value for precision.

Definition at line 204 of file datacollection.hpp.

◆ prefix_path

std::string mfem::DataCollection::prefix_path
protected

A path where the directory with results is saved. If not empty, it has '/' at the end.

Definition at line 164 of file datacollection.hpp.

◆ q_field_map

QFieldMap mfem::DataCollection::q_field_map
protected

A FieldMap mapping registered names to QuadratureFunction pointers.

Definition at line 170 of file datacollection.hpp.

◆ serial

bool mfem::DataCollection::serial
protected

Serial or parallel run? False iff mesh is a ParMesh.

Definition at line 185 of file datacollection.hpp.

◆ time

real_t mfem::DataCollection::time
protected

Physical time (for time-dependent simulations)

Definition at line 179 of file datacollection.hpp.

◆ time_step

real_t mfem::DataCollection::time_step
protected

Time step i.e. delta_t (for time-dependent simulations)

Definition at line 182 of file datacollection.hpp.


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