Wonton::Simple_State_Wrapper< MeshWrapper > Class Template Reference

A thin wrapper that implements state methods for Simple_State needed by Wonton. More...

#include <simple_state_mm_wrapper.h>

Inheritance diagram for Wonton::Simple_State_Wrapper< MeshWrapper >:
Wonton::StateManager< MeshWrapper >

Public Member Functions

 Simple_State_Wrapper (const MeshWrapper &mesh, std::unordered_map< std::string, int > names={}, std::unordered_map< int, std::vector< int >> material_cells={})
 Constructor for the state wrapper. More...
 
Simple_State_Wrapperoperator= (Simple_State_Wrapper const &)=delete
 Assignment operator (disabled). More...
 
 ~Simple_State_Wrapper ()
 Destructor. More...
 
int mat_get_num_cells (int m) const
 Return the number of cells for this material id. More...
 
 Simple_State_Wrapper (Simple_State &state)
 Constructor for the state wrapper. More...
 
Simple_State_Wrapperoperator= (Simple_State_Wrapper const &)=delete
 Assignment operator (disabled). More...
 
 ~Simple_State_Wrapper ()
 Destructor. More...
 
int num_materials () const
 Number of materials in problem. More...
 
std::string material_name (int matid) const
 Name of material. More...
 
int mat_get_num_cells (int matid) const
 Get number of cells containing a particular material. More...
 
void mat_get_cells (int matid, std::vector< int > *matcells) const
 Get cell indices containing a particular material. More...
 
int cell_get_num_mats (int cellid) const
 Get number of materials contained in a cell. More...
 
void cell_get_mats (int cellid, std::vector< int > *cellmats) const
 Get the IDs of materials in a cell. More...
 
int cell_index_in_material (int meshcell, int matid) const
 Get the local index of mesh cell in material cell list. More...
 
Field_type field_type (Entity_kind on_what, std::string const &var_name) const
 Type of field (MESH_FIELD or MULTIMATERIAL_FIELD) More...
 
void mesh_get_data (Entity_kind on_what, std::string const &name, double **data)
 Get a pointer to data from the state manager with a given variable name and on on_what mesh entities. More...
 
void mesh_get_data (Entity_kind on_what, std::string const &name, double const **data) const
 Get a pointer to data from the state manager with a given variable name and on on_what mesh entities. More...
 
void mat_get_celldata (std::string const &var_name, int matid, double const **data) const
 Get pointer to read-only scalar cell data for a particular material. More...
 
void mat_get_celldata (std::string const &var_name, int matid, Wonton::Point< 2 > const **data) const
 
void mat_get_celldata (std::string const &var_name, int matid, Wonton::Point< 3 > const **data) const
 
void mat_get_celldata (std::string const &var_name, int matid, double **data)
 Get pointer to read-write scalar data for a particular material. More...
 
void mesh_add_data (Entity_kind on_what, std::string const &name, double const **data) const
 Get a pointer to data from the state manager with a given variable name and on on_what mesh entities. More...
 
void mat_add_celldata (std::string const &var_name, double value)
 Add a scalar multi-valued data field on cells and initialize its material data to a single value. More...
 
void mat_add_celldata (std::string const &var_name, double const *const *values=nullptr, Data_layout layout=Data_layout::MATERIAL_CENTRIC)
 Add a scalar multi-valued data field on cells and initialize its material data according to a 2D array. More...
 
void mat_add_celldata (std::string const &var_name, int matid, double const *values)
 Add a scalar multi-valued data field on cells and add data to one of its materials. More...
 
void mat_add_celldata (std::string const &var_name, int matid, double value)
 Add a scalar multi-valued data field on cells and initialize one of its material data to a uniform value. More...
 
void mat_add_cells (int matid, std::vector< int > const &newcells)
 Add cells to material (or add material to cells) More...
 
void mat_rem_cells (int matid, std::vector< int > const &delcells)
 Remove cells from material (or remove material from cells) More...
 
void add_material (std::string const &matname, std::vector< int > const &matcells)
 Add a material to state. More...
 
- Public Member Functions inherited from Wonton::StateManager< MeshWrapper >
 StateManager (const MeshWrapper &mesh, std::unordered_map< std::string, int > names={}, std::unordered_map< int, std::vector< int >> material_cells={})
 Constructor. More...
 
void add_material_names (const std::unordered_map< std::string, int > &names)
 Add the names of the materials. More...
 
std::vector< std::string > const names () const
 Return the names registered by the state manager. More...
 
std::string material_name (int m) const
 Return the name of a material from its material id. More...
 
