MFEM
v4.6.0
Finite element discretization library
|
Data collection with Sidre routines following the Conduit mesh blueprint specification. More...
#include <sidredatacollection.hpp>
Public Types | |
typedef NamedFieldsMap< Array< int > > | AttributeFieldMap |
Public Types inherited from mfem::DataCollection | |
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 | |
SidreDataCollection (const std::string &collection_name, Mesh *the_mesh=NULL, bool owns_mesh_data=false) | |
Constructor that allocates and initializes a Sidre DataStore. More... | |
SidreDataCollection (const std::string &collection_name, axom::sidre::Group *bp_index_grp, axom::sidre::Group *domain_grp, bool owns_mesh_data=false) | |
Constructor that links to an external Sidre DataStore. More... | |
void | SetComm (MPI_Comm comm) |
Associate an MPI communicator with the collection. More... | |
virtual void | RegisterField (const std::string &field_name, GridFunction *gf) |
Register a GridFunction in the Sidre DataStore. More... | |
void | RegisterField (const std::string &field_name, GridFunction *gf, const std::string &buffer_name, axom::sidre::IndexType offset) |
Register a GridFunction in the Sidre DataStore. More... | |
void | RegisterAttributeField (const std::string &name, bool is_bdry) |
Registers an attribute field in the Sidre DataStore. More... | |
void | DeregisterAttributeField (const std::string &name) |
Array< int > * | GetAttributeField (const std::string &field_name) const |
bool | HasAttributeField (const std::string &field_name) const |
bool | HasBoundaryMesh () const |
void | SetMeshNodesName (const std::string &nodes_name) |
Set the name of the mesh nodes field. More... | |
virtual void | DeregisterField (const std::string &field_name) |
De-register field_name from the SidreDataCollection. More... | |
virtual | ~SidreDataCollection () |
Delete all owned data. More... | |
virtual void | SetMesh (Mesh *new_mesh) |
Set/change the mesh associated with the collection. More... | |
virtual void | SetMesh (MPI_Comm comm, Mesh *new_mesh) |
Set/change the mesh associated with the collection. More... | |
void | SetGroupPointers (axom::sidre::Group *global_grp, axom::sidre::Group *domain_grp) |
Reset the domain and global datastore group pointers. More... | |
axom::sidre::Group * | GetBPGroup () |
axom::sidre::Group * | GetBPIndexGroup () |
virtual void | PrepareToSave () |
Prepare the DataStore for writing. More... | |
virtual void | Save () |
Save the collection to file. More... | |
void | Save (const std::string &filename, const std::string &protocol) |
Save the collection to filename. More... | |
void | Load (const std::string &path, const std::string &protocol) |
Load the Sidre DataStore from file. More... | |
virtual void | Load (int cycle_=0) |
Load SidreDataCollection from file. More... | |
void | LoadExternalData (const std::string &path) |
Load external data after registering externally owned fields. More... | |
void | UpdateStateFromDS () |
Updates the DataCollection's cycle, time, and time-step variables with the values from the data store. More... | |
void | UpdateStateToDS () |
Updates the data store's cycle, time, and time-step variables with the values from the SidreDataCollection. More... | |
Methods for named buffer access and manipulation. | |
axom::sidre::View * | GetNamedBuffer (const std::string &buffer_name) const |
Get a pointer to the sidre::View holding the named buffer for buffer_name. More... | |
axom::sidre::View * | AllocNamedBuffer (const std::string &buffer_name, axom::sidre::IndexType sz, axom::sidre::TypeID type=axom::sidre::DOUBLE_ID) |
Return newly allocated or existing named buffer for buffer_name. More... | |
void | FreeNamedBuffer (const std::string &buffer_name) |
Deallocate the named buffer buffer_name. More... | |
Public Member Functions inherited from mfem::DataCollection | |
DataCollection (const std::string &collection_name, Mesh *mesh_=NULL) | |
Initialize the collection with its name and Mesh. 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 &field_name) const |
Check if a grid function is part of the collection. More... | |
GridFunction * | GetField (const std::string &field_name) |
Get a pointer to a grid function in the collection. More... | |
MPI_Comm | GetComm () const |
Return the associated MPI communicator or MPI_COMM_NULL. More... | |
ParGridFunction * | GetParField (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... | |
QuadratureFunction * | GetQField (const std::string &q_field_name) |
Get a pointer to a QuadratureFunction in the collection. More... | |
const FieldMapType & | GetFieldMap () const |
Get a const reference to the internal field map. More... | |
const QFieldMapType & | GetQFieldMap () const |
Get a const reference to the internal q-field map. More... | |
Mesh * | GetMesh () |
Get a pointer to the mesh in 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... | |
virtual void | SetPadDigits (int digits) |
Set the number of digits used for both the cycle and the MPI rank. More... | |
virtual void | SetPadDigitsCycle (int digits) |
Set the number of digits used for the cycle. More... | |
virtual void | SetPadDigitsRank (int digits) |
Set the number of digits used for the MPI rank in filenames. More... | |
virtual void | SetFormat (int fmt) |
Set the desired output mesh and data format. More... | |
virtual void | SetCompression (bool comp) |
Set the flag for use of gz compressed files. 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 | 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 | ~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_state=No_Error) |
Reset the error state. More... | |
Public Attributes | |
AttributeFieldMap | attr_map |
Protected Member Functions | |
axom::sidre::Group * | named_buffers_grp () const |
axom::sidre::View * | alloc_view (axom::sidre::Group *grp, const std::string &view_name) |
axom::sidre::View * | alloc_view (axom::sidre::Group *grp, const std::string &view_name, const axom::sidre::DataType &dtype) |
axom::sidre::Group * | alloc_group (axom::sidre::Group *grp, const std::string &group_name) |
std::string | get_file_path (const std::string &filename) const |
Protected Member Functions inherited from mfem::DataCollection | |
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 | 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. More... | |
void | SaveOneQField (const QFieldMapIterator &it) |
Save one q-field to disk, assuming the collection directory exists. More... | |
Additional Inherited Members | |
Static Protected Member Functions inherited from mfem::DataCollection | |
static int | create_directory (const std::string &dir_name, const Mesh *mesh, int myid) |
Protected Attributes inherited from mfem::DataCollection | |
std::string | name |
Name of the collection, used as a directory name when saving. More... | |
std::string | prefix_path |
A path where the directory with results is saved. If not empty, it has '/' at the end. More... | |
GFieldMap | field_map |
QFieldMap | q_field_map |
Mesh * | mesh |
The (common) mesh for the collected fields. More... | |
int | cycle |
Time cycle; for time-dependent simulations cycle >= 0, otherwise = -1. More... | |
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? False iff mesh is a ParMesh. 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... | |
MPI_Comm | m_comm |
Associated MPI communicator. 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: see the Format enumeration. More... | |
int | compression |
bool | own_data |
Should the collection delete its mesh and fields. More... | |
int | error |
Error state. More... | |
Static Protected Attributes inherited from mfem::DataCollection | |
static const int | precision_default = 6 |
Default value for precision. More... | |
static const int | pad_digits_default = 6 |
Default value for pad_digits_*. More... | |
Data collection with Sidre routines following the Conduit mesh blueprint specification.
SidreDataCollection provides an HDF5-based file format for visualization or restart capability. This functionality is aimed primarily at customers of LLNL's axom project that run problems at extreme scales.
For more information, see:
The layout created in the Sidre DataStore is: ("──"
denote groups, "─•"
denote views, "─>"
denote links, i.e. shallow-copy view)
<root> ├── <collection-name>_global (global group) │ └── blueprint_index │ └── <collection-name> (bp_index group) │ ├── state │ │ ├─• cycle │ │ ├─• time │ │ └─• number_of_domains = <mesh-mpi-comm-size> │ ├── coordsets │ │ └── coords │ │ ├─• path = "<bp-path>/coordsets/coords" │ │ ├─• type ─> <bp-grp>/coordsets/coords/type = "explicit" │ │ └─• coord_system = "x"|"xy"|"xyz" │ ├── topologies │ │ ├── mesh │ │ │ ├─• path = "<bp-path>/topologies/mesh" │ │ │ ├─• type ─> <bp-grp>/topologies/mesh/type = "unstructured" │ │ │ ├─• coordset ─> <bp-grp>/topologies/mesh/coordset = "coords" │ │ │ ├─• grid_function ─> <bp-grp>/topologies/mesh/grid_function = "<nodes-field-name>" │ │ │ └─• boundary_topology ─> <bp-grp>/topologies/mesh/boundary_topology = "boundary" │ │ └── boundary │ │ ├─• path = "<bp-path>/topologies/mesh" │ │ ├─• type ─> <bp-grp>/topologies/boundary/type = "unstructured" │ │ └─• coordset ─> <bp-grp>/topologies/boundary/coordset = "coords" │ └── fields │ ├── mesh_material_attribute │ │ ├─• path = "<bp-path>/fields/mesh_material_attribute" │ │ ├─• association ─> <bp-grp>/fields/mesh_material_attribute/association = "element" │ │ ├─• topology ─> <bp-grp>/fields/mesh_material_attribute/topology = "mesh" │ │ └─• number_of_components = 1 │ ├── boundary_material_attribute │ │ ├─• path = "<bp-path>/fields/boundary_material_attribute" │ │ ├─• association ─> <bp-grp>/fields/boundary_material_attribute/association = "element" │ │ ├─• topology ─> <bp-grp>/fields/boundary_material_attribute/topology = "boundary" │ │ └─• number_of_components = 1 │ ├── grid-function-1 │ │ ├─• path = "<bp-path>/fields/grid-function-1" │ │ ├─• basis ─> <bp-grp>/fields/grid-function-1/basis = "<fe-coll-name>" │ │ ├─• topology ─> <bp-grp>/fields/grid-function-1/topology = "mesh" │ │ └─• number_of_components = gf1->VectorDim() │ ├── grid-function-2 │ │ ├─• path = "<bp-path>/fields/grid-function-2" │ │ ├─• basis ─> <bp-grp>/fields/grid-function-2/basis = "<fe-coll-name>" │ │ ├─• topology ─> <bp-grp>/fields/grid-function-2/topology = "mesh" │ │ └─• number_of_components = gf2->VectorDim() │ ├── ... │ ... └── <collection-name> (domain group) ├── blueprint (blueprint group) │ ├── state │ │ ├─• cycle │ │ ├─• time │ │ ├─• domain = <mesh-mpi-rank> │ │ └─• time_step │ ├── coordsets │ │ └── coords │ │ ├─• type = "explicit" │ │ └── values │ │ ├─• x = view in <vertex-coords-buffer>/<ext-double-data> │ │ ├─• y = view in <vertex-coords-buffer>/<ext-double-data> │ │ └─• z = view in <vertex-coords-buffer>/<ext-double-data> │ ├── topologies │ │ ├── mesh │ │ │ ├─• type = "unstructured" │ │ │ ├── elements │ │ │ │ ├─• shape = "points"|"lines"|... │ │ │ │ └─• connectivity = <vert-idx-array> │ │ │ ├─• coordset = "coords" │ │ │ ├─• grid_function = "<nodes-field-name>" │ │ │ └─• boundary_topology = "boundary" │ │ └── boundary │ │ ├─• type = "unstructured" │ │ ├── elements │ │ │ ├─• shape = "points"|"lines"|... │ │ │ └─• connectivity = <vert-idx-array> │ │ └─• coordset = "coords" │ └── fields │ ├── mesh_material_attribute │ │ ├─• association = "element" │ │ ├─• topology = "mesh" │ │ └─• values = <attr-array> │ ├── boundary_material_attribute │ │ ├─• association = "element" │ │ ├─• topology = "boundary" │ │ └─• values = <attr-array> │ ├── grid-function-1 (name can include path) │ │ ├─• basis = "<fe-coll-name>" │ │ ├─• topology = "mesh" │ │ └─• values = <ext-double-array>/<named-buffer> (vdim == 1) │ ├── grid-function-2 (name can include path) │ │ ├─• basis = "<fe-coll-name>" │ │ ├─• topology = "mesh" │ │ └── values (vdim > 1) │ │ ├─• x0 = view into <ext-double-array>/<named-buffer> │ │ ├─• x1 = view into <ext-double-array>/<named-buffer> │ │ └─• x2 = view into <ext-double-array>/<named-buffer> │ ├── ... │ ... └── named_buffers (named_buffers group) ├─• vertex_coords = <double-array> ├─• grid-function-1 = <double-array> ├─• grid-function-2 = <double-array> ...
Definition at line 172 of file sidredatacollection.hpp.
typedef NamedFieldsMap< Array<int> > mfem::SidreDataCollection::AttributeFieldMap |
Definition at line 175 of file sidredatacollection.hpp.
mfem::SidreDataCollection::SidreDataCollection | ( | const std::string & | collection_name, |
Mesh * | the_mesh = NULL , |
||
bool | owns_mesh_data = false |
||
) |
Constructor that allocates and initializes a Sidre DataStore.
[in] | collection_name | Name of the collection used as a file name when saving |
[in] | the_mesh | Mesh shared by all grid functions in the collection (can be NULL) |
[in] | owns_mesh_data | Does the SidreDC own the mesh vertices? |
With this constructor, the SidreDataCollection owns the allocated Sidre DataStore.
Definition at line 32 of file sidredatacollection.cpp.
mfem::SidreDataCollection::SidreDataCollection | ( | const std::string & | collection_name, |
axom::sidre::Group * | bp_index_grp, | ||
axom::sidre::Group * | domain_grp, | ||
bool | owns_mesh_data = false |
||
) |
Constructor that links to an external Sidre DataStore.
Specifically, the global and domain groups can be at arbitrary paths.
[in] | collection_name | Name of the collection used as a file name when saving |
[in] | bp_index_grp | Pointer to the blueprint index group in the datastore, see the above schematic |
[in] | domain_grp | Pointer to the domain group in the datastore, see the above schematic |
[in] | owns_mesh_data | Does the SidreDC own the mesh vertices? |
With this constructor, the SidreDataCollection does not own the Sidre DataStore.
Definition at line 70 of file sidredatacollection.cpp.
|
virtual |
Delete all owned data.
Definition at line 90 of file sidredatacollection.cpp.
|
protected |
Definition at line 166 of file sidredatacollection.cpp.
|
protected |
Definition at line 121 of file sidredatacollection.cpp.
|
protected |
Definition at line 143 of file sidredatacollection.cpp.
axom::sidre::View * mfem::SidreDataCollection::AllocNamedBuffer | ( | const std::string & | buffer_name, |
axom::sidre::IndexType | sz, | ||
axom::sidre::TypeID | type = axom::sidre::DOUBLE_ID |
||
) |
Return newly allocated or existing named buffer for buffer_name.
The buffer is stored in the named_buffers group. If the currently allocated buffer size is smaller than sz, then the buffer is reallocated with size sz, destroying its contents.
Definition at line 204 of file sidredatacollection.cpp.
void mfem::SidreDataCollection::DeregisterAttributeField | ( | const std::string & | name | ) |
Definition at line 1155 of file sidredatacollection.cpp.
|
virtual |
De-register field_name from the SidreDataCollection.
The field is removed from the field_map and the DataStore, including deleting it from the named_buffers group, if allocated.
Reimplemented from mfem::DataCollection.
Definition at line 1208 of file sidredatacollection.cpp.
|
inline |
Deallocate the named buffer buffer_name.
Definition at line 395 of file sidredatacollection.hpp.
|
protected |
Definition at line 187 of file sidredatacollection.cpp.
|
inline |
Returns a pointer to the attribute field associated with field_name, or NULL when there is no associated field
Definition at line 264 of file sidredatacollection.hpp.
|
inline |
Definition at line 314 of file sidredatacollection.hpp.
|
inline |
Definition at line 315 of file sidredatacollection.hpp.
|
inline |
Get a pointer to the sidre::View holding the named buffer for buffer_name.
If such named buffer is not allocated, the method returns NULL.
Definition at line 375 of file sidredatacollection.hpp.
|
inline |
Checks if there is an attribute field associated with field_name
Definition at line 268 of file sidredatacollection.hpp.
bool mfem::SidreDataCollection::HasBoundaryMesh | ( | ) | const |
Checks if any rank in the mesh has boundary elements
Definition at line 561 of file sidredatacollection.cpp.
void mfem::SidreDataCollection::Load | ( | const std::string & | path, |
const std::string & | protocol | ||
) |
Load the Sidre DataStore from file.
No mesh or fields are read from the loaded DataStore.
If the data collection created the datastore, it knows the layout of where the domain and global groups are, and can restore them after the Load().
If, however, the data collection does not own the datastore (e.g. it did not create the datastore), the host code must reset these pointers after the load operation, using SetGroupPointers(), and also reset the state variables, using UpdateStateFromDS().
Definition at line 698 of file sidredatacollection.cpp.
|
inlinevirtual |
Load SidreDataCollection from file.
The used file path is based on the current prefix path, collection name, and the given cycle_. The protocol is "sidre_hdf5".
Reimplemented from mfem::DataCollection.
Definition at line 348 of file sidredatacollection.hpp.
void mfem::SidreDataCollection::LoadExternalData | ( | const std::string & | path | ) |
Load external data after registering externally owned fields.
Definition at line 731 of file sidredatacollection.cpp.
|
protected |
Definition at line 111 of file sidredatacollection.cpp.
|
virtual |
Prepare the DataStore for writing.
Definition at line 766 of file sidredatacollection.cpp.
void mfem::SidreDataCollection::RegisterAttributeField | ( | const std::string & | name, |
bool | is_bdry | ||
) |
Registers an attribute field in the Sidre DataStore.
The registration process is similar to that of RegisterField() The attribute field is associated with the elements of the mesh when is_bdry is false, and with the boundary elements, when is_bdry is true.
Definition at line 1087 of file sidredatacollection.cpp.
|
inlinevirtual |
Register a GridFunction in the Sidre DataStore.
This method is a shortcut for the call RegisterField(field_name, gf, field_name, 0)
.
Reimplemented from mfem::DataCollection.
Definition at line 227 of file sidredatacollection.hpp.
void mfem::SidreDataCollection::RegisterField | ( | const std::string & | field_name, |
GridFunction * | gf, | ||
const std::string & | buffer_name, | ||
axom::sidre::IndexType | offset | ||
) |
Register a GridFunction in the Sidre DataStore.
The registration procedure is as follows:
Both the field_name and buffer_name can contain a path prefix.
Definition at line 1011 of file sidredatacollection.cpp.
|
virtual |
Save the collection to file.
This method calls Save(collection_name, "sidre_hdf5")
.
Reimplemented from mfem::DataCollection.
Definition at line 772 of file sidredatacollection.cpp.
void mfem::SidreDataCollection::Save | ( | const std::string & | filename, |
const std::string & | protocol | ||
) |
Save the collection to filename.
The collection path prefix is prepended to the filename and the current cycle is appended, if cycle >= 0.
Definition at line 780 of file sidredatacollection.cpp.
void mfem::SidreDataCollection::SetComm | ( | MPI_Comm | comm | ) |
Associate an MPI communicator with the collection.
If no mesh was associated with the collection, this method should be called before using any of the Load() methods to read parallel data.
Definition at line 100 of file sidredatacollection.cpp.
void mfem::SidreDataCollection::SetGroupPointers | ( | axom::sidre::Group * | global_grp, |
axom::sidre::Group * | domain_grp | ||
) |
Reset the domain and global datastore group pointers.
These are set in the constructor, but if a host code changes the datastore contents ( such as wiping out the datastore and loading in new contents from a file, i.e. a restart ) these pointers will need to be reset to valid groups in the datastore.
Definition at line 687 of file sidredatacollection.cpp.
|
virtual |
Set/change the mesh associated with the collection.
Uses the field name "mesh_nodes" or the value set by SetMeshNodesName() to register the mesh nodes GridFunction, if the mesh uses nodes.
Reimplemented from mfem::DataCollection.
Definition at line 582 of file sidredatacollection.cpp.
|
virtual |
Set/change the mesh associated with the collection.
Uses the field name "mesh_nodes" or the value set by SetMeshNodesName() to register the mesh nodes GridFunction, if the mesh uses nodes.
Reimplemented from mfem::DataCollection.
Definition at line 675 of file sidredatacollection.cpp.
|
inline |
Set the name of the mesh nodes field.
This name will be used by SetMesh() to register the mesh nodes, if not already registered. Also, this method should be called if the mesh nodes GridFunction was or will be registered directly by the user. The default value for the name is "mesh_nodes".
Definition at line 279 of file sidredatacollection.hpp.
void mfem::SidreDataCollection::UpdateStateFromDS | ( | ) |
Updates the DataCollection's cycle, time, and time-step variables with the values from the data store.
Definition at line 746 of file sidredatacollection.cpp.
void mfem::SidreDataCollection::UpdateStateToDS | ( | ) |
Updates the data store's cycle, time, and time-step variables with the values from the SidreDataCollection.
Definition at line 753 of file sidredatacollection.cpp.
AttributeFieldMap mfem::SidreDataCollection::attr_map |
Definition at line 176 of file sidredatacollection.hpp.