[Richards] Allow parameterization to be modified when is not const

parent ab1f8d7d
......@@ -72,11 +72,13 @@ private:
/// Storage for parameters and skaling factors
using ParameterStorage = std::unordered_map<Index,
const std::tuple<const std::shared_ptr<const Parameterization>, const Scaling>
std::tuple<std::shared_ptr<Parameterization>, Scaling>
>;
/// Need this gruesome typedef because 'map::value_type' has const key
using Cache = std::tuple<std::shared_ptr<const Parameterization>, Scaling>;
using Cache = std::tuple<std::shared_ptr<Parameterization>, Scaling>;
using ConstCache = std::tuple<const std::shared_ptr<const Parameterization>, const Scaling>;
/// Configuration file tree
const Dune::ParameterTree& _config;
/// Grid view of the coarsest grid configuration (level 0)
......@@ -97,7 +99,7 @@ private:
/// Check if an entity has been cached
void verify_cache () const
{
if (not std::get<std::shared_ptr<const Parameterization>>(_cache)) {
if (not std::get<std::shared_ptr<Parameterization>>(_cache)) {
_log->error("Parameterization cache is empty. Call 'bind' before "
"accessing the cache or the parameterization");
DUNE_THROW(Dune::InvalidStateException,
......@@ -133,7 +135,14 @@ public:
const Vector& gravity() const { return _gravity; }
/// Return the current cache
const Cache& cache() const
const ConstCache& cache() const
{
verify_cache();
return _cache;
}
/// Return the current cache
const Cache& cache()
{
verify_cache();
return _cache;
......@@ -165,7 +174,7 @@ public:
{
verify_cache();
const auto& par =
std::get<std::shared_ptr<const Parameterization>>(_cache);
std::get<std::shared_ptr<Parameterization>>(_cache);
const auto cond_f = par->conductivity_f();
using Saturation = typename Parameterization::Saturation;
......@@ -185,7 +194,7 @@ public:
{
verify_cache();
const auto& par =
std::get<std::shared_ptr<const Parameterization>>(_cache);
std::get<std::shared_ptr<Parameterization>>(_cache);
const auto sat_f = par->saturation_f();
using MatricHead = typename Parameterization::MatricHead;
......@@ -205,7 +214,7 @@ public:
{
verify_cache();
const auto& par =
std::get<std::shared_ptr<const Parameterization>>(_cache);
std::get<std::shared_ptr<Parameterization>>(_cache);
// get water content function and apply the scaling
const auto& scale_por = std::get<Scaling>(_cache).scale_por;
......@@ -257,12 +266,12 @@ private:
/// Read the YAML parameter file and insert information into a map.
/** \param param_file The top YAML node to read from (file root)
*/
std::map<int, std::shared_ptr<const Parameterization>> read_parameter_file (
std::map<int, std::shared_ptr<Parameterization>> read_parameter_file (
const YAML::Node& param_file
)
{
// mapping: index on grid to parameterization object (will be returned)
std::map<int, std::shared_ptr<const Parameterization>> ret;
std::map<int, std::shared_ptr<Parameterization>> ret;
// set to check for duplicate indices
std::set<int> param_index_set;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment