A very light-weight state manager for a Simple_Mesh. More...
#include <simple_state.h>
Public Types | |
typedef std::vector< double > | vec |
Convenience types. More... | |
typedef vec::iterator | vec_it |
typedef std::vector< std::string > | name_vec |
typedef name_vec::iterator | name_vec_it |
typedef std::pair< std::string, Entity_kind > | key |
typedef std::map< key, vec > | mymap |
typedef mymap::iterator | map_it |
Public Member Functions | |
Simple_State (std::shared_ptr< Simple_Mesh > mesh) | |
Constructor for creating a Simple_State. More... | |
~Simple_State () | |
Destructor. More... | |
int | numVars () const |
The number of variables that live in the state manager. More... | |
map_it | begin () |
An iterator to the beginning of the field map. More... | |
map_it | end () |
An iterator to the ending of the field map. More... | |
name_vec_it | names_begin () |
An iterator to the beginning of the variable names vector. More... | |
name_vec_it | names_end () |
An iterator to the ending fo the variable names vector. More... | |
name_vec | names () const |
map_it | find (std::string const name, Entity_kind const on_what=Entity_kind::ANY_KIND) |
Search for a specific key (name, Entity_kind) within the map of known fields and return an iterator to its location. More... | |
vec & | add (std::string const name, Entity_kind const on_what, double const *const data=nullptr) |
Add a field to the state manager. More... | |
vec & | add (std::string const name, Entity_kind const on_what, double const val) |
Add a field to the state manager. More... | |
vec & | get (std::string const name, Entity_kind const on_what) |
Get a specific variable from the state manager. More... | |
Detailed Description
A very light-weight state manager for a Simple_Mesh.
This class stores double
(and only double
) data atop a Simple_Mesh. The data can be located at any mesh location (e.g. CELL
or NODE
) that Simple_Mesh understands. The field variables are stored in a map and are identified by key composed of a string name and an Entity_kind; for example, pair("pressure", CELL)
. The actual data corresponding to any field is stored as a std::vector of double's
.
In addition to the map, this class stores (and exposes) a vector containing just the string variable names.
Member Typedef Documentation
◆ key
typedef std::pair<std::string, Entity_kind> Wonton::Simple_State::key |
◆ map_it
typedef mymap::iterator Wonton::Simple_State::map_it |
◆ mymap
typedef std::map<key, vec> Wonton::Simple_State::mymap |
◆ name_vec
typedef std::vector<std::string> Wonton::Simple_State::name_vec |
◆ name_vec_it
typedef name_vec::iterator Wonton::Simple_State::name_vec_it |
◆ vec
typedef std::vector<double> Wonton::Simple_State::vec |
Convenience types.
◆ vec_it
typedef vec::iterator Wonton::Simple_State::vec_it |
Constructor & Destructor Documentation
◆ Simple_State()
|
inlineexplicit |
Constructor for creating a Simple_State.
- Parameters
-
[in] mesh A smart pointer to the Simple_Mesh where this data lives.
◆ ~Simple_State()
|
inline |
Destructor.
Member Function Documentation
◆ add() [1/2]
|
inline |
Add a field to the state manager.
- Parameters
-
[in] name The variable name of the field to be added. [in] on_what The Entity_kind (e.g. CELL) on which the data should live. [in] data A pointer to some data to initialize. This defaults to nullptr
, which allows you to not initialize any of the data, but the underlying std::vector will be sized appropriately.
- Returns
- A reference to the underlying std::vector for further modification/use.
If the requested variable (name
, on_what
) pair already exists, this will output a message to std::cerr, but will simply return the reference to the underlying std::vector.
◆ add() [2/2]
|
inline |
Add a field to the state manager.
- Parameters
-
[in] name The variable name of the field to be added. [in] on_what The Entity_kind (e.g. CELL) on which the data should live. [in] val A value with which to iniitalize the underlying std::vector data.
- Returns
- A reference to the underlying std::vector for further modification/use.
If the requested variable (name
, on_what
) pair already exists, this will output a message to std::cerr, but will simply return the reference to the underlying std::vector.
◆ begin()
|
inline |
An iterator to the beginning of the field map.
◆ end()
|
inline |
An iterator to the ending of the field map.
◆ find()
|
inline |
Search for a specific key (name, Entity_kind) within the map of known fields and return an iterator to its location.
- Parameters
-
[in] name The variable name we wish to find. [in] on_what The Entity_kind (e.g. CELL) where the data we wish to find lives.
- Returns
- An iterator to the location of the requested key in the map; if this is the same as Simple_State::end(), then the variable was not found in the map.
◆ get()
|
inline |
Get a specific variable from the state manager.
- Parameters
-
[in] name The variable name of the field to be retrieved. [in] on_what The Entity_kind (e.g. CELL) on whih the requested data lives.
- Returns
- A reference to the underlying std::vector of data for further modification/use.
- Exceptions
-
std::runtime_error The requested variable is not in the state manager.
◆ names()
|
inline |
The above iterator functions fail sometimes for optimized code, so here we allow access to the complete list of names.
◆ names_begin()
|
inline |
An iterator to the beginning of the variable names vector.
◆ names_end()
|
inline |
An iterator to the ending fo the variable names vector.
◆ numVars()
|
inline |
The number of variables that live in the state manager.
The documentation for this class was generated from the following file:
- /home/wonton/wonton/wonton/state/simple/simple_state.h