MFEM  v3.3.2
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
mfem::DataCollection Class Reference

#include <datacollection.hpp>

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

Public Types

enum  { NO_ERROR = 0, READ_ERROR = 1, WRITE_ERROR = 2 }
 Errors returned by Error() More...
 
typedef std::map< std::string,
GridFunction * > 
FieldMapType
 
typedef std::map< std::string,
QuadratureFunction * > 
QFieldMapType
 

Public Member Functions

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

Protected Types

typedef FieldMapType::iterator FieldMapIterator
 The fields and their names (used when saving) More...
 
typedef
FieldMapType::const_iterator 
FieldMapConstIterator
 
typedef QFieldMapType::iterator QFieldMapIterator
 
typedef
QFieldMapType::const_iterator 
QFieldMapConstIterator
 

Protected Member Functions

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

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. More...
 
std::string prefix_path
 
FieldMapType field_map
 
QFieldMapType q_field_map
 
Meshmesh
 The (common) mesh for the collected fields. More...
 
int cycle
 
double time
 Physical time (for time-dependent simulations) More...
 
double time_step
 Time step i.e. delta_t (for time-dependent simulations) More...
 
bool serial
 Serial or parallel run? More...
 
bool appendRankToFileName
 Append rank to any output file names. More...
 
int myid
 MPI rank (in parallel) More...
 
int num_procs
 Number of MPI ranks (in parallel) More...
 
int precision
 Precision (number of digits) used for the text output of doubles. More...
 
int pad_digits_cycle
 Number of digits used for the cycle and MPI rank in filenames. More...
 
int pad_digits_rank
 
int format
 Output mesh format: 0 - serial format (default), 1 - parallel format. More...
 
bool own_data
 Should the collection delete its mesh and fields. More...
 
int error
 Error state. More...
 

Static Protected Attributes

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

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 29 of file datacollection.hpp.

Member Typedef Documentation

typedef FieldMapType::const_iterator mfem::DataCollection::FieldMapConstIterator
protected

Definition at line 45 of file datacollection.hpp.

typedef FieldMapType::iterator mfem::DataCollection::FieldMapIterator
protected

The fields and their names (used when saving)

Definition at line 44 of file datacollection.hpp.

typedef std::map<std::string, GridFunction*> mfem::DataCollection::FieldMapType

Definition at line 32 of file datacollection.hpp.

typedef QFieldMapType::const_iterator mfem::DataCollection::QFieldMapConstIterator
protected

Definition at line 51 of file datacollection.hpp.

typedef QFieldMapType::iterator mfem::DataCollection::QFieldMapIterator
protected

Definition at line 50 of file datacollection.hpp.

Definition at line 33 of file datacollection.hpp.

Member Enumeration Documentation

anonymous enum

Errors returned by Error()

Enumerator
NO_ERROR 
READ_ERROR 
WRITE_ERROR 

Definition at line 226 of file datacollection.hpp.

Constructor & Destructor Documentation

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

Initialize the collection with its name and Mesh.

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

Definition at line 72 of file datacollection.cpp.

mfem::DataCollection::~DataCollection ( )
virtual

Delete the mesh and fields if owned by the collection.

Definition at line 350 of file datacollection.cpp.

Member Function Documentation

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

Definition at line 31 of file datacollection.cpp.

void mfem::DataCollection::DeleteAll ( )
protected

Delete data owned by the DataCollection including field information.

Definition at line 343 of file datacollection.cpp.

void mfem::DataCollection::DeleteData ( )
protected

Delete data owned by the DataCollection keeping field information.

Definition at line 324 of file datacollection.cpp.

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

Remove a grid function from the collection.

Reimplemented in mfem::SidreDataCollection.

Definition at line 133 of file datacollection.cpp.

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

Remove a QuadratureFunction from the collection.

Definition at line 157 of file datacollection.cpp.

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

Get the current error state.

Definition at line 229 of file datacollection.hpp.

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

Get the name of the collection.

Definition at line 186 of file datacollection.hpp.

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

Get time cycle (for time-dependent simulations)

Definition at line 179 of file datacollection.hpp.

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

Get a pointer to a grid function in the collection.

Returns NULL if field_name is not in the collection.

Definition at line 170 of file datacollection.cpp.

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

Definition at line 267 of file datacollection.cpp.

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 158 of file datacollection.hpp.

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

Get a pointer to the mesh in the collection.

Definition at line 166 of file datacollection.hpp.

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 143 of file datacollection.hpp.

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

Get the path where the DataCollection will be saved.

Definition at line 206 of file datacollection.hpp.

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

Get a pointer to a QuadratureFunction in the collection.

Returns NULL if field_name is not in the collection.

Definition at line 177 of file datacollection.cpp.

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 163 of file datacollection.hpp.

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

