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

Provides an interface for general mesh connectivity. More...

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

Public Member Functions

 ConnectivityArray ()=delete
 Default constructor. Disabled. More...
 
void append (const IndexType *values, IndexType AXOM_UNUSED_PARAM(n_values)=0, CellType AXOM_UNUSED_PARAM(type)=UNDEFINED_CELL)
 Appends an ID. More...
 
void appendM (const IndexType *values, IndexType n_IDs, const IndexType *AXOM_UNUSED_PARAM(offsets)=nullptr, const CellType *AXOM_UNUSED_PARAM(types)=nullptr)
 Adds multiple IDs. More...
 
void set (const IndexType *values, IndexType ID)
 Sets the values of the given ID. More...
 
void setM (const IndexType *values, IndexType start_ID, IndexType n_IDs)
 Sets the values of multiple IDs starting with the given ID. More...
 
void insert (const IndexType *values, IndexType start_ID, IndexType AXOM_UNUSED_PARAM(n_values)=0, CellType AXOM_UNUSED_PARAM(type)=UNDEFINED_CELL)
 Insert the values of a new ID before the given ID. More...
 
void insertM (const IndexType *values, IndexType start_ID, IndexType n_IDs, const IndexType *AXOM_UNUSED_PARAM(offsets)=nullptr, const CellType *AXOM_UNUSED_PARAM(types)=nullptr)
 Insert the values of multiple IDs before the given ID. More...
 
Native Storage ConnectivityArray Constructors
 ConnectivityArray (CellType cell_type, IndexType ID_capacity=USE_DEFAULT)
 Constructs an empty ConnectivityArray instance. More...
 
 ConnectivityArray (IndexType stride, IndexType ID_capacity=USE_DEFAULT)
 Constructs an empty ConnectivityArray instance. More...
 
External Storage ConnectivityArray Constructors
 ConnectivityArray (CellType cell_type, IndexType n_IDs, IndexType *values, IndexType ID_capacity=USE_DEFAULT)
 External constructor which creates a ConnectivityArray instance to wrap the given pointer. More...
 
 ConnectivityArray (IndexType stride, IndexType n_IDs, IndexType *values, IndexType ID_capacity=USE_DEFAULT)
 External constructor which creates a ConnectivityArray instance to wrap the given pointer. More...
 
Attribute get/set Methods
IndexType getNumberOfIDs () const
 Returns the total number of IDs. More...
 
IndexType getIDCapacity () const
 Returns the number of IDs available for storage without resizing. More...
 
IndexType getNumberOfValues () const
 Returns the number of values in this ConnectivityArray instance. More...
 
IndexType getValueCapacity () const
 Returns the number of values available for storage without resizing. More...
 
void reserve (IndexType ID_capacity, IndexType AXOM_UNUSED_PARAM(value_capacity)=0)
 Reserve space for IDs and values. More...
 
void resize (IndexType ID_size, IndexType AXOM_UNUSED_PARAM(value_size)=0)
 Resize space to hold the specified number of IDs. More...
 
void shrink ()
 Shrink the array so that there is no extra capacity. More...
 
double getResizeRatio () const
 Get the resize ratio. More...
 
void setResizeRatio (double ratio)
 Set the resize ratio. More...
 
bool hasVariableValuesPerID () const
 Checks if this CellConnecitivity instance has a variable number of values per ID. More...
 
bool empty () const
 Return true if this ConnectivityArray instance is empty. More...
 
bool isExternal () const
 Return true iff constructed via the external constructor. More...
 
bool isInSidre () const
 Return true iff constructed via the sidre constructors. More...
 
Data Access Methods
IndexType getNumberOfValuesForID (IndexType AXOM_UNUSED_PARAM(ID)=0) const
 Returns the number of values for the given ID. More...
 
CellType getIDType (IndexType AXOM_UNUSED_PARAM(ID)=0) const
 Returns the cell type of the given ID. More...
 
IndexTypeoperator[] (IndexType ID)
 Access operator for the values of the given ID. More...
 
const IndexTypeoperator[] (IndexType ID) const
 
IndexTypegetValuePtr ()
 Returns a pointer to the values array, of length getNumberOfValues(). More...
 
const IndexTypegetValuePtr () const
 
IndexTypegetOffsetPtr ()
 Returns a pointer to the offsets array. Since this version of the ConnectivityArray does not have an offsets array this function returns a null pointer. More...
 
const IndexTypegetOffsetPtr () const
 
