Wonton::Jali_State_Wrapper Class Reference

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_Wrapperoperator= (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]

Wonton::Jali_State_Wrapper::Jali_State_Wrapper ( Jali::State &  jali_state)
inlineexplicit

Constructor of Jali_State_Wrapper.

Parameters
[in]jali_stateA reference to a Jali::State instance

◆ Jali_State_Wrapper() [2/2]

Wonton::Jali_State_Wrapper::Jali_State_Wrapper ( Jali_State_Wrapper state)
inline

Copy constructor of Jali_State_Wrapper - not a deep copy.

Parameters
[in]stateA reference to another Jali_State_Wrapper instance

◆ ~Jali_State_Wrapper()

Wonton::Jali_State_Wrapper::~Jali_State_Wrapper ( )
inline

Empty destructor.

Member Function Documentation

◆ add_material()

void Wonton::Jali_State_Wrapper::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

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()

void Wonton::Jali_State_Wrapper::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()

int Wonton::Jali_State_Wrapper::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()

int Wonton::Jali_State_Wrapper::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

◆ export_to_mesh()

void Wonton::Jali_State_Wrapper::export_to_mesh ( )
inline

Export fields to mesh file.

◆ field_type()

Field_type Wonton::Jali_State_Wrapper::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()

int Wonton::Jali_State_Wrapper::get_data_size ( Entity_kind  on_what,
std::string const &  var_name 
) const
inline

Get the data size for the given field.

Parameters
[in]on_whatThe entity type on which the data field is defined
[in]var_nameThe 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()

const std::type_info& Wonton::Jali_State_Wrapper::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()

Entity_kind Wonton::Jali_State_Wrapper::get_entity ( const std::string  var_name) const
inline

Get the entity type on which the given field is defined.

Parameters
[in]var_nameThe string name of the data field
Returns
The Entity_kind enum for the entity type on which the field is defined

◆ init_from_mesh()

void Wonton::Jali_State_Wrapper::init_from_mesh ( )
inline

Initialize fields from mesh file.

◆ mat_add_celldata() [1/4]

template<class T >
std::enable_if<(!std::is_pointer<T>::value && !std::is_array<T>::value), void>::type Wonton::Jali_State_Wrapper::mat_add_celldata ( std::string const &  var_name,
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.

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]

template<class T >
void Wonton::Jali_State_Wrapper::mat_add_celldata ( std::string const &  var_name,
T 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 T >
void Wonton::Jali_State_Wrapper::mat_add_celldata ( std::string const &  var_name,
int  matid,
T 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 T >
std::enable_if<(!std::is_pointer<T>::value && !std::is_array<T>::value), void>::type Wonton::Jali_State_Wrapper::mat_add_celldata ( std::string const &  var_name,
int  matid,
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.

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()

void Wonton::Jali_State_Wrapper::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/2]

template<class T >
void Wonton::Jali_State_Wrapper::mat_get_celldata ( std::string const &  var_name,
int  matid,
T 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/2]

template<class T >
void Wonton::Jali_State_Wrapper::mat_get_celldata ( std::string const &  var_name,
int  matid,
T **  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

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()

void Wonton::Jali_State_Wrapper::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()

int Wonton::Jali_State_Wrapper::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()

void Wonton::Jali_State_Wrapper::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()

std::string Wonton::Jali_State_Wrapper::material_name ( int  matid) const
inline

Name of material.

◆ mesh_add_data() [1/2]

template<class T >
void Wonton::Jali_State_Wrapper::mesh_add_data ( Entity_kind  on_what,
std::string const &  var_name,
T const *const  values 
)
inline

Add a scalar single valued data field.

Parameters
[in]on_whatThe entity type on which the data is defined
[in]var_nameThe name of the data field
[in]valuesInitialize with this array of values

◆ mesh_add_data() [2/2]

template<class T >
std::enable_if<(!std::is_pointer<T>::value && !std::is_array<T>::value), void>::type Wonton::Jali_State_Wrapper::mesh_add_data ( Entity_kind  on_what,
std::string const &  var_name,
const T  value 
)
inline

Add a scalar single valued data field with uniform values.

Parameters
[in]on_whatThe entity type on which the data is defined
[in]var_nameThe name of the data field
[in]valueInitialize 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]

template<class T >
void Wonton::Jali_State_Wrapper::mesh_get_data ( Entity_kind  on_what,
std::string const &  var_name,
T const **  data 
) const
inline

Get a pointer to read-only single-valued data on the mesh.

Parameters
[in]on_whatThe entity type on which to get the data
[in]var_nameThe string name of the data field
[in,out]dataA vector containing the data

◆ mesh_get_data() [2/2]

template<class T >
void Wonton::Jali_State_Wrapper::mesh_get_data ( Entity_kind  on_what,
std::string const &  var_name,
T **  data 
)
inline

Get a pointer to read-write single-valued data on the mesh.

Parameters
[in]on_whatThe entity type on which to get the data
[in]var_nameThe string name of the data field
[in,out]dataA 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()

std::vector<std::string> Wonton::Jali_State_Wrapper::names ( ) const
inline

Vector of names.

Returns
vector of strings

◆ names_begin()

std::vector<std::string>::iterator Wonton::Jali_State_Wrapper::names_begin ( ) const
inline

Begin iterator on vector names.

Returns
Begin iterator on vector of strings

◆ names_end()

std::vector<std::string>::iterator Wonton::Jali_State_Wrapper::names_end ( ) const
inline

End iterator on vector names.

Returns
End iterator on vector of strings

◆ names_entity_begin()

string_permutation Wonton::Jali_State_Wrapper::names_entity_begin ( Entity_kind const  on_what) const
inline

Begin iterator on vector names of specific entity type.

Parameters
[in]on_whatThe desired entity type
Returns
Permutation iterator to start of string vector

◆ names_entity_end()

string_permutation Wonton::Jali_State_Wrapper::names_entity_end ( Entity_kind const  on_what) const
inline

End iterator on vector of names of specific entity type.

Parameters
[in]on_whatThe desired entity type

◆ num_materials()

int Wonton::Jali_State_Wrapper::num_materials ( ) const
inline

Number of materials in problem.

◆ operator=()

Jali_State_Wrapper& Wonton::Jali_State_Wrapper::operator= ( Jali_State_Wrapper const &  )
delete

Assignment operator (disabled) - don't know how to implement (RVG)


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