Commit 38de83d1 authored by Lukas Riedel's avatar Lukas Riedel 📝

Disable get_solute_flux_reconstructed at compile-time

Use enable_if instead of run-time exception.
parent 4f660b1e
......@@ -471,56 +471,49 @@ public:
*
* @return Pointer to a solute grid function
*/
std::shared_ptr<const GFFluxReconstruction> get_solute_flux_reconstructed(ConstState state) const
template<bool enabled=enable_rt_engine>
std::enable_if_t<enabled, std::shared_ptr<const GFFluxReconstruction>>
get_solute_flux_reconstructed(ConstState state) const
{
std::shared_ptr<GFFluxReconstruction> gf_ptr;
auto& cache = cache_solute_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
state.coefficients != u or
state.time != current_time())
{
// if state is different to current state, create flux from zero
gf_ptr = std::make_unique<GFFluxReconstruction>(
this->_log,gv,inifile.sub("fluxReconstruction"));
gf_ptr = std::make_unique<GFFluxReconstruction>(
this->_log,gv,inifile.sub("fluxReconstruction"));
slop->setTime(state.time);
slop->setTime(state.time);
// update it with the state
gf_ptr->update(*(state.coefficients),
*(state.grid_function_space),
*slop);
// update it with the state
gf_ptr->update(*(state.coefficients),
*(state.grid_function_space),
*slop);
slop->setTime(current_time());
} else if (not cache) {
// if state is equal to current state, use cache.
slop->setTime(current_time());
} else if (not cache) {
// if state is equal to current state, use cache.
cache = std::make_unique<GFFluxReconstruction>(
this->_log,gv,inifile.sub("fluxReconstruction"));
slop->setTime(state.time);
cache = std::make_unique<GFFluxReconstruction>(
this->_log,gv,inifile.sub("fluxReconstruction"));
// update it with current state
cache->update(*u,*gfs,*slop);
slop->setTime(state.time);
slop->setTime(current_time());
// update it with current state
cache->update(*u,*gfs,*slop);
gf_ptr = cache;
} else {
gf_ptr = cache;
}
slop->setTime(current_time());
gf_ptr = cache;
} else {
DUNE_THROW(NotImplemented,
"Flux reconstruction is not implemented for the selected "
<< "configuration");
gf_ptr = cache;
}
return gf_ptr;
}
......@@ -529,7 +522,9 @@ public:
*
* @return Pointer to a solute grid function
*/
std::shared_ptr<const GFFluxReconstruction> get_solute_flux_reconstructed() const
template<bool enabled=enable_rt_engine>
std::enable_if_t<enabled, std::shared_ptr<const GFFluxReconstruction>>
get_solute_flux_reconstructed() const
{
return get_solute_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