int get_material_id (std::string const &name) const
 Return the material id from its name. More...
 
void add_material_cells (std::unordered_map< int, std::vector< int >> cells)
 Add the material cells. More...
 
std::unordered_map< int, std::vector< int > > const & get_material_cells () const
 Return the material cells. More...
 
std::unordered_map< int, std::unordered_set< int > > const & get_cell_materials () const
 Return the cell materials. More...
 
std::unordered_map< int, int > const get_material_shape () const
 Return the number of cells for each material. More...
 
int num_materials () const
 Return the number of materials in the problem. More...
 
Entity_kind get_entity (std::string const &name) const
 Return the entity kind for a state vector. More...
 
Field_type field_type (Entity_kind kind, std::string const &name) const
 Return the field type of a state vector. More...
 
int get_data_size (Entity_kind on_what, std::string const &name) const
 Return the data size . More...
 
const std::type_info & get_data_type (std::string var_name)
 Get the data type of the given field. More...
 
void add (std::shared_ptr< StateVectorBase > sv)
 Add a StateVectorBase to the state manager. More...
 
template<class T >
void add (std::shared_ptr< StateVectorUni< T >> sv)
 Add a StateVectorUni<T> to the state manager. More...
 
template<class T >
void add (std::shared_ptr< StateVectorMulti< T >> sv)
 Add a StateVectorMulti<T> to the state manager. More...
 
std::shared_ptr< StateVectorBaseget (std::string name)
 Get a shared pointer to a StateVectorBase from the state manager. More...
 
std::shared_ptr< StateVectorBase const > get (std::string name) const
 Get a shared pointer to a const StateVectorBase from the state manager. More...
 
template<typename T >
std::shared_ptr< T > get (std::string name)
 Get a shared pointer to a templated type from the state manager. More...
 
template<typename T >
std::shared_ptr< T > get (std::string name) const
 Get a shared pointer to a templated type from the state manager. More...
 
int num_material_cells (int m) const
 Return the number of cells for this material id. More...
 
std::vector< int > const & get_material_cells (int m) const
 Return the cell ids for this material id. More...
 
void mat_get_cells (int m, std::vector< int > *matcells) const
 Return the cell ids for this material id. More...
 
template<class T >
void mat_get_celldata (std::string const &name, int m, T const **data) const
 Return the cell data for this material id. More...
 
int cell_index_in_material (int c, int m) const
 Return the cell index in this material id. More...
 
template<class T >
void mat_get_celldata (std::string const &name, int m, T **data)
 Return the cell data for this material id. More...
 
int cell_get_num_mats (int c) const
 Return the number of materials in this cell. More...
 
std::unordered_set< int > get_cell_materials (int c) const
 Return the unordered set of materials in this cell. More...
 
void cell_get_mats (int c, std::vector< int > *cellmats) const
 Return the materials in this cell. More...
 
template<class T >
void mesh_get_data (Entity_kind on_what, std::string const &name, T const **data) const
 Return the const cell data for this material id. More...
 
template<class T >
void mesh_get_data (Entity_kind on_what, std::string const &name, T **data)
 Return the cell data for this material id. More...
 
void mat_add_cells (int m, std::vector< int > const &newcells)
 Add cells for a new material to the material cells. More...
 
template<class T >
void mat_add_celldata (std::string const &name, int m, T const *values)
 Add cell data for a new material in a state vector to the state manager. More...
 
void add_material (std::string const &matname, std::vector< int > const &matcells)
 Add cell data for a new material in a state vector to the state manager. More...
 
template<class T = double>
bool shape_is_good (const std::shared_ptr< StateVectorMulti< T >> sv)
 Check that a StateVectorMulti<T> has a shape consistent with the state manager. More...
 
void clear_material_cells ()
 Clear material cells and the inverse map of cell materials. More...
 

Given a variable name, get where it lives on the mesh.

Parameters
[in]nameThe name of the variable to be found.
Returns
The Entity_kind (e.g. CELL) indicating where the variable lives.
Exceptions
std::runtime_exceptionVariable not found.

This will only pick the first defined variable, if the user adds multiple fields with the same variable name, but on different Entity_kinds. This should be fixed, or get_entity should be ammended.

Entity_kind get_entity (std::string const &name) const
 
int get_data_size (Entity_kind on_what, std::string const &name) const
 Get the number of elements in a specific variable from the state manager. More...
 
const std::type_info & get_data_type (std::string const &var_name) const
 Get the data type of the given field. More...
 
