Introduce Model::pre_step() method to set boundary condition times independently from step computation
In the coupled model, the flux reconstruction at the begin of the step uses the previous boundary conditions, but that currently does not matter because we apply the NextStep
policy when evaluating it.
Description
During the Model::step()
method, the Richards model applies the current start time to its boundary condition manager to retrieve the correct BCs during the step. Before calling step()
, the boundary condition manager therefore applies the boundary conditions of the previous step.
Proposal
Extend the base Model
interface with a virtual pre_step()
method which does nothing by default. Override this method in the Richards model to apply the current time to the boundary condition manager. Additionally, the flux reconstruction cache can be reset in this method rather than at the end of step()
.
Within the coupled model, call pre_step()
on the Richards model before fetching the water flux reconstruction, such that the current boundary conditions are correctly applied. Then, call step()
and retrieve the second reconstruction. See above for an
Additionally, raise a warning in the Richards model if step()
is called without calling pre_step()
before.
void ModelRichardsTransportCoupling<Traits>::step()
{
// ... //
// NOTE: Proposal. Make sure the boundary condition manager returns the BCs for this time step
//_richards->pre_step();
// set initial state of the water flux to container
auto gf_water_flux_begin = _richards->get_water_flux_reconstructed();
igf_water_flux->push(gf_water_flux_begin,time_begin);
// ^----- Currently applies the old BC for this time
// always do an step of richards
_richards->step();
// ^----- Currently enables the correct BCs for this step
// ... //
// set final state of the water flux to container
auto gf_water_flux_end = _richards->get_water_flux_reconstructed();
igf_water_flux->push(gf_water_flux_end,time_end);
// ^----- Applies the correct BC for this time
// ... //
How to test the implementation?
- Extend
test-model-base
to check ifpre_step()
is called duringrun()
.