Dune::Copasi
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Dune::Copasi::TimeStepper< State, TimeQuantity, DurationQuantity > Class Template Reference

Simple time stepper of one-step operators. More...

#include <stepper.hh>

Inheritance diagram for Dune::Copasi::TimeStepper< State, TimeQuantity, DurationQuantity >:
Inheritance graph
[legend]

Public Member Functions

 TimeStepper (std::function< TimeQuantity &(State &)> time_mut, std::function< const TimeQuantity &(const State &)> time_const)
 Construct a new time stepper.
 
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&>; }
 TimeStepper ()
 Construct a new time stepper.
 
 TimeStepper (const TimeStepper &)=delete
 
 TimeStepper (TimeStepper &&)=delete
 
TimeStepperoperator= (const TimeStepper &)=delete
 
TimeStepperoperator= (TimeStepper &&)=delete
 
virtual ~TimeStepper ()=default
 Time stepper destructor.
 
virtual PDELab::ErrorCondition do_step (PDELab::OneStep< State > &one_step, const State &in, State &out, DurationQuantity &dt) const
 Perform one step of the system.
 
PDELab::ErrorCondition 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
 Evolve the system until end_time
 
PDELab::ErrorCondition 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
 Snap the output to a specific time.
 

Detailed Description

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
TimeQuantityType representing time quantities
DurationQuantityType representing duration quantities
StateType representing states

Constructor & Destructor Documentation

◆ TimeStepper() [1/4]

template<std::copyable State, class TimeQuantity , class DurationQuantity >
Dune::Copasi::TimeStepper< State, TimeQuantity, DurationQuantity >::TimeStepper ( std::function< TimeQuantity &(State &)> time_mut,
std::function< const TimeQuantity &(const State &)> time_const )
inline

Construct a new time stepper.

Parameters
time_mutFunctor that obtains a mutable time quantity from a given state
time_constFunctor that obtains a constant time quantity from a given constant state

◆ TimeStepper() [2/4]

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&>; }
Dune::Copasi::TimeStepper< State, TimeQuantity, DurationQuantity >::TimeStepper ( )
inline

Construct a new time stepper.

◆ TimeStepper() [3/4]

template<std::copyable State, class TimeQuantity , class DurationQuantity >
Dune::Copasi::TimeStepper< State, TimeQuantity, DurationQuantity >::TimeStepper ( const TimeStepper< State, TimeQuantity, DurationQuantity > & )
delete

◆ TimeStepper() [4/4]

template<std::copyable State, class TimeQuantity , class DurationQuantity >
Dune::Copasi::TimeStepper< State, TimeQuantity, DurationQuantity >::TimeStepper ( TimeStepper< State, TimeQuantity, DurationQuantity > && )
delete

◆ ~TimeStepper()

template<std::copyable State, class TimeQuantity , class DurationQuantity >
virtual Dune::Copasi::TimeStepper< State, TimeQuantity, DurationQuantity >::~TimeStepper ( )
virtualdefault

Time stepper destructor.

Member Function Documentation

◆ do_step()

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_stepSystem that contain suitable operators to advance in time
inInput state to advance time from
outOutput state where result will be placed
dtMutable 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 >.

◆ evolve()

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_stepSystem that contain suitable operators to advance in time
inInput state to advance time from
outOutput state where result will be placed.
dtMutable delta time to perform step
end_timeFinal time that out state must reach
callableA function called with an state at the end of each successful step
snap_to_end_timeTrue if end_time must be reached exactly, otherwise it will be reached from below with the provided dt

◆ operator=() [1/2]

template<std::copyable State, class TimeQuantity , class DurationQuantity >
TimeStepper & Dune::Copasi::TimeStepper< State, TimeQuantity, DurationQuantity >::operator= ( const TimeStepper< State, TimeQuantity, DurationQuantity > & )
delete

◆ operator=() [2/2]

template<std::copyable State, class TimeQuantity , class DurationQuantity >
TimeStepper & Dune::Copasi::TimeStepper< State, TimeQuantity, DurationQuantity >::operator= ( TimeStepper< State, TimeQuantity, DurationQuantity > && )
delete

◆ snap_to_time()

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_stepSystem that contain suitable operators to advance in time.
dtSuggested delta time to reach snap time. It will be modified to reach snap time exactly.
snap_timeFinal time that out state must reach
callableA function called with an state at the end of each successful step

The documentation for this class was generated from the following file: