7 #ifndef WONTON_SIMPLE_STATE_H_ 8 #define WONTON_SIMPLE_STATE_H_ 49 explicit Simple_State(std::shared_ptr<Simple_Mesh> mesh) : mesh_(mesh) { }
55 int numVars()
const {
return names_.size(); }
58 typedef std::vector<double>
vec;
62 typedef std::pair<std::string, Entity_kind>
key;
63 typedef std::map<key, vec>
mymap;
67 map_it
begin() {
return state_vectors_.begin(); }
69 map_it
end() {
return state_vectors_.end(); }
78 name_vec
names()
const{
return names_;}
90 map_it
find(std::string
const name,
92 key testKey(name, on_what);
95 if ((it->first == testKey) ||
96 ((it->first.first == name) &&
121 double const *
const data =
nullptr) {
122 auto it =
find(name, on_what);
126 key thisKey(name, on_what);
127 if (data ==
nullptr) {
128 state_vectors_.insert(std::make_pair(thisKey,
131 state_vectors_.insert(std::make_pair(thisKey,
132 vec(data, data+num_ent)));
134 names_.emplace_back(name);
135 return state_vectors_[thisKey];
138 std::cerr <<
"Attempted to add duplicate vectors. Ignoring." 160 auto it =
find(name, on_what);
164 key thisKey(name, on_what);
165 state_vectors_.insert(std::make_pair(thisKey,
vec(num_ent, val)));
166 names_.emplace_back(name);
167 return state_vectors_[thisKey];
170 std::cerr <<
"Attempted to add duplicate vectors. Ignoring." 187 auto it =
find(name, on_what);
191 throw std::runtime_error(
"Couldn't find the requested variable.");
197 std::shared_ptr<Simple_Mesh> mesh_;
199 mymap state_vectors_;
206 #endif // WONTON_SIMPLE_STATE_H_ std::map< key, vec > mymap
Definition: simple_state.h:63
name_vec::iterator name_vec_it
Definition: simple_state.h:61
std::vector< std::string > name_vec
Definition: simple_state.h:60
A very light-weight state manager for a Simple_Mesh.
Definition: simple_state.h:43
std::vector< double > vec
Convenience types.
Definition: simple_state.h:58
Factorize a number N into D equal (or nearly equal) factors.
Definition: adaptive_refinement_mesh.h:31
vec::iterator vec_it
Definition: simple_state.h:59
std::pair< std::string, Entity_kind > key
Definition: simple_state.h:62
mymap::iterator map_it
Definition: simple_state.h:64
~Simple_State()
Destructor.
Definition: simple_state.h:52
name_vec names() const
Definition: simple_state.h:78
vec & add(std::string const name, Entity_kind const on_what, double const val)
Add a field to the state manager.
Definition: simple_state.h:158
vec & add(std::string const name, Entity_kind const on_what, double const *const data=nullptr)
Add a field to the state manager.
Definition: simple_state.h:120
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 t...
Definition: simple_state.h:90
map_it begin()
An iterator to the beginning of the field map.
Definition: simple_state.h:67
int numVars() const
The number of variables that live in the state manager.
Definition: simple_state.h:55
Entity_kind
The type of mesh entity.
Definition: wonton.h:81
name_vec_it names_end()
An iterator to the ending fo the variable names vector.
Definition: simple_state.h:74
Simple_State(std::shared_ptr< Simple_Mesh > mesh)
Constructor for creating a Simple_State.
Definition: simple_state.h:49
A very light-weight, simple mesh infrastructure.
map_it end()
An iterator to the ending of the field map.
Definition: simple_state.h:69
name_vec_it names_begin()
An iterator to the beginning of the variable names vector.
Definition: simple_state.h:72