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

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>

Inheritance diagram for axom::mint::FieldVariable< T >:

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
 

Detailed Description

template<typename T>
class axom::mint::FieldVariable< T >

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.

    Warning
    All calls to shrink(), resize() and reserve() will fail if a FieldVariable object is constructed from an external buffer.
  • 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.

Template Parameters
Tthe type of field, e.g., double, int, etc.
See also
mint::Field
mint::FieldData
sidre::View

Constructor & Destructor Documentation

◆ FieldVariable() [1/3]

template<typename T >
axom::mint::FieldVariable< T >::FieldVariable ( )
delete

Default constructor. Disabled.

◆ FieldVariable() [2/3]

template<typename T >
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.

Parameters
[in]namethe name of this FieldVariable.
[in]num_tuplesthe number of tuples.
[in]num_componentsnum components per tuple (optional).
[in]capacitynumber of tuples to allocate space for (optional).
Note
num_components is set to 1 if not specified.
If capacity is not explicitly specified, an internal default is used instead.
Precondition
name.empty() == false
num_tuples >= 0
num_components >= 1

References axom::mint::Field::m_type, SLIC_ASSERT, SLIC_ERROR_IF, and axom::mint::UNDEFINED_FIELD_TYPE.

◆ FieldVariable() [3/3]

template<typename T >
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.

Parameters
[in]namethe name of this FieldVariable.
[in]datapointer to the external buffer.
[in]num_tuplesthe number of tuples to allocate.
[in]num_componentsthe number of components per tuple (optional).
Note
If num_components is set to 1 if not specified.
The supplied pointer must point to a buffer that is sufficiently allocated to hold \( num\_tuples \times num\_components \) items.
Warning
When constructing a FieldVariable instance from an external buffer, all calls to shrink(), resize() and reserve() will fail.
Precondition
name.empty() == false
num_tuples >= 0
num_components >= 1
data != nullptr

References axom::mint::Field::m_type, SLIC_ASSERT, SLIC_ERROR_IF, and axom::mint::UNDEFINED_FIELD_TYPE.

◆ ~FieldVariable()

template<typename T >
virtual axom::mint::FieldVariable< T >::~FieldVariable ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ getNumTuples()

template<typename T >
virtual IndexType axom::mint::FieldVariable< T >::getNumTuples ( ) const
inlinefinaloverridevirtual

Returns the number of tuples of this FieldVariable instance.

Returns
N the number of tuples of this FieldVariable.
Postcondition
N >= 0
See also
Field::getNumTuples()

Implements axom::mint::Field.

◆ getNumComponents()

template<typename T >
virtual IndexType axom::mint::FieldVariable< T >::getNumComponents ( ) const
inlinefinaloverridevirtual

Return the number of components per tuple.

Returns
N the number of components per tuple
Postcondition
N >= 1
See also
Field::getNumComponents()

Implements axom::mint::Field.

◆ getCapacity()

template<typename T >
virtual IndexType axom::mint::FieldVariable< T >::getCapacity ( ) const
inlinefinaloverridevirtual

Returns the total number of tuples this instance can hold.

Returns
N the capacity of this FieldVariable instance.
Postcondition
N >= this->getNumTuples()
See also
Field::getCapacity()

Implements axom::mint::Field.

◆ resize()

template<typename T >
virtual void axom::mint::FieldVariable< T >::resize ( IndexType  newNumTuples)
inlinefinaloverridevirtual

Resizes the Field such that it can store the given number of tuples.

Parameters
[in]newNumTuplesthe number of tuples of this Field instance.
Note
Reallocation is done only if the new size exceeds the capacity.
See also
Field::resize()

Implements axom::mint::Field.

◆ emplace()

template<typename T >
virtual void axom::mint::FieldVariable< T >::emplace ( IndexType  pos,
IndexType  num_tuples 
)
inlinefinaloverridevirtual

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.

Implements axom::mint::Field.

◆ reserve()

template<typename T >
virtual void axom::mint::FieldVariable< T >::reserve ( IndexType  newCapacity)
inlinefinaloverridevirtual

Increase the Field capacity to hold the given number of tuples.

