[Richards] Use non-const parameterization within the simulation class

* In order to ensure const-correctness, we instead copy the whole parameterization into a new shared pointer whenever a state is being exported.
parent 101ef971
......@@ -48,7 +48,7 @@ RichardsSimulation<Traits>::RichardsSimulation (
// --- Create the new parameter class
auto element_map = _grid_creator.element_index_map();
fparam = std::make_shared<const FlowParameters>(inifile, grid, element_map);
fparam = std::make_shared<FlowParameters>(inifile, grid, element_map);
// --- Operator Helper Classes ---
fboundary = std::make_shared<const FlowBoundary>(inifile);
......
......@@ -293,7 +293,7 @@ protected:
std::shared_ptr<LSGFS> lsgfs;
std::shared_ptr<LSCC> lscc;
std::shared_ptr<const FlowParameters> fparam;
std::shared_ptr<FlowParameters> fparam;
std::shared_ptr<const FlowBoundary> fboundary;
std::shared_ptr<const FlowSource> fsource;
std::unique_ptr<FlowInitial> finitial;
......@@ -425,7 +425,7 @@ public:
*/
std::shared_ptr<const GFMatricHead> get_matric_head(ConstState state) const
{
return std::make_shared<const GFMatricHead>(state.grid_function_space,state.coefficients);
return std::make_shared<GFMatricHead>(state.grid_function_space,state.coefficients);
}
/*------------------------------------------------------------------------*//**
......@@ -445,7 +445,11 @@ public:
*/
std::shared_ptr<const GFConductivity> get_conductivity(ConstState state) const
{
return std::make_shared<const GFConductivity>(gv, fparam);
// hard copy of parameters
auto _fparam = std::make_shared<FlowParameters>(*fparam);
// create conductivity adapter
return std::make_shared<GFConductivity>(gv, _fparam);
}
/*------------------------------------------------------------------------*//**
......@@ -465,7 +469,11 @@ public:
*/
std::shared_ptr<const GFWaterContent> get_water_content(ConstState state) const
{
return std::make_shared<const GFWaterContent>(get_matric_head(state), gv, fparam);
// hard copy of parameters
auto _fparam = std::make_shared<FlowParameters>(*fparam);
// create water content adapter
return std::make_shared<GFWaterContent>(get_matric_head(state), gv, _fparam);
}
/*------------------------------------------------------------------------*//**
......@@ -485,7 +493,11 @@ public:
*/
std::shared_ptr<const GFSaturation> get_saturation(ConstState state) const
{
return std::make_shared<const GFSaturation>(get_matric_head(state), gv, fparam);
// hard copy of parameters
auto _fparam = std::make_shared<FlowParameters>(*fparam);
// create saturation adapter
return std::make_shared<GFSaturation>(get_matric_head(state), gv, _fparam);
}
/*------------------------------------------------------------------------*//**
......@@ -505,7 +517,11 @@ public:
*/
std::shared_ptr<const GFWaterFlux> get_water_flux(ConstState state) const
{
return std::make_shared<const GFWaterFlux>(state.grid_function_space, state.coefficients, fparam);
// hard copy of parameters
auto _fparam = std::make_shared<FlowParameters>(*fparam);
// create water flux adapter
return std::make_shared<GFWaterFlux>(state.grid_function_space, state.coefficients, _fparam);
}
/*------------------------------------------------------------------------*//**
......@@ -545,6 +561,7 @@ public:
this->_log,gv,inifile.sub("fluxReconstruction"));
assert(fboundary);
assert(fparam);
assert(slop);
slop->setTime(state.time);
......@@ -562,6 +579,7 @@ public:
this->_log,gv,inifile.sub("fluxReconstruction"));
assert(fboundary);
assert(fparam);
assert(slop);
// update it with current state
......
......@@ -445,7 +445,7 @@ public:
*/
std::shared_ptr<const GFSolute> get_solute(ConstState state) const
{
return std::make_shared<const GFSolute>(state.grid_function_space,state.coefficients);
return std::make_shared<GFSolute>(state.grid_function_space,state.coefficients);
}
/*------------------------------------------------------------------------*//**
......@@ -472,7 +472,7 @@ public:
_water_content_gf->setTime(state.time);
_water_content_gf->shrink_to_time();
return std::make_shared<const GFTotalSolute>(solute_gf, _water_content_gf);
return std::make_shared<GFTotalSolute>(solute_gf, _water_content_gf);
}
/*------------------------------------------------------------------------*//**
......
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