Provides access to data stored in Jali_State. More...
#include <jali_state_wrapper.h>
Public Types | |
typedef Jali::State::string_permutation | string_permutation |
Typedef for permutation iterator on vector of strings. More... | |
Public Member Functions | |
Jali_State_Wrapper (Jali::State &jali_state) | |
Constructor of Jali_State_Wrapper. More... | |
Jali_State_Wrapper (Jali_State_Wrapper &state) | |
Copy constructor of Jali_State_Wrapper - not a deep copy. More... | |
Jali_State_Wrapper & | operator= (Jali_State_Wrapper const &)=delete |
Assignment operator (disabled) - don't know how to implement (RVG) More... | |
~Jali_State_Wrapper () | |
Empty destructor. More... | |
void | init_from_mesh () |
Initialize fields from mesh file. More... | |
void | export_to_mesh () |
Export fields to mesh file. 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... | |
template<class T > | |
void | mesh_get_data (Entity_kind on_what, std::string const &var_name, T const **data) const |
Get a pointer to read-only single-valued data on the mesh. More... | |
template<class T > | |
void | mesh_get_data (Entity_kind on_what, std::string const &var_name, T **data) |
Get a pointer to read-write single-valued data on the mesh. More... | |
template<class T > | |
void | mat_get_celldata (std::string const &var_name, int matid, T const **data) const |
Get pointer to read-only scalar cell data for a particular material. More... | |
template<class T > | |
void | mat_get_celldata (std::string const &var_name, int matid, T **data) |
Get pointer to read-write scalar data for a particular material. More... | |
template<class T > | |
void | mesh_add_data (Entity_kind on_what, std::string const &var_name, T const *const values) |
Add a scalar single valued data field. More... | |
template<class T > | |
std::enable_if<(!std::is_pointer< T >::value &&!std::is_array< T >::value), void >::type | mesh_add_data (Entity_kind on_what, std::string const &var_name, const T value) |
Add a scalar single valued data field with uniform values. More... | |
template<class T > | |
std::enable_if<(!std::is_pointer< T >::value &&!std::is_array< T >::value), void >::type | mat_add_celldata (std::string const &var_name, T value) |
Add a scalar multi-valued data field on cells and initialize its material data to a single value. More... | |
template<class T > | |
void | mat_add_celldata (std::string const &var_name, T 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... | |
template<class T > | |
void | mat_add_celldata (std::string const &var_name, int matid, T const *values) |
Add a scalar multi-valued data field on cells and add data to one of its materials. More... | |
template<class T > | |
std::enable_if<(!std::is_pointer< T >::value &&!std::is_array< T >::value), void >::type | mat_add_celldata (std::string const &var_name, int matid, T 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... | |
Entity_kind | get_entity (const std::string var_name) const |
Get the entity type on which the given field is defined. More... | |
int | get_data_size (Entity_kind on_what, std::string const &var_name) const |
Get the data size for the given field. More... | |
const std::type_info & | get_data_type (std::string const &var_name) const |
Get the data type of the given field. More... | |
std::vector< std::string >::iterator | names_begin () const |
Begin iterator on vector names. More... | |
std::vector< std::string >::iterator | names_end () const |
End iterator on vector names. More... | |
std::vector< std::string > | names () const |
Vector of names. More... | |
string_permutation | names_entity_begin (Entity_kind const on_what) const |
Begin iterator on vector names of specific entity type. More... | |
string_permutation | names_entity_end (Entity_kind const on_what) const |
End iterator on vector of names of specific entity type. More... | |
Detailed Description
Provides access to data stored in Jali_State.
Member Typedef Documentation
◆ string_permutation
typedef Jali::State::string_permutation Wonton::Jali_State_Wrapper::string_permutation |
Typedef for permutation iterator on vector of strings.
Constructor & Destructor Documentation
◆ Jali_State_Wrapper() [1/2]
|
inlineexplicit |
Constructor of Jali_State_Wrapper.
- Parameters
-
[in] jali_state A reference to a Jali::State instance
◆ Jali_State_Wrapper() [2/2]
|
inline |
Copy constructor of Jali_State_Wrapper - not a deep copy.
- Parameters
-
[in] state A reference to another Jali_State_Wrapper instance
◆ ~Jali_State_Wrapper()
|
inline |
Empty destructor.
Member Function Documentation
◆ add_material()
|
inline |
Add a material to state.
- Parameters
-
[in] matname Name of material [in] matcells Cells containing the material
NOTE: NOT ONLY DOES THIS ROUTINE ADD A MATERIAL AND ITS CELLS TO THE STATEMANAGER, IT ALSO MAKE SPACE FOR FIELD VALUES FOR THIS MATERIAL IN EVERY MULTI-MATERIAL VECTOR IN THE STATE MANAGER. THIS ENSURES THAT WHEN WE CALL mat_get_celldata FOR A MATERIAL IN MULTI-MATERIAL STATE VECTOR IT WILL ALWAYS HAVE SPACE ALLOCATED FOR FIELD VALUES OF THAT MATERIAL
◆ cell_get_mats()
|
inline |
Get the IDs of materials in a cell.
- Parameters
-
cellid Index of cell in mesh cellmats Indices of materials in cell
◆ cell_get_num_mats()
|
inline |
Get number of materials contained in a cell.
- Parameters
-
cellid Index of cell in mesh
- Returns
- Number of materials in cell
◆ cell_index_in_material()
|
inline |
Get the local index of mesh cell in material cell list.
- Parameters
-
meshcell Mesh cell ID matid Material ID
- Returns
- Local cell index in material cell list
◆ export_to_mesh()
|
inline |
Export fields to mesh file.
◆ field_type()
|
inline |
Type of field (MESH_FIELD or MULTIMATERIAL_FIELD)
- Parameters
-
onwhat Entity_kind that field is defined on varname Name of field
- Returns
- Field type
◆ get_data_size()
|
inline |
Get the data size for the given field.
- Parameters
-
[in] on_what The entity type on which the data field is defined [in] var_name The string name of the data field
- Returns
- The data size for the field with the given name on the given entity type
For multi-material state, this will give the number of materials for now
◆ get_data_type()
|
inline |
Get the data type of the given field.
- Parameters
-
[in] var_name The string name of the data field
- Returns
- A reference to the type_info struct for the field's data type
◆ get_entity()
|
inline |
Get the entity type on which the given field is defined.
- Parameters
-
[in] var_name The string name of the data field
- Returns
- The Entity_kind enum for the entity type on which the field is defined
◆ init_from_mesh()
|
inline |
Initialize fields from mesh file.
◆ mat_add_celldata() [1/4]
|
inline |
Add a scalar multi-valued data field on cells and initialize its material data to a single value.
- Parameters
-
[in] var_name The name of the data field [in] value Initialize 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.
This version of the overloaded operator is being DISABLED for pointer and array types (via the line 'typename std::enable_if....type') because template deduction rules are making the compiler invoke this version, when we call it with a const double ** pointer
See, stackoverflow.com Q&A
http://stackoverflow.com/questions/13665574/template-argument-deduction-and-pointers-to-constants
We could make it work for some cases using
template <class T, class DomainType, template<class, class> class StateVecType> auto add(........, T const& data) -> StateVecType<decltype(data+data), DomainType>&
but this does not work if T is a double[3] or std::array<double, 3> as there is no + operator defined for these types
◆ mat_add_celldata() [2/4]
|
inline |
Add a scalar multi-valued data field on cells and initialize its material data according to a 2D array.
- Parameters
-
[in] var_name The name of the data field [in] layout Whether 2D array is laid out with first index being the cell (CELL_CENRIC) or material (MATERIAL CENTRIC) [in] value Initialize 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]
|
inline |
Add a scalar multi-valued data field on cells and add data to one of its materials.
- Parameters
-
[in] var_name The name of the data field [in] matid Index of material in the problem [in] layout Data layout - [in] values Initialize 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]
|
inline |
Add a scalar multi-valued data field on cells and initialize one of its material data to a uniform value.
- Parameters
-
[in] var_name The name of the data field [in] matid Index of material in the problem [in] value Initialize with this value
Subsequent calls to this function with the same name will find the added field and just add the data.
Need to disable this call for deductions where T is a pointer; otherwise when we call mat_add_celldata with a pointer to a non-const type, this function is called by interpreting T as 'type ' (e.g. this overload is called with T = double *, instead of calling the pointer version with T = double)
See stackoverflow.com Q&A
http://stackoverflow.com/questions/13665574/template-argument-deduction-and-pointers-to-constants
◆ mat_add_cells()
|
inline |
Add cells to material (or add material to cells)
- Parameters
-
[in] matid Material ID [in] newcells Vector of new cells in material
◆ mat_get_celldata() [1/2]
|
inline |
Get pointer to read-only scalar cell data for a particular material.
- Parameters
-
[in] var_name The string name of the data field [in] matid Index (not unique identifier) of the material [out] data vector containing the values corresponding to cells in the material
◆ mat_get_celldata() [2/2]
|
inline |
Get pointer to read-write scalar data for a particular material.
- Parameters
-
[in] on_what The entity type on which to get the data [in] var_name The string name of the data field [in] matid Index (not unique identifier) of the material [out] data vector containing the values corresponding to cells in the material
Removing the constness of the template parameter allows us to call this function and get const data back (e.g. pointer to double const) even if the wrapper object is not const. The alternative is to make another overloaded operator that is non-const but returns a pointer to const data. Thanks StackOverflow!
◆ mat_get_cells()
|
inline |
Get cell indices containing a particular material.
- Parameters
-
matid Index of material (0, num_materials()-1) matcells Cells containing material 'matid'
◆ mat_get_num_cells()
|
inline |
Get number of cells containing a particular material.
- Parameters
-
matid Index of material (0, num_materials()-1)
- Returns
- Number of cells containing material 'matid'
◆ mat_rem_cells()
|
inline |
Remove cells from material (or remove material from cells)
- Parameters
-
[in] matid Material ID [in] matcells Vector of to be removed cells
◆ material_name()
|
inline |
Name of material.
◆ mesh_add_data() [1/2]
|
inline |
Add a scalar single valued data field.
- Parameters
-
[in] on_what The entity type on which the data is defined [in] var_name The name of the data field [in] values Initialize with this array of values
◆ mesh_add_data() [2/2]
|
inline |
Add a scalar single valued data field with uniform values.
- Parameters
-
[in] on_what The entity type on which the data is defined [in] var_name The name of the data field [in] value Initialize with this value
This version of the overloaded operator is being DISABLED for pointer and array types (via the line 'typename std::enable_if....type') because template deduction rules are making the compiler invoke this version, when we call it with a const double ** pointer
See, stackoverflow.com Q&A
http://stackoverflow.com/questions/13665574/template-argument-deduction-and-pointers-to-constants
We could make it work for some cases using
template <class T, class DomainType, template<class, class> class StateVecType> auto add(........, T const& data) -> StateVecType<decltype(data+data), DomainType>&
but this does not work if T is a double[3] or std::array<double, 3> as there is no + operator defined for these types
◆ mesh_get_data() [1/2]
|
inline |
Get a pointer to read-only single-valued data on the mesh.
- Parameters
-
[in] on_what The entity type on which to get the data [in] var_name The string name of the data field [in,out] data A vector containing the data
◆ mesh_get_data() [2/2]
|
inline |
Get a pointer to read-write single-valued data on the mesh.
- Parameters
-
[in] on_what The entity type on which to get the data [in] var_name The string name of the data field [in,out] data A vector containing the data
Removing the constness of the template parameter allows us to call this function and get const data back (e.g. pointer to double const) even if the wrapper object is not const. The alternative is to make another overloaded operator that is non-const but returns a pointer to const data. Thanks StackOverflow!
◆ names()
|
inline |
Vector of names.
- Returns
- vector of strings
◆ names_begin()
|
inline |
Begin iterator on vector names.
- Returns
- Begin iterator on vector of strings
◆ names_end()
|
inline |
End iterator on vector names.
- Returns
- End iterator on vector of strings
◆ names_entity_begin()
|
inline |
Begin iterator on vector names of specific entity type.
- Parameters
-
[in] on_what The desired entity type
- Returns
- Permutation iterator to start of string vector
◆ names_entity_end()
|
inline |
End iterator on vector of names of specific entity type.
- Parameters
-
[in] on_what The desired entity type
◆ num_materials()
|
inline |
Number of materials in problem.
◆ operator=()
|
delete |
Assignment operator (disabled) - don't know how to implement (RVG)
The documentation for this class was generated from the following file:
- /home/wonton/wonton/wonton/state/jali/jali_state_wrapper.h