AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
|
Provides the ability to store, access and modify a mesh field. More...
#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/latest/src/axom/mint/mesh/FieldVariable.hpp>
Public Member Functions | |
FieldVariable ()=delete | |
Default constructor. Disabled. More... | |
Native Storage Field Variable Constructor | |
FieldVariable (const std::string &name, IndexType num_tuples, IndexType num_components=1, IndexType capacity=USE_DEFAULT) | |
Creates a FieldVariable instance with the given name, size and number of components per tuple. More... | |
External Storage FieldVariable Constructors | |
FieldVariable (const std::string &name, T *data, IndexType num_tuples, IndexType num_components=1, IndexType capacity=USE_DEFAULT) | |
Creates a FieldVariable that points to a supplied external buffer. More... | |
Virtual Methods | |
virtual | ~FieldVariable () |
Destructor. More... | |
virtual IndexType | getNumTuples () const final override |
Returns the number of tuples of this FieldVariable instance. More... | |
virtual IndexType | getNumComponents () const final override |
Return the number of components per tuple. More... | |
virtual IndexType | getCapacity () const final override |
Returns the total number of tuples this instance can hold. More... | |
virtual void | resize (IndexType newNumTuples) final override |
Resizes the Field such that it can store the given number of tuples. More... | |
virtual void | emplace (IndexType pos, IndexType num_tuples) final override |
Inserts n_tuples with the default value at the given position. More... | |
virtual void | reserve (IndexType newCapacity) final override |
Increase the Field capacity to hold the given number of tuples. More... | |
virtual void | shrink () final override |
Shrinks the field capacity to be equal to the number of tuples. More... | |
virtual double | getResizeRatio () const final override |
Return the resize ratio of this field. More... | |
virtual void | setResizeRatio (double ratio) final override |
Set the resize ratio of this field. More... | |
virtual bool | isExternal () const final override |
Return true iff the field is stored in an external buffer. More... | |
virtual bool | isInSidre () const final override |
Return true iff the field is stored in sidre. More... | |
Data Access Methods | |
T * | getFieldVariablePtr () |
Returns pointer to the FieldVariable data. More... | |
const T * | getFieldVariablePtr () const |
Attribute get/set Methods | |
int | getType () const |
Returns the type of the field. More... | |
const std::string & | getName () const |
Returns the name of the field. More... | |
int | getBasis () const |
Returns the basis associated with this field. More... | |
void | setBasis (int fe_basis) |
Sets the finite element basis associated with this field. More... | |
Static Public Member Functions | |
Static Methods | |
template<typename T > | |
static T * | getDataPtr (Field *field) |
Returns raw pointer to the field data. More... | |
template<typename T > | |
static const T * | getDataPtr (const Field *field) |
Protected Attributes | |
std::string | m_name |
int | m_type |
int | m_basis |
Provides the ability to store, access and modify a mesh field.
FieldVariable is a concrete implementation of mint::Field. The FieldVariable class provides the ability to store, access and modify a field. Most often a field is associated with entities on a mesh. For example, temperature or velocity at the nodes of a mesh, or, pressure and mass evaluated at cell centers.
A FieldVariable may be used to represent a scalar quantity, a vector quantity or a tensor field. The number of tuples of the field corresponds to the number of corresponding mesh entities at which the field is evaluated, e.g., the number of nodes in the mesh for a node-centered field. The number of components of the FieldVariable may be used to indicate the number of components for a vector or tensor field. For example, a 3D velocity field may have \( 3 \) components for the \( x \), \( y \), and \( z \) velocity components. Similarly, a \( 3 \times 3 \) tensor field, may be stored using \( 9 \) components that correspond to the tensor components.
The FieldVariable class provides support for a variety of field types through the use of templates. A list of supported field types is given in FieldTypes.hpp
A FieldVariable object may be constructed using (a) native storage, (b) external storage, or, (c) from Sidre:
Native Storage
When using native storage, the FieldVariable object owns all associated memory. The storage can dynamically grow as needed, e.g., when doing refinement. When the object is deleted, all memory associated with the given instance is returned to the system.
External Storage
A FieldVariable may also be constructed by pointing it to an external, user-supplied buffer. In this case, the FieldVariable does not own the memory. Consequently, the FieldVariable cannot be resized, i.e., the number of tuples and number of components stays fixed for the life-time of the object.
Sidre
When Sidre is enabled, a FieldVariable may be constructed from a corresponding sidre::View. In this case, Sidre has ownership of the data, but, storage can dynamically grow as needed. All memory management operations are, therefore, delegated to Sidre.
When the FieldVariable object is deleted, the, associated data in the Sidre::View remains persistent in Sidre.
T | the type of field, e.g., double, int, etc. |
|
delete |
Default constructor. Disabled.
axom::mint::FieldVariable< T >::FieldVariable | ( | const std::string & | name, |
IndexType | num_tuples, | ||
IndexType | num_components = 1 , |
||
IndexType | capacity = USE_DEFAULT |
||
) |
Creates a FieldVariable instance with the given name, size and number of components per tuple.
[in] | name | the name of this FieldVariable. |
[in] | num_tuples | the number of tuples. |
[in] | num_components | num components per tuple (optional). |
[in] | capacity | number of tuples to allocate space for (optional). |
References axom::mint::Field::m_type, SLIC_ASSERT, SLIC_ERROR_IF, and axom::mint::UNDEFINED_FIELD_TYPE.
axom::mint::FieldVariable< T >::FieldVariable | ( | const std::string & | name, |
T * | data, | ||
IndexType | num_tuples, | ||
IndexType | num_components = 1 , |
||
IndexType | capacity = USE_DEFAULT |
||
) |
Creates a FieldVariable that points to a supplied external buffer.
[in] | name | the name of this FieldVariable. |
[in] | data | pointer to the external buffer. |
[in] | num_tuples | the number of tuples to allocate. |
[in] | num_components | the number of components per tuple (optional). |
References axom::mint::Field::m_type, SLIC_ASSERT, SLIC_ERROR_IF, and axom::mint::UNDEFINED_FIELD_TYPE.
|
inlinevirtual |
Destructor.
|
inlinefinaloverridevirtual |
Returns the number of tuples of this FieldVariable instance.
Implements axom::mint::Field.
|
inlinefinaloverridevirtual |
Return the number of components per tuple.
Implements axom::mint::Field.
|
inlinefinaloverridevirtual |
Returns the total number of tuples this instance can hold.
Implements axom::mint::Field.
|
inlinefinaloverridevirtual |
Resizes the Field such that it can store the given number of tuples.
[in] | newNumTuples | the number of tuples of this Field instance. |
Implements axom::mint::Field.
|
inlinefinaloverridevirtual |
Inserts n_tuples with the default value at the given position.
[in] | pos | the position of the insert. |
[in] | n_tuples | the number of tuples to insert. |
Implements axom::mint::Field.
|
inlinefinaloverridevirtual |
Increase the Field capacity to hold the given number of tuples.
[in] | newCapacity | number of tuples to reserve memory for. |
Implements axom::mint::Field.
|
inlinefinaloverridevirtual |
Shrinks the field capacity to be equal to the number of tuples.
Implements axom::mint::Field.
|
inlinefinaloverridevirtual |
Return the resize ratio of this field.
Implements axom::mint::Field.
|
inlinefinaloverridevirtual |
Set the resize ratio of this field.
[in] | ratio | the new resize ratio. |
Implements axom::mint::Field.
|
inlinefinaloverridevirtual |
Return true iff the field is stored in an external buffer.
Implements axom::mint::Field.
|
inlinefinaloverridevirtual |
Return true iff the field is stored in sidre.
Implements axom::mint::Field.
|
inline |
Returns pointer to the FieldVariable data.
|
inline |
|
inlineinherited |
Returns the type of the field.
References axom::mint::Field::m_type.
|
inlineinherited |
Returns the name of the field.
References axom::mint::Field::m_name.
|
inlineinherited |
Returns the basis associated with this field.
References axom::mint::Field::m_basis.
|
inlineinherited |
Sets the finite element basis associated with this field.
[in] | fe_basis | the finite element basis |
setBasis()
References axom::mint::Field::m_basis, MINT_NUM_BASIS_TYPES, and SLIC_ASSERT.
|
inlinestaticinherited |
Returns raw pointer to the field data.
T | the field data type, e.g., double, int, etc. |
References axom::mint::FieldVariable< T >::getFieldVariablePtr(), axom::mint::Field::getType(), SLIC_ASSERT, SLIC_ERROR_IF, axom::mint::field_traits< FieldType >::type(), and axom::mint::UNDEFINED_FIELD_TYPE.
|
inlinestaticinherited |
|
protectedinherited |
the name of the field
|
protectedinherited |
the field type
|
protectedinherited |
associated finite element basis with the field.