Get physical time (for time-dependent simulations)

Definition at line 181 of file datacollection.hpp.

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

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

Definition at line 183 of file datacollection.hpp.

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

Check if a grid function is part of the collection.

Definition at line 131 of file datacollection.hpp.

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 148 of file datacollection.hpp.

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

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

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

Definition at line 200 of file datacollection.cpp.

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

Add a grid function to the collection.

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

Definition at line 123 of file datacollection.cpp.

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

Add a QuadratureFunction to the collection.

Definition at line 146 of file datacollection.cpp.

void mfem::DataCollection::ResetError ( int  err = NO_ERROR)
inline

Reset the error state.

Definition at line 231 of file datacollection.hpp.

void mfem::DataCollection::Save ( )
virtual

Save the collection to disk. By default, everything is saved in a directory with name "collection_name" or "collection_name_cycle" for time-dependent simulations.

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

Definition at line 205 of file datacollection.cpp.

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

Save one field, assuming the collection directory already exists.

Definition at line 306 of file datacollection.cpp.

void mfem::DataCollection::SaveMesh ( )
virtual

Save the mesh, creating the collection directory.

Definition at line 224 of file datacollection.cpp.

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

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

Definition at line 282 of file datacollection.cpp.

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

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

Definition at line 294 of file datacollection.cpp.

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

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

Definition at line 315 of file datacollection.cpp.

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

Set time cycle (for time-dependent simulations)

Definition at line 171 of file datacollection.hpp.

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

Set the desired output mesh format: 0 - serial format (default), 1 - parallel format.

Definition at line 200 of file datacollection.hpp.

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

Set/change the mesh associated with the collection.

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

Definition at line 102 of file datacollection.cpp.

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

Set the ownership of collection data.

Definition at line 188 of file datacollection.hpp.

void mfem::DataCollection::SetPadDigits ( int  digits)
inline

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

Definition at line 193 of file datacollection.hpp.

void mfem::DataCollection::SetPadDigitsCycle ( int  digits)
inline

Set the number of digits used for the cycle.

Definition at line 195 of file datacollection.hpp.

void mfem::DataCollection::SetPadDigitsRank ( int  digits)
inline

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

Definition at line 197 of file datacollection.hpp.

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

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

Definition at line 191 of file datacollection.hpp.

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

Set the path where the DataCollection will be saved.

Definition at line 184 of file datacollection.cpp.

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

Set physical time (for time-dependent simulations)

Definition at line 173 of file datacollection.hpp.

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

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

Definition at line 176 of file datacollection.hpp.

Member Data Documentation

bool mfem::DataCollection::appendRankToFileName
protected

Append rank to any output file names.

Definition at line 69 of file datacollection.hpp.

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 59 of file datacollection.hpp.

int mfem::DataCollection::error
protected

Error state.

Definition at line 93 of file datacollection.hpp.

FieldMapType mfem::DataCollection::field_map
protected

An std::map containing the registered fields' names as keys (std::string) and their GridFunction pointers as values.

Definition at line 48 of file datacollection.hpp.

int mfem::DataCollection::format
protected

Output mesh format: 0 - serial format (default), 1 - parallel format.

Definition at line 87 of file datacollection.hpp.

Mesh* mfem::DataCollection::mesh
protected

The (common) mesh for the collected fields.

Definition at line 55 of file datacollection.hpp.

int mfem::DataCollection::myid
protected

MPI rank (in parallel)

Definition at line 72 of file datacollection.hpp.

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

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

Definition at line 37 of file datacollection.hpp.

int mfem::DataCollection::num_procs
protected

Number of MPI ranks (in parallel)

Definition at line 74 of file datacollection.hpp.

bool mfem::DataCollection::own_data
protected

Should the collection delete its mesh and fields.

Definition at line 90 of file datacollection.hpp.

int mfem::DataCollection::pad_digits_cycle
protected

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

Definition at line 79 of file datacollection.hpp.

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

Default value for pad_digits_*.

Definition at line 84 of file datacollection.hpp.

int mfem::DataCollection::pad_digits_rank
protected

Definition at line 79 of file datacollection.hpp.

int mfem::DataCollection::precision
protected

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

Definition at line 77 of file datacollection.hpp.

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

Default value for precision.

Definition at line 82 of file datacollection.hpp.

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 41 of file datacollection.hpp.

QFieldMapType mfem::DataCollection::q_field_map
protected

Definition at line 52 of file datacollection.hpp.

bool mfem::DataCollection::serial
protected

Serial or parallel run?

Definition at line 67 of file datacollection.hpp.

double mfem::DataCollection::time
protected

Physical time (for time-dependent simulations)

Definition at line 61 of file datacollection.hpp.

double mfem::DataCollection::time_step
protected

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

Definition at line 64 of file datacollection.hpp.


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