Simple_State::name_vec_it names_begin () const
 An iterator to the beginning of the vector of names in the state manager. More...
 
Simple_State::name_vec_it names_end () const
 An iterator to the ending of the vector of names in the state manager. More...
 
Simple_State::name_vec names () const
 

Additional Inherited Members

- Protected Member Functions inherited from Wonton::StateManager< MeshWrapper >
void clear ()
 
- Protected Attributes inherited from Wonton::StateManager< MeshWrapper >
const MeshWrapper & mesh_
 
std::unordered_map< std::string, std::shared_ptr< StateVectorBase > > state_vectors_
 
std::unordered_map< std::string, int > material_ids_
 
std::unordered_map< int, std::string > material_names_
 
std::unordered_map< int, std::vector< int > > material_cells_
 
std::unordered_map< int, std::unordered_map< int, int > > cell_index_in_mat_
 
std::unordered_map< int, std::unordered_set< int > > cell_materials_
 

Detailed Description

template<class MeshWrapper>
class Wonton::Simple_State_Wrapper< MeshWrapper >

A thin wrapper that implements state methods for Simple_State needed by Wonton.

Constructor & Destructor Documentation

◆ Simple_State_Wrapper() [1/2]

template<class MeshWrapper >
Wonton::Simple_State_Wrapper< MeshWrapper >::Simple_State_Wrapper ( const MeshWrapper &  mesh,
std::unordered_map< std::string, int >  names = {},
std::unordered_map< int, std::vector< int >>  material_cells = {} 
)
inline

Constructor for the state wrapper.

◆ ~Simple_State_Wrapper() [1/2]

template<class MeshWrapper >
Wonton::Simple_State_Wrapper< MeshWrapper >::~Simple_State_Wrapper ( )
inline

Destructor.

◆ Simple_State_Wrapper() [2/2]

template<class MeshWrapper >
Wonton::Simple_State_Wrapper< MeshWrapper >::Simple_State_Wrapper ( Simple_State state)
inlineexplicit

Constructor for the state wrapper.

◆ ~Simple_State_Wrapper() [2/2]

template<class MeshWrapper >
Wonton::Simple_State_Wrapper< MeshWrapper >::~Simple_State_Wrapper ( )
inline

Destructor.

Member Function Documentation

◆ add_material()

template<class MeshWrapper >
void Wonton::Simple_State_Wrapper< MeshWrapper >::add_material ( std::string const &  matname,
std::vector< int > const &  matcells 
)
inline

Add a material to state.

Parameters
[in]matnameName of material
[in]matcellsCells containing the material

◆ cell_get_mats()

template<class MeshWrapper >
void Wonton::Simple_State_Wrapper< MeshWrapper >::cell_get_mats ( int  cellid,
std::vector< int > *  cellmats 
) const
inline

Get the IDs of materials in a cell.

Parameters
cellidIndex of cell in mesh
cellmatsIndices of materials in cell

◆ cell_get_num_mats()

template<class MeshWrapper >
int Wonton::Simple_State_Wrapper< MeshWrapper >::cell_get_num_mats ( int  cellid) const
inline

Get number of materials contained in a cell.

Parameters
cellidIndex of cell in mesh
Returns
Number of materials in cell

◆ cell_index_in_material()

template<class MeshWrapper >
int Wonton::Simple_State_Wrapper< MeshWrapper >::cell_index_in_material ( int  meshcell,
int  matid 
) const
inline

Get the local index of mesh cell in material cell list.

Parameters
meshcellMesh cell ID
matidMaterial ID
Returns
Local cell index in material cell list

◆ field_type()

template<class MeshWrapper >
Field_type Wonton::Simple_State_Wrapper< MeshWrapper >::field_type ( Entity_kind  on_what,
std::string const &  var_name 
) const
inline

Type of field (MESH_FIELD or MULTIMATERIAL_FIELD)

Parameters
onwhatEntity_kind that field is defined on
varnameName of field
Returns
Field type

◆ get_data_size()

template<class MeshWrapper >
int Wonton::Simple_State_Wrapper< MeshWrapper >::get_data_size ( Entity_kind  on_what,
std::string const &  name 
) const
inline

Get the number of elements in a specific variable from the state manager.

Parameters
[in]on_whatThe Entity_kind (e.g. CELL) of the variable for which the size is requested.
[in]nameThe name of the variable for which the size is requested.
Returns
The number of elements; for example, the number of cells, if the data were added with the CELLS Entity_kind.

◆ get_data_type()

template<class MeshWrapper >
const std::type_info& Wonton::Simple_State_Wrapper< MeshWrapper >::get_data_type ( std::string const &  var_name) const
inline