CellTypegetTypePtr ()
 Returns a pointer to the types array. Since this version of the ConnectivityArray does not have a types array this function returns a null pointer. More...
 
const CellTypegetTypePtr () const
 

Detailed Description

template<ConnectivityType TYPE>
class axom::mint::ConnectivityArray< TYPE >

Provides an interface for general mesh connectivity.

The ConnectivityArray is a map between IDs and values where each ID can be a different type and have a different number of values. A ConnectivityArray with N IDs has IDs from [0, N-1] whereas the values for each ID can be anything within the range of IndexType.

The ConnectivityArray object may be constructed using (a) native storage, (b) external storage, or, (c) Sidre:

  • Native Storage

    When using native storage, the ConnectivityArray object owns all associated memory. The storage can dynamically grow as needed, e.g. when adding more IDs. Typically, extra space is allocated to minimize the number of re-allocations. At any given instance, the total ID/value capacity can be queried by calling the getIDCapacity()/getValueCapacity() functions. The extra memory can be returned to the system by calling the shrink() method.

    When all extra memory is exhausted, appending a new ID triggers a re-allocation. The amount of extra space that is allocated is according to the resize_ratio parameter, which is set to 2.0 by default. The resize_ratio may be queried and set to a different value by the getResizeRatio() and setResizeRatio() functions respectively.

    When the ConnectivityArray object goes out-of-scope, all memory associated with the given instance is returned to the system.

  • External Storage

    A ConnectivityArray object may also be constructed from external, user-supplied buffers that store the various arrays. In this case, the memory is owned by the caller. The ConnectivityArray object just keeps pointers to the user-supplied buffers.

    Warning
    Since the memory is not owned by the ConnectivityArray object when external buffers are supplied, the ConnectivityArray object cannot dynamically grow the storage. Consequently, the number of IDs/values the ConnectivityArray instance can hold is fixed. All calls to shrink() and reserve() will fail.
    Moreover, when the ConnectivityArray object goes out-of-scope, the associated buffers are not deleted. The caller owns the external data and has the responsibility of properly de-allocating the associated memory.
  • Sidre

    A ConnectivityArray object may also be constructed from a sidre::Group which conforms to a topology of the mesh blueprint .

    A ConnectivityArray object that is bound to a particular sidre::Group supports all operations transparently including dynamically growing the storage to hold more nodes as needed, but instead Sidre owns the memory. All memory management operations are delegated to Sidre.

    Warning
    Once the ConnectivityArray object goes out-of-scope, the data remains persistent in Sidre.
    Reallocations tend to be costly operations in terms of performance. Use reserveIDs()/reserveValues() when the number of IDs/values is known a priori, or opt to use a constructor that takes a size and capacity when possible.

    In this non-specialized ConnectivityArray it is assumed that each ID is of the same type and has the same number of values. Template specializations deal with the case where the number of values per ID differ but the type remains the same and the case where both differ.

Template Parameters
TYPEthe type of the ConnectivityArray this class deals with the case of TYPE == NO_INDIRECTION.
See also
ConnectivityArray_typed_indirection.hpp
ConnectivityArray_internal.hpp

Constructor & Destructor Documentation

◆ ConnectivityArray() [1/5]

template<ConnectivityType TYPE>
axom::mint::ConnectivityArray< TYPE >::ConnectivityArray ( )
delete

Default constructor. Disabled.

◆ ConnectivityArray() [2/5]

template<ConnectivityType TYPE>
axom::mint::ConnectivityArray< TYPE >::ConnectivityArray ( CellType  cell_type,
IndexType  ID_capacity = USE_DEFAULT 
)
inline

Constructs an empty ConnectivityArray instance.

Parameters
[in]cell_typethe cell type associated with the IDs.
[in]ID_capacitythe number of IDs to allocate space for.
Precondition
cell_type != UNDEFINED_CELL && cell_type < NUM_CELL_TYPES
Postcondition
getIDCapacity() >= getNumberOfIDs()
getNumberOfIDs() == 0
getIDType() == cell_type

References axom::mint::cellTypeToInt(), axom::mint::getCellInfo(), axom::mint::Native, axom::mint::NUM_CELL_TYPES, axom::mint::CellInfo::num_nodes, SLIC_ERROR_IF, and axom::mint::UNDEFINED_CELL.

◆ ConnectivityArray() [3/5]

template<ConnectivityType TYPE>
axom::mint::ConnectivityArray< TYPE >::ConnectivityArray ( IndexType  stride,
IndexType  ID_capacity = USE_DEFAULT 
)
inline

