AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
axom::mint::FieldData Class Reference

Provides a container for storing fields associated with a specified mesh topology and methods to create, access and remove fields from the container. More...

#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/latest/src/axom/mint/mesh/FieldData.hpp>

Public Member Functions

 ~FieldData ()
 Destructor. More...
 
Constructors
 FieldData ()=delete
 Default constructor. Disabled. More...
 
 FieldData (int association)
 Creates an empty FieldData instance with the specified mesh topology association. More...
 
Attribute get/set Methods
int getAssociation () const
 Returns the mesh topology association of fields in this container. More...
 
bool empty () const
 Checks if this FieldData instance is empty. More...
 
int getNumFields () const
 Returns the number of fields of this FieldData instance. More...
 
bool hasField (const std::string &name) const
 Checks if the field with the given name exists. More...
 
bool hasSidreGroup () const
 Checks if a Sidre Group is associated with this FieldData instance. More...
 
double getResizeRatio () const
 Return the resize ratio of this FieldData. More...
 
Methods acting on a single field
template<typename T >
T * createField (const std::string &name, IndexType num_tuples, IndexType num_components=1, IndexType capacity=USE_DEFAULT, bool storeInSidre=true)
 Creates a new field with the given name consisting of the specified number of tuples and number of components. More...
 
template<typename T >
T * createField (const std::string &name, T *data, IndexType num_tuples, IndexType num_components=1, IndexType capacity=USE_DEFAULT)
 Creates a new field which will use the supplied external buffer as storage, consisting of the specified number of tuples and components. More...
 
void removeField (const std::string &name)
 Removes the field with the given name. More...
 
void removeField (int i)
 Removes the ith field from the container. More...
 
FieldgetField (int i)
 Returns the ith field of this FieldData instance. More...
 
const FieldgetField (int i) const
 
FieldgetField (const std::string &name)
 Returns the field with the given name. More...
 
const FieldgetField (const std::string &name) const
 
template<typename T >
T * getFieldPtr (const std::string &name)
 Returns pointer to the buffer of the field with the given name. More...
 
template<typename T >
T * getFieldPtr (const std::string &name, IndexType &num_tuples)
 
template<typename T >
T * getFieldPtr (const std::string &name, IndexType &num_tuples, IndexType &num_components)
 
template<typename T >
const T * getFieldPtr (const std::string &name) const
 Returns const pointer to the buffer of the field with the given name. More...
 
template<typename T >
const T * getFieldPtr (const std::string &name, IndexType &num_tuples) const
 
template<typename T >
const T * getFieldPtr (const std::string &name, IndexType &num_tuples, IndexType &num_components) const
 
Methods acting on all fields
void resize (IndexType newNumTuples)
 Changes the num-tuples of all fields in this FieldData instance. More...
 
void emplace (IndexType pos, IndexType n_tuples)
 Inserts n_tuples with the default value at the given position. More...
 
void reserve (IndexType newCapacity)
 Changes the tuple capacity of all fields in this FieldData instance. More...
 
void shrink ()
 Shrinks the tuple capacity of all fields in this FieldData instance to be equal to the actual number of tuples in the field. More...
 
void setResizeRatio (double ratio)
 Set the resize ratio of this FieldData and all associated Fields. More...
 
bool checkConsistency (IndexType num_tuples, IndexType capacity) const
 

Detailed Description

Provides a container for storing fields associated with a specified mesh topology and methods to create, access and remove fields from the container.

A FieldData object may store fields associated with a single mesh topology, e.g., node-, cell- , face- or edge-centered. The FieldData object provides the means to create, access, modify and remove fields from the container.

Each field in the container is a FieldVariable instance which may store scalar, vector, tensor fields etc. as explained in more detail in the FieldVariable documentation.

When Mint is compiled with Sidre support, the FieldData object can be bound to a particular sidre::Group to store fields in a Sidre hierarchy according to the mesh blueprint .

Note
When using Sidre as the back-end storage, the action of creating or removing fields from the FieldData object is reflected in the associated Sidre hierarchy by default.
See also
Field
FieldVariable

Constructor & Destructor Documentation

◆ FieldData() [1/2]

axom::mint::FieldData::FieldData ( )
delete

Default constructor. Disabled.

◆ FieldData() [2/2]

axom::mint::FieldData::FieldData ( int  association)
explicit

Creates an empty FieldData instance with the specified mesh topology association.

