AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
|
A multimaterial data management class that provides storage in various layouts (dense/sparse, and material-dominant/cell-dominant). More...
#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/develop/src/axom/multimat/multimat.hpp>
Public Types | |
using | BivariateSetType = slam::BivariateSet< RangeSetType, RangeSetType > |
using | ProductSetType = slam::ProductSet< RangeSetType, RangeSetType > |
using | SparseRelationType = StaticVariableRelationType |
using | RelationSetType = slam::RelationSet< StaticVariableRelationType > |
using | RelationSetDynType = slam::RelationSet< DynamicVariableRelationType > |
template<typename T > | |
using | Field1D = MapType< T > |
template<typename T , typename BSet = BivariateSetType> | |
using | Field2D = MMField2D< T, BSet > |
template<typename T > | |
using | SparseField2D = MMField2D< T, typename RelationSetType::ConcreteSet > |
template<typename T > | |
using | DenseField2D = MMField2D< T, typename ProductSetType::ConcreteSet > |
template<typename T , DataLayout D, typename B > | |
using | Field2DTemplated = MMField2DTemplated< T, D, B > |
template<typename Field2DType > | |
using | SubField = MMSubField2D< Field2DType > |
using | IndexSet = RangeSetType |
using | IdSet = typename BivariateSetType::SubsetType |
Public Member Functions | |
MultiMat (DataLayout data_layout=DataLayout::CELL_DOM, SparsityLayout sparsity_layout=SparsityLayout::SPARSE) | |
Constructor to create a new MultiMat object. More... | |
MultiMat (const MultiMat &other) | |
Copy constructor for a MultiMat object. More... | |
MultiMat & | operator= (const MultiMat &other) |
Copy assignment operator for a MultiMat object. More... | |
MultiMat (MultiMat &&)=default | |
Move constructor for MultiMat, defaulted. More... | |
MultiMat & | operator= (MultiMat &&)=default |
Move assignment operator for MultiMat, defaulted. More... | |
~MultiMat ()=default | |
Destructor for MultiMat, defaulted. More... | |
void | setNumberOfMaterials (int num_mats) |
Set the number of materials. More... | |
void | setNumberOfCells (int num_cells) |
Set the number of cells. More... | |
void | setAllocatorID (int alloc_id) |
Sets the allocator ID to use for allocations. Has the same effect as calling setSlamAllocatorID() and setFieldAllocatorID() with the same allocator ID. More... | |
void | setSlamAllocatorID (int alloc_id) |
Sets the allocator ID to use for Slam object allocations. This should point to either a host Umpire pool if only being used on the host, or a unified memory pool if also being used on the GPU. More... | |
void | setFieldAllocatorID (int alloc_id) |
Sets the allocator ID to use for field allocations. More... | |
const ProductSetType * | getDense2dFieldSet (DataLayout layout) const |
Returns a pointer to the dense 2d field set. More... | |
const RelationSetType * | getSparse2dFieldSet (DataLayout layout) const |
Returns a pointer to the sparse 2d field set. More... | |
void | setCellMatRel (const std::vector< bool > &relation_info, DataLayout layout) |
Set the cell-material relation. More... | |
void | setCellMatRel (axom::ArrayView< const SetPosType > cardinality, axom::ArrayView< const SetPosType > indices, DataLayout layout) |
Set the cell-material relation. More... | |
int | getNumberOfFields () const |
template<typename T > | |
int | addField (const std::string &field_name, FieldMapping field_mapping, DataLayout data_layout, SparsityLayout sparsity_layout, axom::ArrayView< T > data_array, int ncomp=1) |
Add a field to the MultiMat object. More... | |
template<typename T > | |
int | addExternalField (const std::string &field_name, FieldMapping field_mapping, DataLayout data_layout, SparsityLayout sparsity_layout, axom::ArrayView< T > data_array, int ncomp=1) |
Add an externally-managed field to the MultiMat object. More... | |
void | removeField (const std::string &name) |
Delete a field from the MultiMat object. More... | |
template<typename T > | |
int | setVolfracField (axom::ArrayView< T > data_array, DataLayout layout, SparsityLayout sparsity) |
Set the volume fraction field \detail volume fraction field is assumed to be a double. Its field index is always 0, and the name of the field is "Volfrac". More... | |
int | setVolfracField (axom::ArrayView< const double > data_array, DataLayout layout, SparsityLayout sparsity) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
int | getFieldIdx (const std::string &field_name) const |
Search for and return the field index of the field given its name. More... | |
std::string | getFieldName (int field_idx) const |
Return the name of the field given its index. More... | |
template<typename T > | |
Field1D< T > | get1dField (const std::string &field_name) |
Search for and return the field given the field name. \detail the field is of type Field1D, containing an entry for each cell or material. To retrieve a field of type Field2D, use get2dField(). More... | |
template<typename T > | |
Field1D< const T > | get1dField (const std::string &field_name) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
template<typename T > | |
Field2D< T > | get2dField (const std::string &field_name) |
Search for and return the field given the field name. \detail the field is of type Field2D, containing an entry for each cell and each material. To retrieve a field of type Field1D, use get1dField(). More... | |
template<typename T > | |
Field2D< const T > | get2dField (const std::string &field_name) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
template<typename T , typename BSetType > | |
Field2D< T, BSetType > | get2dField (const std::string &field_name) |
template<typename T > | |
DenseField2D< T > | getDense2dField (const std::string &field_name) |
template<typename T > | |
SparseField2D< T > | getSparse2dField (const std::string &field_name) |
template<typename T , DataLayout D, typename B > | |
Field2DTemplated< T, D, B > | getTemplated2DField (const std::string &field_name) |
template<typename T , typename BSetType > | |
slam::BivariateMap< T, BSetType, IndViewPolicy< T > > | get2dFieldAsSlamBivarMap (const std::string &field_name) |
Field2D< double > | getVolfracField () |
Get the volume fraction field. More... | |
Field2D< const double > | getVolfracField () const |
IdSet | getSubfieldIndex (int idx) |
Get a set of index for a Subfield. \detail for a cell-dominant layout, this is equivalent to getting the set of materials presented in a cell. Vice versa, for a material-dominant layout, this returns a set of cells containing a material. getMatInCell() and getCellContainingMat() are layout specific calls for this function. More... | |
IdSet | getMatInCell (int cell_id) |
IdSet | getCellContainingMat (int mat_id) |
IndexSet | getSubfieldIndexingSet (int idx, DataLayout layout, SparsityLayout sparsity) const |
Get a set to index a Subfield in a Field2D. \detail This returns a set of indices that can be used to directly access a subfield in a Field2D without having to retrieve a Subfield first. Accessing the Field2D using this indexing set should be done with the bracket operator. More... | |
IndexSet | getIndexingSetOfCell (int cell_id, SparsityLayout sparsity) const |
IndexSet | getIndexingSetOfMat (int mat_id, SparsityLayout sparsity) const |
int | getNumberOfMaterials () const |
int | getNumberOfCells () const |
void | convertFieldLayout (int field_idx, SparsityLayout, DataLayout) |
void | convertFieldToSparse (int field_idx) |
Converts a field with a given index to a sparse layout. No-op if the field is already in sparse layout, or if the field is not a 2D cell-material field. More... | |
void | convertFieldToDense (int field_idx) |
Converts a field with a given index to a dense layout. No-op if the field is already in dense layout, or if the field is not a 2D cell-material field. More... | |
SparsityLayout | getFieldSparsityLayout (int field_idx) const |
void | transposeField (int field_idx) |
void | convertFieldToMatDom (int field_idx) |
void | convertFieldToCellDom (int field_idx) |
DataLayout | getFieldDataLayout (int field_idx) const |
std::string | getFieldDataLayoutAsString (int field_idx) const |
std::string | getFieldSparsityLayoutAsString (int field_idx) const |
void | convertLayout (DataLayout, SparsityLayout) |
void | convertLayoutToSparse () |
void | convertLayoutToDense () |
void | convertLayoutToCellDominant () |
void | convertLayoutToMaterialDominant () |
FieldMapping | getFieldMapping (int field_idx) const |
Get the FieldMapping for a field. More... | |
void | convertToDynamic () |
void | convertToStatic () |
bool | addEntry (int firstIdx, int secondIdx) |
Add a material to a cell. More... | |
bool | removeEntry (int firstIdx, int secondIdx) |
Remove a material from a cell. More... | |
void | print () const |
bool | isValid (bool verboseOutput=false) const |
Return true if the object is valid, false otherwise. More... | |
Protected Types | |
using | SetPosType = slam::DefaultPositionType |
using | SetElemType = slam::DefaultPositionType |
using | SetType = slam::Set< SetPosType, SetElemType > |
using | RangeSetType = slam::RangeSet< SetPosType, SetElemType >::ConcreteSet |
Protected Member Functions | |
const RangeSetType * | getMappedRangeSet (FieldMapping mapping) const |
const BivariateSetType * | get_mapped_biSet (DataLayout, SparsityLayout) const |
const BivariateSetType * | get_mapped_biSet (int field_idx) const |
StaticVariableRelationType * | getRel (int field_idx) |
Friends | |
template<typename T , typename S > | |
class | MMField2D |
template<typename Field2D > | |
class | MMSubField2D |
template<typename T , DataLayout D, typename S > | |
class | MMField2DTemplated |
A multimaterial data management class that provides storage in various layouts (dense/sparse, and material-dominant/cell-dominant).
|
protected |
|
protected |
|
protected |
|
protected |
using axom::multimat::MultiMat::Field1D = MapType<T> |
using axom::multimat::MultiMat::Field2D = MMField2D<T, BSet> |
using axom::multimat::MultiMat::SparseField2D = MMField2D<T, typename RelationSetType::ConcreteSet> |
using axom::multimat::MultiMat::DenseField2D = MMField2D<T, typename ProductSetType::ConcreteSet> |
using axom::multimat::MultiMat::Field2DTemplated = MMField2DTemplated<T, D, B> |
using axom::multimat::MultiMat::SubField = MMSubField2D<Field2DType> |
using axom::multimat::MultiMat::IdSet = typename BivariateSetType::SubsetType |
axom::multimat::MultiMat::MultiMat | ( | DataLayout | data_layout = DataLayout::CELL_DOM , |
SparsityLayout | sparsity_layout = SparsityLayout::SPARSE |
||
) |
Constructor to create a new MultiMat object.
data_layout | Select material-dominant or cell-dominant layout to store the data in. Default is cell-dominant. |
sparsity_layout | Select dense or sparse layout to store the data in. Default is sparse. |
axom::multimat::MultiMat::MultiMat | ( | const MultiMat & | other | ) |
|
default |
Move constructor for MultiMat, defaulted.
|
default |
Destructor for MultiMat, defaulted.
Move assignment operator for MultiMat, defaulted.
void axom::multimat::MultiMat::setNumberOfMaterials | ( | int | num_mats | ) |
Set the number of materials.
void axom::multimat::MultiMat::setNumberOfCells | ( | int | num_cells | ) |
Set the number of cells.
void axom::multimat::MultiMat::setAllocatorID | ( | int | alloc_id | ) |
Sets the allocator ID to use for allocations. Has the same effect as calling setSlamAllocatorID() and setFieldAllocatorID() with the same allocator ID.
The | allocator ID to use |
void axom::multimat::MultiMat::setSlamAllocatorID | ( | int | alloc_id | ) |
Sets the allocator ID to use for Slam object allocations. This should point to either a host Umpire pool if only being used on the host, or a unified memory pool if also being used on the GPU.
alloc_id | the Umpire allocator ID to use |
void axom::multimat::MultiMat::setFieldAllocatorID | ( | int | alloc_id | ) |
Sets the allocator ID to use for field allocations.
alloc_id | the Umpire allocator ID to use |
|
inline |
Returns a pointer to the dense 2d field set.
|
inline |
Returns a pointer to the sparse 2d field set.
void axom::multimat::MultiMat::setCellMatRel | ( | const std::vector< bool > & | relation_info, |
DataLayout | layout | ||
) |
Set the cell-material relation.
\detail This function takes the input of boolean vectors and set-up internal data structure. The relation_info vector is indexed by the cell and material index:
idx = mat * num_cell + cell
or idx = cell * num_mats + mat
for material-centric and cell-centric layout, respectively.
Entry at idx
should containing 'true' where materials are presented in the cell.
The number of materials and cell must be set prior to calling this function with setNumberOfMaterials(int) and setNumberOfCells(int)
A | boolean vector of size num_mats * num_cells containing information on if a materials is present in a cell. |
void axom::multimat::MultiMat::setCellMatRel | ( | axom::ArrayView< const SetPosType > | cardinality, |
axom::ArrayView< const SetPosType > | indices, | ||
DataLayout | layout | ||
) |
Set the cell-material relation.
\detail This function accepts a compressed sparse row representation of a relation.
cardinality | The number of secondary elements associated with each dominant element, i.e.:
|
indices | A compressed sparse row array of indices representing the associated secondary-set elements, i.e.:
|
layout | The layout of the relation (cell- or material-dominant) |
|
inline |
int axom::multimat::MultiMat::addField | ( | const std::string & | field_name, |
FieldMapping | field_mapping, | ||
DataLayout | data_layout, | ||
SparsityLayout | sparsity_layout, | ||
axom::ArrayView< T > | data_array, | ||
int | ncomp = 1 |
||
) |
Add a field to the MultiMat object.
If a field has the special name 'VolFrac', calling addField will have the same behavior as calling setVolfracField. If a field already exists, the call to addExternalField is a no-op, and the index of the already-existing field will be returned.
T | The data type (double, float...) of the field |
field_name | The name of the field, used to retrieve the field later |
field_mapping | |
data_layout | |
sparsity_layout | |
data_array | The array containing data to the field. The length of the array should be num_mats * num_cells * ncomp if the current format is Dense, or num_nonzero * ncomp if the current format is Sprase. |
(optional) | ncomp The number of component of the field. Default is 1 |
References getFieldIdx(), axom::multimat::PER_CELL_MAT, setVolfracField(), SLIC_ASSERT, and SLIC_WARNING.
int axom::multimat::MultiMat::addExternalField | ( | const std::string & | field_name, |
FieldMapping | field_mapping, | ||
DataLayout | data_layout, | ||
SparsityLayout | sparsity_layout, | ||
axom::ArrayView< T > | data_array, | ||
int | ncomp = 1 |
||
) |
Add an externally-managed field to the MultiMat object.
If a field has the special name 'VolFrac', calling addField will have the same behavior as calling setVolfracField. A volume fraction field will always be internally-managed. If a field already exists, the call to addExternalField is a no-op, and the index of the already-existing field will be returned.
T | The data type (double, float...) of the field |
field_name | The name of the field, used to retrieve the field later |
field_mapping | |
data_layout | |
sparsity_layout | |
data_array | The array containing data to the field. The length of the array should be num_mats * num_cells * ncomp if the current format is Dense, or num_nonzero * ncomp if the current format is Sprase. |
(optional) | ncomp The number of component of the field. Default is 1 |
References getFieldIdx(), axom::multimat::PER_CELL_MAT, setVolfracField(), SLIC_ASSERT, and SLIC_WARNING.
void axom::multimat::MultiMat::removeField | ( | const std::string & | name | ) |
Delete a field from the MultiMat object.
name | The name of the field to remove. |
int axom::multimat::MultiMat::setVolfracField | ( | axom::ArrayView< T > | data_array, |
DataLayout | layout, | ||
SparsityLayout | sparsity | ||
) |
Set the volume fraction field \detail volume fraction field is assumed to be a double. Its field index is always 0, and the name of the field is "Volfrac".
data_array | the array containing the volume fraction information |
References axom::ArrayView< T, DIM, SPACE >::size().
int axom::multimat::MultiMat::setVolfracField | ( | axom::ArrayView< const double > | data_array, |
DataLayout | layout, | ||
SparsityLayout | sparsity | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
int axom::multimat::MultiMat::getFieldIdx | ( | const std::string & | field_name | ) | const |
Search for and return the field index of the field given its name.
field_name | the name of the field |
std::string axom::multimat::MultiMat::getFieldName | ( | int | field_idx | ) | const |
Return the name of the field given its index.
field_idx | the index of the field |
MultiMat::Field1D< T > axom::multimat::MultiMat::get1dField | ( | const std::string & | field_name | ) |
Search for and return the field given the field name. \detail the field is of type Field1D, containing an entry for each cell or material. To retrieve a field of type Field2D, use get2dField().
T | The data type of the field |
field_name | the name of the field |
References getFieldIdx(), and SLIC_ERROR.
MultiMat::Field1D< const T > axom::multimat::MultiMat::get1dField | ( | const std::string & | field_name | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
References getFieldIdx(), and SLIC_ERROR.
MultiMat::Field2D< T > axom::multimat::MultiMat::get2dField | ( | const std::string & | field_name | ) |
Search for and return the field given the field name. \detail the field is of type Field2D, containing an entry for each cell and each material. To retrieve a field of type Field1D, use get1dField().
T | The data type of the field |
field_name | the name of the field |
References getFieldIdx(), and SLIC_ERROR.
MultiMat::Field2D< const T > axom::multimat::MultiMat::get2dField | ( | const std::string & | field_name | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
References getFieldIdx().
MultiMat::Field2D< T, BSetType > axom::multimat::MultiMat::get2dField | ( | const std::string & | field_name | ) |
References getFieldIdx().
MultiMat::DenseField2D< T > axom::multimat::MultiMat::getDense2dField | ( | const std::string & | field_name | ) |
References getFieldIdx(), and SLIC_CHECK_MSG.
MultiMat::SparseField2D< T > axom::multimat::MultiMat::getSparse2dField | ( | const std::string & | field_name | ) |
References getFieldIdx(), and SLIC_CHECK_MSG.
MultiMat::Field2DTemplated< T, D, B > axom::multimat::MultiMat::getTemplated2DField | ( | const std::string & | field_name | ) |
References getFieldIdx().
slam::BivariateMap< T, BSetType, MultiMat::IndViewPolicy< T > > axom::multimat::MultiMat::get2dFieldAsSlamBivarMap | ( | const std::string & | field_name | ) |
References getFieldIdx().
Field2D<double> axom::multimat::MultiMat::getVolfracField | ( | ) |
Get the volume fraction field.
Field2D<const double> axom::multimat::MultiMat::getVolfracField | ( | ) | const |
IdSet axom::multimat::MultiMat::getSubfieldIndex | ( | int | idx | ) |
Get a set of index for a Subfield. \detail for a cell-dominant layout, this is equivalent to getting the set of materials presented in a cell. Vice versa, for a material-dominant layout, this returns a set of cells containing a material.
getMatInCell() and getCellContainingMat() are layout specific calls for this function.
idx | the index of the subfield |
IdSet axom::multimat::MultiMat::getMatInCell | ( | int | cell_id | ) |
Cell-dominant version of getSubfieldIndex()
IdSet axom::multimat::MultiMat::getCellContainingMat | ( | int | mat_id | ) |
Material-dominant version of getSubfieldIndex()
IndexSet axom::multimat::MultiMat::getSubfieldIndexingSet | ( | int | idx, |
DataLayout | layout, | ||
SparsityLayout | sparsity | ||
) | const |
Get a set to index a Subfield in a Field2D. \detail This returns a set of indices that can be used to directly access a subfield in a Field2D without having to retrieve a Subfield first.
Accessing the Field2D using this indexing set should be done with the bracket operator.
For example:
Or to account for multiple components:
getIndexingSetOfCell() and getIndexingSetOfMat() are layout specific calls for this function.
idx | The index of the subfield |
IndexSet axom::multimat::MultiMat::getIndexingSetOfCell | ( | int | cell_id, |
SparsityLayout | sparsity | ||
) | const |
Cell-dominant version of getSubfieldIndexingSet()
IndexSet axom::multimat::MultiMat::getIndexingSetOfMat | ( | int | mat_id, |
SparsityLayout | sparsity | ||
) | const |
Material-dominant version of getSubfieldIndexingSet()
|
inline |
Return the number of material this object holds
|
inline |
Return the number of cells this object holds
void axom::multimat::MultiMat::convertFieldLayout | ( | int | field_idx, |
SparsityLayout | , | ||
DataLayout | |||
) |
void axom::multimat::MultiMat::convertFieldToSparse | ( | int | field_idx | ) |
Converts a field with a given index to a sparse layout. No-op if the field is already in sparse layout, or if the field is not a 2D cell-material field.
field_idx | the index of the field to convert |
void axom::multimat::MultiMat::convertFieldToDense | ( | int | field_idx | ) |
Converts a field with a given index to a dense layout. No-op if the field is already in dense layout, or if the field is not a 2D cell-material field.
field_idx | the index of the field to convert |
SparsityLayout axom::multimat::MultiMat::getFieldSparsityLayout | ( | int | field_idx | ) | const |
void axom::multimat::MultiMat::transposeField | ( | int | field_idx | ) |
void axom::multimat::MultiMat::convertFieldToMatDom | ( | int | field_idx | ) |
void axom::multimat::MultiMat::convertFieldToCellDom | ( | int | field_idx | ) |
DataLayout axom::multimat::MultiMat::getFieldDataLayout | ( | int | field_idx | ) | const |
std::string axom::multimat::MultiMat::getFieldDataLayoutAsString | ( | int | field_idx | ) | const |
std::string axom::multimat::MultiMat::getFieldSparsityLayoutAsString | ( | int | field_idx | ) | const |
void axom::multimat::MultiMat::convertLayout | ( | DataLayout | , |
SparsityLayout | |||
) |
Convert the data to be stored in the specified layout.
void axom::multimat::MultiMat::convertLayoutToSparse | ( | ) |
Convert the data to be stored in sparse/compact layout
void axom::multimat::MultiMat::convertLayoutToDense | ( | ) |
Convert the data to be stored in dense layout
void axom::multimat::MultiMat::convertLayoutToCellDominant | ( | ) |
Convert the data to be stored in cell-dominant layout.
void axom::multimat::MultiMat::convertLayoutToMaterialDominant | ( | ) |
Convert the data to be stored in material-dominant layout.
|
inline |
Get the FieldMapping for a field.
A FieldMapping of a field describes if there is an entry for each cell, for each material, or for each cell x material.
field_idx | the index of the field |
void axom::multimat::MultiMat::convertToDynamic | ( | ) |
Convert the layout to use dynamic layout. In dynamic layout, users can call addEntry() or removeEntry() to change the materials in a cell.
void axom::multimat::MultiMat::convertToStatic | ( | ) |
Convert the layout to use static layout.
bool axom::multimat::MultiMat::addEntry | ( | int | firstIdx, |
int | secondIdx | ||
) |
Add a material to a cell.
In a cell-dominant layout, firstIdx is the cell index, secondIdx is the material index. Conversely, for a material-dominant layout, firstIdx is the material index and secondIdx is the cell index.
bool axom::multimat::MultiMat::removeEntry | ( | int | firstIdx, |
int | secondIdx | ||
) |
Remove a material from a cell.
In a cell-dominant layout, firstIdx is the cell index, secondIdx is the material index. Conversely, for a material-dominant layout, firstIdx is the material index and secondIdx is the cell index.
void axom::multimat::MultiMat::print | ( | ) | const |
Print the detail of this object
bool axom::multimat::MultiMat::isValid | ( | bool | verboseOutput = false | ) | const |
Return true if the object is valid, false otherwise.
verboseOutput | (Optional) if true, this function will print out its valid/invalid detail. |
|
inlineprotected |
References axom::multimat::PER_CELL, axom::multimat::PER_MAT, and SLIC_ASSERT.
|
protected |
|
protected |
|
protected |
|
friend |
|
friend |
|
friend |