Constructs an empty ConnectivityArray instance.

Parameters
[in]stridethe number of values associated with each ID.
[in]ID_capacitythe number of IDs to allocate space for.
Postcondition
getIDCapacity() >= getNumberOfIDs()
getNumberOfIDs() == 0
getIDType() == UNDEFINED_CELL

References axom::mint::Native, and SLIC_ERROR_IF.

◆ ConnectivityArray() [4/5]

template<ConnectivityType TYPE>
axom::mint::ConnectivityArray< TYPE >::ConnectivityArray ( CellType  cell_type,
IndexType  n_IDs,
IndexType values,
IndexType  ID_capacity = USE_DEFAULT 
)
inline

External constructor which creates a ConnectivityArray instance to wrap the given pointer.

Parameters
[in]cell_typethe cell type associated with the IDs.
[in]n_IDsthe number of IDs.
[in]valuesthe array of values of length at least ID_capacity * getCellInfo( cell_type ).num_nodes.
[in]ID_capacitythe capacity of the values array in terms of IDs. If not specified the capacity is set to n_IDs.
Precondition
cell_type != UNDEFINED_CELL && cell_type < NUM_CELL_TYPES
n_IDs >= 0
values != nullptr
Postcondition
getIDCapacity() >= getNumberOfIDs()
getNumberOfIDs() == n_IDs
getIDType() == cell_type

References axom::mint::cellTypeToInt(), axom::mint::External, axom::mint::getCellInfo(), axom::mint::NUM_CELL_TYPES, axom::mint::CellInfo::num_nodes, SLIC_ERROR_IF, and axom::mint::UNDEFINED_CELL.

◆ ConnectivityArray() [5/5]

template<ConnectivityType TYPE>
axom::mint::ConnectivityArray< TYPE >::ConnectivityArray ( IndexType  stride,
IndexType  n_IDs,
IndexType values,
IndexType  ID_capacity = USE_DEFAULT 
)
inline

External constructor which creates a ConnectivityArray instance to wrap the given pointer.

Parameters
[in]stridethe number of values associated with each ID.
[in]n_IDsthe number of IDs.
[in]valuesthe array of values of length at least ID_capacity * getCellInfo( cell_type ).num_nodes.
[in]ID_capacitythe capacity of the values array in terms of IDs. If not specified the capacity is set to n_IDs.
Precondition
cell_type != UNDEFINED_CELL && cell_type < NUM_CELL_TYPES
n_IDs >= 0
values != nullptr
Postcondition
getIDCapacity() >= getNumberOfIDs()
getNumberOfIDs() == n_IDs
getIDType() == cell_type

References axom::mint::External.

Member Function Documentation

◆ getNumberOfIDs()

template<ConnectivityType TYPE>
IndexType axom::mint::ConnectivityArray< TYPE >::getNumberOfIDs ( ) const
inline

Returns the total number of IDs.

◆ getIDCapacity()

template<ConnectivityType TYPE>
IndexType axom::mint::ConnectivityArray< TYPE >::getIDCapacity ( ) const
inline

Returns the number of IDs available for storage without resizing.

◆ getNumberOfValues()

template<ConnectivityType TYPE>
IndexType axom::mint::ConnectivityArray< TYPE >::getNumberOfValues ( ) const
inline

Returns the number of values in this ConnectivityArray instance.

◆ getValueCapacity()

template<ConnectivityType TYPE>
IndexType axom::mint::ConnectivityArray< TYPE >::getValueCapacity ( ) const
inline

Returns the number of values available for storage without resizing.

References axom::mint::ConnectivityArray< TYPE >::getIDCapacity().

◆ reserve()

template<ConnectivityType TYPE>
void axom::mint::ConnectivityArray< TYPE >::reserve ( IndexType  ID_capacity,
IndexType   AXOM_UNUSED_PARAMvalue_capacity = 0 
)
inline

Reserve space for IDs and values.

Parameters
[in]ID_capacitythe number of IDs to reserve space for.
[in]value_capacitynot used, does not need to be specified.

If current getIDCapacity() >= ID_capacity, do nothing.

Postcondition
getIDCapacity() >= ID_capacity

References axom::mint::ConnectivityArray< TYPE >::isExternal(), and SLIC_ERROR_IF.

◆ resize()

template<ConnectivityType TYPE>
void axom::mint::ConnectivityArray< TYPE >::resize ( IndexType  ID_size,
IndexType   AXOM_UNUSED_PARAMvalue_size = 0 
)
inline