Parameters
[in]associationthe mesh topology association, e.g., NODE_CENTERED
Note
The FieldAssociation enum provides a convenient way to specify values for the association parameter used in this constructor.
Warning
ANY_CENTERING, albeit defined in the FieldAssociation enum, it is used as wild-card and is not a valid value for this constructor.
Precondition
association >= NODE_CENTERED && association < NUM_FIELD_ASSOCIATIONS
Postcondition
this->getAssociation() == association
this->empty() == true
this->hasSidreGroup() == false
this->getNumFields() == 0

◆ ~FieldData()

axom::mint::FieldData::~FieldData ( )
inline

Destructor.

Member Function Documentation

◆ getAssociation()

int axom::mint::FieldData::getAssociation ( ) const
inline

Returns the mesh topology association of fields in this container.

Returns
association the field association.
See also
FieldAssociation.hpp

◆ empty()

bool axom::mint::FieldData::empty ( ) const
inline

Checks if this FieldData instance is empty.

Returns
status true if empty, else, false.

◆ getNumFields()

int axom::mint::FieldData::getNumFields ( ) const
inline

Returns the number of fields of this FieldData instance.

Returns
N the number of fields in this instance.
Postcondition
N == 0 \iff this->empty() == true.

◆ hasField()

bool axom::mint::FieldData::hasField ( const std::string &  name) const
inline

Checks if the field with the given name exists.

Parameters
[in]namethe name of the field to check.
Returns
status true if the field exists, else, false.

◆ hasSidreGroup()

bool axom::mint::FieldData::hasSidreGroup ( ) const
inline

Checks if a Sidre Group is associated with this FieldData instance.

Returns
status true if the FieldData is associated with Sidre, else, false.

◆ getResizeRatio()

double axom::mint::FieldData::getResizeRatio ( ) const
inline

Return the resize ratio of this FieldData.

◆ createField() [1/2]

template<typename T >
T * axom::mint::FieldData::createField ( const std::string &  name,
IndexType  num_tuples,
IndexType  num_components = 1,
IndexType  capacity = USE_DEFAULT,
bool  storeInSidre = true 
)
inline

Creates a new field with the given name consisting of the specified number of tuples and number of components.

Parameters
[in]namethe user-supplied name to identify this field.
[in]num_tuplesthe number of tuples in the field.
[in]num_componentsnumber of components per tuple (optional)
[in]capacityinitial max capacity for the field (optional).
[in]storeInSidreindicates whether to store the field in the associated Sidre group of this FieldData instance (optional).
Template Parameters
Tthe underlying data type of the field, e.g., double, int, etc.
Note
num_components is an optional argument. It defaults to '1' if a value is not explicitly specified by the caller.
The 'storeInSidre' boolean argument that indicates whether the field data should be stored in Sidre. This is an optional argument which defaults to true and is only relevant when the code is compiled with Sidre support and the FieldData instance is associated with a Sidre Group. For persistent data, e.g., state variables etc., Sidre should own the data. However, for temporary variables it may be desirable to not modify the Sidre hierarchy.
Returns
ptr pointer to the buffer associated with this field.
Precondition
hasField( name ) == false
num_components >= 1
Postcondition
ptr != nullptr

References axom::sidre::Group::createGroup(), axom::sidre::Group::createView(), hasField(), hasSidreGroup(), axom::mint::Field::setResizeRatio(), axom::sidre::View::setString(), SLIC_ASSERT, and SLIC_ERROR_IF.

◆ createField() [2/2]

template<typename T >
T * axom::mint::FieldData::createField ( const std::string &  name,
T *  data,
IndexType  num_tuples,
IndexType  num_components = 1,
IndexType  capacity = USE_DEFAULT 
)
inline

Creates a new field which will use the supplied external buffer as storage, consisting of the specified number of tuples and components.

Parameters
[in]namethe user-supplied name of this field
[in]datasupplied external buffer
[in]num_tuplesthe number of tuples in the field.
[in]num_componentsthe numbere of components per tuple (optional).
[in]capacitymax capacity for the field (optional). If not specified the capacity defaults to num_tuples.
Template Parameters
Tthe underlying data type of the field, e.g., double, int, etc.
Note
num_components is an optional argument. It defaults to '1' if a value is not explicitly specified by the caller.
The supplied pointer must point to a buffer that is able to hold at least \( num\_tuples \times num\_components \)
An external field is not inserted in the Sidre tree hierarchy.
Once an external field is created, subsequent calls to the FieldData methods to "resize()" and "reserve()" will fail.
Returns
ptr pointer to the buffer associated with this field.
Precondition
hasField( name ) == false
data != nullptr
Postcondition
ptr != nullptr
ptr == data

References hasField(), and SLIC_ERROR_IF.

◆ removeField() [1/2]

void axom::mint::FieldData::removeField ( const std::string &  name)

Removes the field with the given name.

