Commit a97c2b28 authored by Lukas Riedel's avatar Lukas Riedel

Disable get_water_flux_reconstructed at compile-time

Use enable_if instead of throwing at run-time
parent 3d209140
...@@ -542,60 +542,57 @@ public: ...@@ -542,60 +542,57 @@ public:
* *
* @return Pointer to a (reconstructed) water flux grid function * @return Pointer to a (reconstructed) water flux grid function
*/ */
std::shared_ptr<const GFFluxReconstruction> get_water_flux_reconstructed(ConstState state) const template<bool enabled=enable_rt_engine>
std::enable_if_t<enabled, std::shared_ptr<const GFFluxReconstruction>>
get_water_flux_reconstructed(ConstState state) const
{ {
std::shared_ptr<GFFluxReconstruction> gf_ptr; std::shared_ptr<GFFluxReconstruction> gf_ptr;
auto& cache = cache_water_flux_gf_rt; auto& cache = cache_water_flux_gf_rt;
if constexpr (enable_rt_engine) if (state.grid_function_space != gfs
or state.coefficients != u
or state.time != current_time())
{ {
// if state is different to current state, create flux from zero
if (state.grid_function_space != gfs or gf_ptr = std::make_unique<GFFluxReconstruction>(
state.coefficients != u or this->_log,gv,inifile.sub("fluxReconstruction"));
state.time != current_time())
{ assert(fboundary);
// if state is different to current state, create flux from zero assert(fparam);
assert(slop);
gf_ptr = std::make_unique<GFFluxReconstruction>(
this->_log,gv,inifile.sub("fluxReconstruction")); slop->setTime(state.time);
assert(fboundary); // update it with the state
assert(fparam); gf_ptr->update(*(state.coefficients),
assert(slop); *(state.grid_function_space),
*slop);
slop->setTime(state.time);
slop->setTime(current_time());
// update it with the state }
gf_ptr->update(*(state.coefficients),
*(state.grid_function_space), // if state is equal to current state, use cache.
*slop); else if (not cache) {
slop->setTime(current_time()); cache = std::make_unique<GFFluxReconstruction>(
} else if (not cache) { this->_log,gv,inifile.sub("fluxReconstruction"));
// if state is equal to current state, use cache.
assert(fboundary);
cache = std::make_unique<GFFluxReconstruction>( assert(fparam);
this->_log,gv,inifile.sub("fluxReconstruction")); assert(slop);
assert(fboundary); // update it with current state
assert(fparam); cache->update(*u,*gfs,*slop);
assert(slop);
gf_ptr = cache;
// update it with current state
cache->update(*u,*gfs,*slop);
gf_ptr = cache;
} else {
gf_ptr = cache;
}
} else {
DUNE_THROW(NotImplemented,
"Flux reconstruction is not implemented for the selected "
<< "configuration");
} }
else {
gf_ptr = cache;
}
return gf_ptr; return gf_ptr;
} }
...@@ -604,10 +601,12 @@ public: ...@@ -604,10 +601,12 @@ public:
* *
* @return Pointer to a (reconstructed) water flux grid function * @return Pointer to a (reconstructed) water flux grid function
*/ */
std::shared_ptr<const GFFluxReconstruction> get_water_flux_reconstructed() const template<bool enabled=enable_rt_engine>
std::enable_if_t<enabled, std::shared_ptr<const GFFluxReconstruction>>
get_water_flux_reconstructed() const
{ {
return get_water_flux_reconstructed(current_state()); return get_water_flux_reconstructed(current_state());
} }
protected: protected:
......
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