MFEM  v3.1
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Types | Public Member Functions | 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...
 

Public Member Functions

 DataCollection (const char *collection_name, Mesh *_mesh)
 Initialize the collection with its name and Mesh. More...
 
virtual void RegisterField (const char *field_name, GridFunction *gf)
 Add a grid function to the collection. More...
 
GridFunctionGetField (const char *field_name)
 
bool HasField (const char *name)
 Check if a grid function is part of the collection. 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...
 
int GetCycle ()
 Get time cycle (for time-dependent simulations) More...
 
double GetTime ()
 Get physical time (for time-dependent simulations) More...
 
const char * GetCollectionName ()
 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 the cycle and MPI rank in filenames. More...
 
virtual void Save ()
 
virtual void SaveMesh ()
 Save the mesh, creating the collection directory. More...
 
virtual void SaveField (const char *field_name)
 Save one field, assuming the collection directory already exists. 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 Member Functions

 DataCollection (const char *collection_name)
 Create an empty collection with the given name. More...
 
void DeleteData ()
 Delete data owned by the DataCollection keeping field information. More...
 
void DeleteAll ()
 Delete data owned by the DataCollection including field information. More...
 
void SaveOneField (const std::map< std::string, GridFunction * >::iterator &it)
 Save one field to disk, assuming the collection directory exists. More...
 

Protected Attributes

std::string name
 Name of the collection, used as a directory name when saving. More...
 
std::map< std::string,
GridFunction * > 
field_map
 The fields and their names (used when saving) More...
 
Meshmesh
 The (common) mesh for the collected fields. More...
 
int cycle
 
double time
 Physical time (for time-dependent simulations) More...
 
bool serial
 Serial or parallel run? If false, append rank (myid) to 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
 Number of digits used for the cycle and MPI rank in filenames. 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 several grid functions (fields) and the mesh that they are defined on.

Definition at line 26 of file datacollection.hpp.

Member Enumeration Documentation

anonymous enum

Errors returned by Error()

Enumerator
NO_ERROR 
READ_ERROR 
WRITE_ERROR 

Definition at line 125 of file datacollection.hpp.

Constructor & Destructor Documentation

mfem::DataCollection::DataCollection ( const char *  collection_name)
protected

Create an empty collection with the given name.

Definition at line 58 of file datacollection.cpp.

mfem::DataCollection::DataCollection ( const char *  collection_name,
Mesh _mesh 
)

Initialize the collection with its name and Mesh.

Definition at line 73 of file datacollection.cpp.

mfem::DataCollection::~DataCollection ( )
virtual

Delete the mesh and fields if owned by the collection.

Definition at line 272 of file datacollection.cpp.

Member Function Documentation

void mfem::DataCollection::DeleteAll ( )
protected

Delete data owned by the DataCollection including field information.

Definition at line 266 of file datacollection.cpp.

void mfem::DataCollection::DeleteData ( )
protected

Delete data owned by the DataCollection keeping field information.

Definition at line 247 of file datacollection.cpp.

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

Get the current error state.

Definition at line 128 of file datacollection.hpp.

const char* mfem::DataCollection::GetCollectionName ( )
inline

Get the name of the collection.

Definition at line 103 of file datacollection.hpp.

int mfem::DataCollection::GetCycle ( )
inline

Get time cycle (for time-dependent simulations)

Definition at line 99 of file datacollection.hpp.

GridFunction * mfem::DataCollection::GetField ( const char *  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 124 of file datacollection.cpp.

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

Get a pointer to the mesh in the collection.

Definition at line 89 of file datacollection.hpp.

double mfem::DataCollection::GetTime ( )
inline

Get physical time (for time-dependent simulations)

Definition at line 101 of file datacollection.hpp.

bool mfem::DataCollection::HasField ( const char *  name)
inline

Check if a grid function is part of the collection.

Definition at line 86 of file datacollection.hpp.

void mfem::DataCollection::RegisterField ( const char *  field_name,
GridFunction gf 
)
virtual

Add a grid function to the collection.

Reimplemented in mfem::VisItDataCollection.

Definition at line 115 of file datacollection.cpp.

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

Reset the error state.

Definition at line 130 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.

Definition at line 136 of file datacollection.cpp.

void mfem::DataCollection::SaveField ( const char *  field_name)
virtual

Save one field, assuming the collection directory already exists.

Definition at line 238 of file datacollection.cpp.

void mfem::DataCollection::SaveMesh ( )
virtual

Save the mesh, creating the collection directory.

Definition at line 149 of file datacollection.cpp.

void mfem::DataCollection::SaveOneField ( const std::map< std::string, GridFunction * >::iterator &  it)
protected

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

Definition at line 207 of file datacollection.cpp.

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

Set time cycle (for time-dependent simulations)

Definition at line 94 of file datacollection.hpp.

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

Set/change the mesh associated with the collection.

Reimplemented in mfem::VisItDataCollection.

Definition at line 97 of file datacollection.cpp.

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

Set the ownership of collection data.

Definition at line 105 of file datacollection.hpp.

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

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

Definition at line 110 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 108 of file datacollection.hpp.

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

Set physical time (for time-dependent simulations)

Definition at line 96 of file datacollection.hpp.

Member Data Documentation

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

int mfem::DataCollection::error
protected

Error state.

Definition at line 64 of file datacollection.hpp.

std::map<std::string, GridFunction*> mfem::DataCollection::field_map
protected

The fields and their names (used when saving)

Definition at line 33 of file datacollection.hpp.

Mesh* mfem::DataCollection::mesh
protected

The (common) mesh for the collected fields.

Definition at line 35 of file datacollection.hpp.

int mfem::DataCollection::myid
protected

MPI rank (in parallel)

Definition at line 46 of file datacollection.hpp.

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

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

Definition at line 30 of file datacollection.hpp.

int mfem::DataCollection::num_procs
protected

Number of MPI ranks (in parallel)

Definition at line 48 of file datacollection.hpp.

bool mfem::DataCollection::own_data
protected

Should the collection delete its mesh and fields.

Definition at line 61 of file datacollection.hpp.

int mfem::DataCollection::pad_digits
protected

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

Definition at line 53 of file datacollection.hpp.

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

Default value for pad_digits.

Definition at line 58 of file datacollection.hpp.

int mfem::DataCollection::precision
protected

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

Definition at line 51 of file datacollection.hpp.

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

Default value for precision.

Definition at line 56 of file datacollection.hpp.

bool mfem::DataCollection::serial
protected

Serial or parallel run? If false, append rank (myid) to file names.

Definition at line 44 of file datacollection.hpp.

double mfem::DataCollection::time
protected

Physical time (for time-dependent simulations)

Definition at line 41 of file datacollection.hpp.


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