Get the data type of the given field.

Parameters
[in]var_nameThe string name of the data field
Returns
A reference to the type_info struct for the field's data type

◆ get_entity()

template<class MeshWrapper >
Entity_kind Wonton::Simple_State_Wrapper< MeshWrapper >::get_entity ( std::string const &  name) const
inline

◆ mat_add_celldata() [1/4]

template<class MeshWrapper >
void Wonton::Simple_State_Wrapper< MeshWrapper >::mat_add_celldata ( std::string const &  var_name,
double  value 
)
inline

Add a scalar multi-valued data field on cells and initialize its material data to a single value.

Parameters
[in]var_nameThe name of the data field
[in]valueInitialize with this value

The 2D array will be read and values copied according to which materials are contained in which cells. If a material+cell combination is not active providing a value for the array will have no effect.

◆ mat_add_celldata() [2/4]

template<class MeshWrapper >
void Wonton::Simple_State_Wrapper< MeshWrapper >::mat_add_celldata ( std::string const &  var_name,
double const *const *  values = nullptr,
Data_layout  layout = Data_layout::MATERIAL_CENTRIC 
)
inline

Add a scalar multi-valued data field on cells and initialize its material data according to a 2D array.

Parameters
[in]var_nameThe name of the data field
[in]layoutWhether 2D array is laid out with first index being the cell (CELL_CENRIC) or material (MATERIAL CENTRIC)
[in]valueInitialize with this value

The 2D array will be read and values copied according to which materials are contained in which cells. If a material+cell combination is not active providing a value for the array will have no effect.

◆ mat_add_celldata() [3/4]

template<class MeshWrapper >
void Wonton::Simple_State_Wrapper< MeshWrapper >::mat_add_celldata ( std::string const &  var_name,
int  matid,
double const *  values 
)
inline

Add a scalar multi-valued data field on cells and add data to one of its materials.

Parameters
[in]var_nameThe name of the data field
[in]matidIndex of material in the problem
[in]layoutData layout -
[in]valuesInitialize with this array of values

Subsequent calls to this function with the same name will find the added field and just add the data.

◆ mat_add_celldata() [4/4]

template<class MeshWrapper >
void Wonton::Simple_State_Wrapper< MeshWrapper >::mat_add_celldata ( std::string const &  var_name,
int  matid,
double  value 
)
inline

Add a scalar multi-valued data field on cells and initialize one of its material data to a uniform value.

Parameters
[in]var_nameThe name of the data field
[in]matidIndex of material in the problem
[in]valueInitialize with this value

Subsequent calls to this function with the same name will find the added field and just add the data.

◆ mat_add_cells()

template<class MeshWrapper >
void Wonton::Simple_State_Wrapper< MeshWrapper >::mat_add_cells ( int  matid,
std::vector< int > const &  newcells 
)
inline

Add cells to material (or add material to cells)

Parameters
[in]matidMaterial ID
[in]newcellsVector of new cells in material

◆ mat_get_celldata() [1/4]

template<class MeshWrapper >
void Wonton::Simple_State_Wrapper< MeshWrapper >::mat_get_celldata ( std::string const &  var_name,
int  matid,
double const **  data 
) const
inline

Get pointer to read-only scalar cell data for a particular material.

Parameters
[in]var_nameThe string name of the data field
[in]matidIndex (not unique identifier) of the material
[out]datavector containing the values corresponding to cells in the material

◆ mat_get_celldata() [2/4]

template<class MeshWrapper >
void Wonton::Simple_State_Wrapper< MeshWrapper >::mat_get_celldata ( std::string const &  var_name,
int  matid,
Wonton::Point< 2 > const **  data 
) const
inline

◆ mat_get_celldata() [3/4]

template<class MeshWrapper >
void Wonton::Simple_State_Wrapper< MeshWrapper >::mat_get_celldata ( std::string const &  var_name,
int  matid,
Wonton::Point< 3 > const **  data 
) const
inline

◆ mat_get_celldata() [4/4]

template<class MeshWrapper >
void Wonton::Simple_State_Wrapper< MeshWrapper >::mat_get_celldata ( std::string const &  var_name,
int  matid,
double **  data 
)
inline

Get pointer to read-write scalar data for a particular material.

Parameters
[in]on_whatThe entity type on which to get the data
[in]var_nameThe string name of the data field
[in]matidIndex (not unique identifier) of the material
[out]datavector containing the values corresponding to cells in the material

◆ mat_get_cells()