Resize space to hold the specified number of IDs.

Parameters
[in]ID_sizethe number of IDs to resize the space for.
[in]value_sizenot used, does not need to be specified.
Postcondition
getNumberOfIDs() == newIDSize

◆ shrink()

template<ConnectivityType TYPE>
void axom::mint::ConnectivityArray< TYPE >::shrink ( )
inline

Shrink the array so that there is no extra capacity.

Postcondition
getIDCapacity() == getNumberOfIDs()

◆ getResizeRatio()

template<ConnectivityType TYPE>
double axom::mint::ConnectivityArray< TYPE >::getResizeRatio ( ) const
inline

Get the resize ratio.

◆ setResizeRatio()

template<ConnectivityType TYPE>
void axom::mint::ConnectivityArray< TYPE >::setResizeRatio ( double  ratio)
inline

Set the resize ratio.

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

◆ hasVariableValuesPerID()

template<ConnectivityType TYPE>
bool axom::mint::ConnectivityArray< TYPE >::hasVariableValuesPerID ( ) const
inline

Checks if this CellConnecitivity instance has a variable number of values per ID.

Returns
false.

◆ empty()

template<ConnectivityType TYPE>
bool axom::mint::ConnectivityArray< TYPE >::empty ( ) const
inline

Return true if this ConnectivityArray instance is empty.

◆ isExternal()

template<ConnectivityType TYPE>
bool axom::mint::ConnectivityArray< TYPE >::isExternal ( ) const
inline

Return true iff constructed via the external constructor.

References axom::mint::External.

◆ isInSidre()

template<ConnectivityType TYPE>
bool axom::mint::ConnectivityArray< TYPE >::isInSidre ( ) const
inline

Return true iff constructed via the sidre constructors.

References axom::mint::Sidre.

◆ getNumberOfValuesForID()

template<ConnectivityType TYPE>
IndexType axom::mint::ConnectivityArray< TYPE >::getNumberOfValuesForID ( IndexType   AXOM_UNUSED_PARAMID = 0) const
inline

Returns the number of values for the given ID.

Parameters
[in]IDnot used, does not need to be specified.

◆ getIDType()

template<ConnectivityType TYPE>
CellType axom::mint::ConnectivityArray< TYPE >::getIDType ( IndexType   AXOM_UNUSED_PARAMID = 0) const
inline

Returns the cell type of the given ID.

Parameters
[in]IDnot used, does not need to be specified.

◆ operator[]() [1/2]

template<ConnectivityType TYPE>
IndexType* axom::mint::ConnectivityArray< TYPE >::operator[] ( IndexType  ID)
inline

Access operator for the values of the given ID.

Parameters
[in]IDthe ID in question.
Returns
pointer to the values of the given ID, of length at least getNumberOfValuesForID().
Precondition
ID >= 0 && ID < getNumberOfIDs()
Postcondition
cell_ptr != nullptr.

References axom::mint::ConnectivityArray< TYPE >::getNumberOfIDs(), and SLIC_ASSERT.

◆ operator[]() [2/2]

template<ConnectivityType TYPE>
const IndexType* axom::mint::ConnectivityArray< TYPE >::operator[] ( IndexType  ID) const
inline

◆ getValuePtr() [1/2]

template<ConnectivityType TYPE>
IndexType* axom::mint::ConnectivityArray< TYPE >::getValuePtr ( )
inline

Returns a pointer to the values array, of length getNumberOfValues().

◆ getValuePtr() [2/2]

template<ConnectivityType TYPE>
const IndexType* axom::mint::ConnectivityArray< TYPE >::getValuePtr ( ) const
inline

◆ getOffsetPtr() [1/2]

template<ConnectivityType TYPE>
IndexType* axom::mint::ConnectivityArray< TYPE >::getOffsetPtr ( )
inline

Returns a pointer to the offsets array. Since this version of the ConnectivityArray does not have an offsets array this function returns a null pointer.

◆ getOffsetPtr() [2/2]

template<ConnectivityType TYPE>
const IndexType* axom::mint::ConnectivityArray< TYPE >::getOffsetPtr ( ) const
inline

◆ getTypePtr() [1/2]

template<ConnectivityType TYPE>
CellType* axom::mint::ConnectivityArray< TYPE >::getTypePtr ( )
inline

Returns a pointer to the types array. Since this version of the ConnectivityArray does not have a types array this function returns a null pointer.

