template<std::copyable State, class TimeQuantity, class DurationQuantity>
class Dune::Copasi::TimeStepper< State, TimeQuantity, DurationQuantity >
Simple time stepper of one-step operators.
The polymorphic method do_step
advances one time step from input to output state with a given duration. Then, this class is able to evolve a system until a final time.
- Template Parameters
-
TimeQuantity | Type representing time quantities |
DurationQuantity | Type representing duration quantities |
State | Type representing states |
template<std::copyable State, class TimeQuantity , class DurationQuantity >
template<std::same_as< void > = void>
requires requires(const State& cstate, State& mstate) { { cstate.time } -> std::convertible_to<const TimeQuantity&>; { mstate.time } -> std::convertible_to<TimeQuantity&>; }
Construct a new time stepper.
template<std::copyable State, class TimeQuantity , class DurationQuantity >
virtual PDELab::ErrorCondition Dune::Copasi::TimeStepper< State, TimeQuantity, DurationQuantity >::do_step |
( |
PDELab::OneStep< State > & |
one_step, |
|
|
const State & |
in, |
|
|
State & |
out, |
|
|
DurationQuantity & |
dt |
|
) |
| const |
|
inlinevirtual |
Perform one step of the system.
The input state is advanced a delta time dt
and placed in out
state.
- Parameters
-
one_step | System that contain suitable operators to advance in time |
in | Input state to advance time from |
out | Output state where result will be placed |
dt | Mutable delta time to perform step |
- Returns
- error condition describing the reason of (not) convergence of the timestep
Reimplemented in Dune::Copasi::SimpleAdaptiveStepper< State, TimeQuantity, DurationQuantity >.
template<std::copyable State, class TimeQuantity , class DurationQuantity >
PDELab::ErrorCondition Dune::Copasi::TimeStepper< State, TimeQuantity, DurationQuantity >::evolve |
( |
PDELab::OneStep< State > & |
one_step, |
|
|
const State & |
in, |
|
|
State & |
out, |
|
|
DurationQuantity & |
dt, |
|
|
TimeQuantity |
end_time, |
|
|
std::function< void(const State &)> |
callable = [](const State&) {} , |
|
|
bool |
snap_to_end_time = true |
|
) |
| const |
|
inline |
Evolve the system until end_time
The input state is advanced by time steps dt
to approach end_time
. The application of each timestep is performed using the polymorphic do_step
method, which may adapt the timestep dt
dynamically.
- Parameters
-
one_step | System that contain suitable operators to advance in time |
in | Input state to advance time from |
out | Output state where result will be placed. |
dt | Mutable delta time to perform step |
end_time | Final time that out state must reach |
callable | A function called with an state at the end of each successful step |
snap_to_end_time | True if end_time must be reached exactly, otherwise it will be reached from below with the provided dt |
template<std::copyable State, class TimeQuantity , class DurationQuantity >
PDELab::ErrorCondition Dune::Copasi::TimeStepper< State, TimeQuantity, DurationQuantity >::snap_to_time |
( |
PDELab::OneStep< State > & |
one_step, |
|
|
const State & |
in, |
|
|
State & |
out, |
|
|
DurationQuantity & |
dt, |
|
|
TimeQuantity |
snap_time, |
|
|
std::function< void(const State &)> |
callable = [](const State&) {} |
|
) |
| const |
|
inline |
Snap the output to a specific time.
This method is used to advance towards a snap_time avoiding very small timesteps. It work best if the snap time is a couple of timesteps ahead of the suggested dt. It differs from evolve in that the steps might be done with a suitable stepper for wider range of timesteps.
- Parameters
-
one_step | System that contain suitable operators to advance in time. |
dt | Suggested delta time to reach snap time. It will be modified to reach snap time exactly. |
snap_time | Final time that out state must reach |
callable | A function called with an state at the end of each successful step |