Parameters
[in]newCapacitynumber of tuples to reserve memory for.
Note
if newCapacity < getCapacity() this method returns immediately.
See also
Field::reserve()

Implements axom::mint::Field.

◆ shrink()

template<typename T >
virtual void axom::mint::FieldVariable< T >::shrink ( )
inlinefinaloverridevirtual

Shrinks the field capacity to be equal to the number of tuples.

Postcondition
getCapacity()==getNumTuple()
See also
Field::shrink()

Implements axom::mint::Field.

◆ getResizeRatio()

template<typename T >
virtual double axom::mint::FieldVariable< T >::getResizeRatio ( ) const
inlinefinaloverridevirtual

Return the resize ratio of this field.

Implements axom::mint::Field.

◆ setResizeRatio()

template<typename T >
virtual void axom::mint::FieldVariable< T >::setResizeRatio ( double  ratio)
inlinefinaloverridevirtual

Set the resize ratio of this field.

Parameters
[in]ratiothe new resize ratio.
Postcondition
getResizeRatio() == ratio

Implements axom::mint::Field.

◆ isExternal()

template<typename T >
virtual bool axom::mint::FieldVariable< T >::isExternal ( ) const
inlinefinaloverridevirtual

Return true iff the field is stored in an external buffer.

Implements axom::mint::Field.

◆ isInSidre()

template<typename T >
virtual bool axom::mint::FieldVariable< T >::isInSidre ( ) const
inlinefinaloverridevirtual

Return true iff the field is stored in sidre.

Implements axom::mint::Field.

◆ getFieldVariablePtr() [1/2]

template<typename T >
T* axom::mint::FieldVariable< T >::getFieldVariablePtr ( )
inline

Returns pointer to the FieldVariable data.

Returns
ptr pointer to the data associated with this field variable.
Postcondition
ptr != nullptr

◆ getFieldVariablePtr() [2/2]

template<typename T >
const T* axom::mint::FieldVariable< T >::getFieldVariablePtr ( ) const
inline

◆ getType()

int axom::mint::Field::getType ( ) const
inlineinherited

Returns the type of the field.

Returns
t the type of the field.
Postcondition
t < NUMBER_OF_FIELD_TYPES
See also
FieldTypes

References axom::mint::Field::m_type.

◆ getName()

const std::string& axom::mint::Field::getName ( ) const
inlineinherited

Returns the name of the field.

Returns
name the name of the field.

References axom::mint::Field::m_name.

◆ getBasis()

int axom::mint::Field::getBasis ( ) const
inlineinherited

Returns the basis associated with this field.

Returns
basis the basis associated with this field.
Precondition
fe_basis >= 0 && fe_basis < MINT_NUM_BASIS_TYPES

References axom::mint::Field::m_basis.

◆ setBasis()

void axom::mint::Field::setBasis ( int  fe_basis)
inlineinherited

Sets the finite element basis associated with this field.

Parameters
[in]fe_basisthe finite element basis
Note
A field is not associated with basis type by default. The caller must explicitly associate a field with a basis by calling setBasis()
Precondition
fe_basis >= 0 && fe_basis < MINT_NUM_BASIS_TYPES
See also
FEBasisTypes for a list of supported basis.

References axom::mint::Field::m_basis, MINT_NUM_BASIS_TYPES, and SLIC_ASSERT.

◆ getDataPtr() [1/2]

template<typename T >
T * axom::mint::Field::getDataPtr ( Field field)
inlinestaticinherited

Returns raw pointer to the field data.

Returns
dataPtr pointer to the field data.
Template Parameters
Tthe field data type, e.g., double, int, etc.
Precondition
field_traits< T >::type() == field->getType()
Postcondition
dataPtr != nullptr

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.

◆ getDataPtr() [2/2]

template<typename T >
const T * axom::mint::Field::getDataPtr ( const Field field)
inlinestaticinherited

Member Data Documentation

◆ m_name

std::string axom::mint::Field::m_name
protectedinherited

the name of the field

◆ m_type

int axom::mint::Field::m_type
protectedinherited

the field type

◆ m_basis

int axom::mint::Field::m_basis
protectedinherited

associated finite element basis with the field.


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