template<class MeshWrapper >
void Wonton::Simple_State_Wrapper< MeshWrapper >::mat_get_cells ( int  matid,
std::vector< int > *  matcells 
) const
inline

Get cell indices containing a particular material.

Parameters
matidIndex of material (0, num_materials()-1)
matcellsCells containing material 'matid'

◆ mat_get_num_cells() [1/2]

template<class MeshWrapper >
int Wonton::Simple_State_Wrapper< MeshWrapper >::mat_get_num_cells ( int  m) const
inline

Return the number of cells for this material id.

Parameters
[in]mmaterial id
Returns
number of cells containing this material

Return the number of cells for this material id.

◆ mat_get_num_cells() [2/2]

template<class MeshWrapper >
int Wonton::Simple_State_Wrapper< MeshWrapper >::mat_get_num_cells ( int  matid) const
inline

Get number of cells containing a particular material.

Parameters
matidIndex of material (0, num_materials()-1)
Returns
Number of cells containing material 'matid'

◆ mat_rem_cells()

template<class MeshWrapper >
void Wonton::Simple_State_Wrapper< MeshWrapper >::mat_rem_cells ( int  matid,
std::vector< int > const &  delcells 
)
inline

Remove cells from material (or remove material from cells)

Parameters
[in]matidMaterial ID
[in]matcellsVector of to be removed cells

◆ material_name()

template<class MeshWrapper >
std::string Wonton::Simple_State_Wrapper< MeshWrapper >::material_name ( int  matid) const
inline

Name of material.

◆ mesh_add_data()

template<class MeshWrapper >
void Wonton::Simple_State_Wrapper< MeshWrapper >::mesh_add_data ( Entity_kind  on_what,
std::string const &  name,
double const **  data 
) const
inline

Get a pointer to data from the state manager with a given variable name and on on_what mesh entities.

Parameters
[in]on_whatThe Entity_kind (e.g. CELL) on which the data lives.
[in]nameThe name of the variable.
dataA pointer to the const data array. If the requested data is not found in the state manager, a nullptr is returned.

◆ mesh_get_data() [1/2]

template<class MeshWrapper >
void Wonton::Simple_State_Wrapper< MeshWrapper >::mesh_get_data ( Entity_kind  on_what,
std::string const &  name,
double **  data 
)
inline

Get a pointer to data from the state manager with a given variable name and on on_what mesh entities.

Parameters
[in]on_whatThe Entity_kind (e.g. CELL) on which the data lives.
[in]nameThe name of the variable.
dataA pointer to the data array. If the requested data is not found in the state manager, a nullptr is returned.

◆ mesh_get_data() [2/2]

template<class MeshWrapper >
void Wonton::Simple_State_Wrapper< MeshWrapper >::mesh_get_data ( Entity_kind  on_what,
std::string const &  name,
double const **  data 
) const
inline

Get a pointer to data from the state manager with a given variable name and on on_what mesh entities.

Parameters
[in]on_whatThe Entity_kind (e.g. CELL) on which the data lives.
[in]nameThe name of the variable.
dataA pointer to the const data array. If the requested data is not found in the state manager, a nullptr is returned.

◆ names()

template<class MeshWrapper >
Simple_State::name_vec Wonton::Simple_State_Wrapper< MeshWrapper >::names ( ) const
inline

The above iterator functions fail sometimes for optimized code, so here we allow access to the complete list of names.

◆ names_begin()

template<class MeshWrapper >
Simple_State::name_vec_it Wonton::Simple_State_Wrapper< MeshWrapper >::names_begin ( ) const
inline

An iterator to the beginning of the vector of names in the state manager.

◆ names_end()

template<class MeshWrapper >
Simple_State::name_vec_it Wonton::Simple_State_Wrapper< MeshWrapper >::names_end ( ) const
inline

An iterator to the ending of the vector of names in the state manager.

◆ num_materials()

template<class MeshWrapper >
int Wonton::Simple_State_Wrapper< MeshWrapper >::num_materials ( ) const
inline

Number of materials in problem.

◆ operator=() [1/2]

template<class MeshWrapper >
Simple_State_Wrapper& Wonton::Simple_State_Wrapper< MeshWrapper >::operator= ( Simple_State_Wrapper< MeshWrapper > const &  )
delete

Assignment operator (disabled).

◆ operator=() [2/2]

template<class MeshWrapper >
Simple_State_Wrapper& Wonton::Simple_State_Wrapper< MeshWrapper >::operator= ( Simple_State_Wrapper< MeshWrapper > const &  )
delete

Assignment operator (disabled).


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