Parameters
[in]namethe name of the field to remove.
Precondition
name.empty() == false
hasField( name ) == true

◆ removeField() [2/2]

void axom::mint::FieldData::removeField ( int  i)

Removes the ith field from the container.

Parameters
[in]ithe index of the field to remove from the container
Precondition
i >= 0 && i < getNumFields()

◆ getField() [1/4]

Field* axom::mint::FieldData::getField ( int  i)
inline

Returns the ith field of this FieldData instance.

Parameters
[in]ithe index of the field in query.
Returns
f pointer to the field in query.
Precondition
i >= 0 && i < this->getNumFields()
Postcondition
f == nullptr \iff i < 0 || i >= this->getNumberOfFieds()

References getField().

◆ getField() [2/4]

const Field* axom::mint::FieldData::getField ( int  i) const
inline

References SLIC_ASSERT.

◆ getField() [3/4]

Field* axom::mint::FieldData::getField ( const std::string &  name)
inline

Returns the field with the given name.

Parameters
[in]namethe name of the field in query.
Returns
f pointer to the field in query.
Postcondition
f == nullptr \iff this->hasField( name )==false.

References getField().

◆ getField() [4/4]

const Field* axom::mint::FieldData::getField ( const std::string &  name) const
inline

References SLIC_ASSERT.

◆ getFieldPtr() [1/6]

template<typename T >
T * axom::mint::FieldData::getFieldPtr ( const std::string &  name)
inline

Returns pointer to the buffer of the field with the given name.

Parameters
[in]namethe name of the field in query.
[out]num_tuplesthe number of tuples in the field (optional)
[out]num_componentsthe number of components per tuple (optional).
Returns
ptr pointer to the buffer of the specified field.
Precondition
hasField( name ) == true
Postcondition
ptr != nullptr

◆ getFieldPtr() [2/6]

template<typename T >
T * axom::mint::FieldData::getFieldPtr ( const std::string &  name,
IndexType num_tuples 
)
inline

◆ getFieldPtr() [3/6]

template<typename T >
T * axom::mint::FieldData::getFieldPtr ( const std::string &  name,
IndexType num_tuples,
IndexType num_components 
)
inline

References getFieldPtr().

◆ getFieldPtr() [4/6]

template<typename T >
const T * axom::mint::FieldData::getFieldPtr ( const std::string &  name) const
inline

Returns const pointer to the buffer of the field with the given name.

Parameters
[in]namethe name of the field in query.
[out]num_tuplesthe number of tuples in the field (optional)
[out]num_componentsthe number of components per tuple (optional)
Returns
ptr pointer to the buffer of the specified field.
Precondition
hasField( name ) == true.
Postcondition
ptr != nullptr

◆ getFieldPtr() [5/6]

template<typename T >
const T * axom::mint::FieldData::getFieldPtr ( const std::string &  name,
IndexType num_tuples 
) const
inline

◆ getFieldPtr() [6/6]

template<typename T >
const T * axom::mint::FieldData::getFieldPtr ( const std::string &  name,
IndexType num_tuples,
IndexType num_components 
) const
inline

◆ resize()

void axom::mint::FieldData::resize ( IndexType  newNumTuples)

Changes the num-tuples of all fields in this FieldData instance.

Parameters
[in]newNumTuplesthe new number of tuples.
Warning
If the FieldData instance contains a FieldVariable that cannot be re-sized, e.g., it points to an external buffer, this method will abort with an error.
See also
FieldVariable

◆ emplace()

void axom::mint::FieldData::emplace ( IndexType  pos,
IndexType  n_tuples 
)

Inserts n_tuples with the default value at the given position.

Parameters
[in]posthe position of the insert.
[in]n_tuplesthe number of tuples to insert.
Note
The values at pos and above are shifted up and the new tuples have the default values.
See also
FieldVariable

◆ reserve()

void axom::mint::FieldData::reserve ( IndexType  newCapacity)

Changes the tuple capacity of all fields in this FieldData instance.

Parameters
[in]newCapacitythe new max tuple capacity.
Warning
If the FieldData instance contains a FieldVariable that cannot be re-sized, e.g., it points to an external buffer, this method will abort with an error.
See also
FieldVariable

◆ shrink()

void axom::mint::FieldData::shrink ( )

Shrinks the tuple capacity of all fields in this FieldData instance to be equal to the actual number of tuples in the field.

See also
FieldVariable

◆ setResizeRatio()

void axom::mint::FieldData::setResizeRatio ( double  ratio)

Set the resize ratio of this FieldData and all associated Fields.

◆ checkConsistency()

bool axom::mint::FieldData::checkConsistency ( IndexType  num_tuples,
IndexType  capacity 
) const

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