Skip to content

Commit 1db4bc8

Browse files
committed
Add RBParameters::get_extra_step_value()
Initially I did not think I would need full multi-step support for getting the "extra" parameters, but it turns out we do, so I'm adding it now.
1 parent e8f0b6c commit 1db4bc8

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

include/reduced_basis/rb_parameters.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,14 @@ class RBParameters
198198
* Get the value of the specified parameter at the specified step,
199199
* throwing an error if it does not exist.
200200
*/
201-
Real get_step_value(const std::string & param_name, std::size_t index) const;
201+
Real get_step_value(const std::string & param_name, std::size_t step) const;
202202

203203
/**
204204
* Get the value of the specified parameter at the specified step,
205205
* returning the provided default value if either the parameter is
206206
* not defined or the step is invalid.
207207
*/
208-
Real get_step_value(const std::string & param_name, std::size_t index, const Real & default_val) const;
208+
Real get_step_value(const std::string & param_name, std::size_t step, const Real & default_val) const;
209209

210210
/**
211211
* Set the value of the specified parameter. If param_name
@@ -244,6 +244,19 @@ class RBParameters
244244
*/
245245
Real get_extra_value(const std::string & param_name, const Real & default_val) const;
246246

247+
/**
248+
* Get the value of the specified "extra" parameter at the specified step,
249+
* throwing an error if it does not exist.
250+
*/
251+
Real get_extra_step_value(const std::string & param_name, std::size_t step) const;
252+
253+
/**
254+
* Get the value of the specified extra parameter at the specified step,
255+
* returning the provided default value if either the parameter is
256+
* not defined or the step is invalid.
257+
*/
258+
Real get_extra_step_value(const std::string & param_name, std::size_t step, const Real & default_val) const;
259+
247260
/**
248261
* Set the value of the specified extra parameter. If param_name
249262
* doesn't already exist, it is added to the extra parameters.

src/reduced_basis/rb_parameters.C

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,20 @@ Real RBParameters::get_extra_value(const std::string & param_name, const Real &
154154
return ((it != _extra_parameters.end() && it->second.size() != 0) ? it->second[0] : default_val);
155155
}
156156

157+
Real RBParameters::get_extra_step_value(const std::string & param_name, std::size_t step) const
158+
{
159+
const auto & vec = libmesh_map_find(_extra_parameters, param_name);
160+
libmesh_error_msg_if(step >= vec.size(), "Error getting value for parameter " << param_name);
161+
return vec[step];
162+
}
163+
164+
Real RBParameters::get_extra_step_value(const std::string & param_name, std::size_t step, const Real & default_val) const
165+
{
166+
// same as get_step_value(param_name, index, default_val) but for the map of extra parameters
167+
auto it = _extra_parameters.find(param_name);
168+
return ((it != _extra_parameters.end() && step < it->second.size()) ? it->second[step] : default_val);
169+
}
170+
157171
void RBParameters::set_extra_value(const std::string & param_name, Real value)
158172
{
159173
// Same as set_value(param_name, value) but for the map of extra parameters

0 commit comments

Comments
 (0)