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,18 +542,17 @@ public:
*
* @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;
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.grid_function_space != gfs
or state.coefficients != u
or state.time != current_time())
{
// if state is different to current state, create flux from zero
......@@ -572,8 +571,10 @@ public:
*slop);
slop->setTime(current_time());
} else if (not cache) {
}
// if state is equal to current state, use cache.
else if (not cache) {
cache = std::make_unique<GFFluxReconstruction>(
this->_log,gv,inifile.sub("fluxReconstruction"));
......@@ -585,15 +586,11 @@ public:
// 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;
......@@ -604,7 +601,9 @@ public:
*
* @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());
}
......
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