◆ getTypePtr() [2/2]

template<ConnectivityType TYPE>
const CellType* axom::mint::ConnectivityArray< TYPE >::getTypePtr ( ) const
inline

◆ append()

template<ConnectivityType TYPE>
void axom::mint::ConnectivityArray< TYPE >::append ( const IndexType values,
IndexType   AXOM_UNUSED_PARAMn_values = 0,
CellType   AXOM_UNUSED_PARAMtype = UNDEFINED_CELL 
)
inline

Appends an ID.

Parameters
[in]valuespointer to the values to add, of length at least getNumberOfValuesForID().
[in]n_valuesnot used, does not need to be specified.
[in]typenot used, does not need to be specified.
Precondition
values != nullptr

References axom::mint::ConnectivityArray< TYPE >::appendM().

◆ appendM()

template<ConnectivityType TYPE>
void axom::mint::ConnectivityArray< TYPE >::appendM ( const IndexType values,
IndexType  n_IDs,
const IndexType AXOM_UNUSED_PARAMoffsets = nullptr,
const CellType AXOM_UNUSED_PARAMtypes = nullptr 
)
inline

Adds multiple IDs.

Parameters
[in]valuespointer to the values to add, of length at least n_IDs * getNumberOfValuesForID().
[in]n_IDsthe number of IDs to append.
[in]offsetsnot used, does not need to be specified.
[in]typesnot used, does not need to be specified.
Precondition
values != nullptr
n_IDs >= 0

References SLIC_ASSERT.

◆ set()

template<ConnectivityType TYPE>
void axom::mint::ConnectivityArray< TYPE >::set ( const IndexType values,
IndexType  ID 
)
inline

Sets the values of the given ID.

Parameters
[in]valuespointer to the values to set, of length at least getNumberOfValuesForID().
[in]IDthe ID of the values to set.
Precondition
ID >= 0 && ID < getNumberOfIDs()
values != nullptr

References axom::mint::ConnectivityArray< TYPE >::getNumberOfIDs(), and SLIC_ASSERT.

◆ setM()

template<ConnectivityType TYPE>
void axom::mint::ConnectivityArray< TYPE >::setM ( const IndexType values,
IndexType  start_ID,
IndexType  n_IDs 
)
inline

Sets the values of multiple IDs starting with the given ID.

Parameters
[in]valuespointer to the values to set, of length at least n_IDs * getNumberOfValuesForID.
[in]start_IDthe ID to start at.
[in]n_IDsthe number of IDs to set.
Precondition
start_ID >= 0 && start_ID + n_IDs < getNumberOfIDs()
values != nullptr

References axom::mint::ConnectivityArray< TYPE >::getNumberOfIDs(), and SLIC_ASSERT.

◆ insert()

template<ConnectivityType TYPE>
void axom::mint::ConnectivityArray< TYPE >::insert ( const IndexType values,
IndexType  start_ID,
IndexType   AXOM_UNUSED_PARAMn_values = 0,
CellType   AXOM_UNUSED_PARAMtype = UNDEFINED_CELL 
)
inline

Insert the values of a new ID before the given ID.

Parameters
[in]valuespointer to the values to insert, of length at least getNumberOfValuesForID().
[in]start_IDthe ID to start at.
[in]n_valuesnot used, does not need to be specified.
[in]typenot used, does not need to be specified.
Precondition
start_ID >= 0 && start_ID <= getNumberOfIDs()
values != nullptr

References axom::mint::ConnectivityArray< TYPE >::insertM().

◆ insertM()

template<ConnectivityType TYPE>
void axom::mint::ConnectivityArray< TYPE >::insertM ( const IndexType values,
IndexType  start_ID,
IndexType  n_IDs,
const IndexType AXOM_UNUSED_PARAMoffsets = nullptr,
const CellType AXOM_UNUSED_PARAMtypes = nullptr 
)
inline

Insert the values of multiple IDs before the given ID.

Parameters
[in]valuespointer to the values to set, of length at least n_IDs * getNumberOfValuesForID().
[in]start_IDthe ID to start at.
[in]n_IDsthe number of IDs to insert.
[in]offsetsnot used, does not need to be specified.
[in]typesnot used, does not need to be specified.
Precondition
start_ID >= 0 && start_ID <= getNumberOfIDs()
n_IDs >= 0
values != nullptr

References axom::mint::ConnectivityArray< TYPE >::getNumberOfIDs(), and SLIC_ASSERT.


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