Discontinuous Galerkin Library
#include "dg/algorithm.h"

Integrate using a for loop and a fixed non-changeable time-step. More...

Inheritance diagram for dg::MultistepTimeloop< ContainerType >:
[legend]

Public Types

using container_type = ContainerType
 
using value_type = dg::get_value_type< ContainerType >
 
- Public Types inherited from dg::aTimeloop< ContainerType >
using value_type = dg::get_value_type< ContainerType >
 
using container_type = ContainerType
 

Public Member Functions

 MultistepTimeloop ()=default
 no allocation More...
 
 MultistepTimeloop (std::function< void(value_type &, ContainerType &)> step, value_type dt)
 Construct using a std::function. More...
 
template<class Stepper , class ODE >
 MultistepTimeloop (Stepper &&stepper, ODE &&ode, value_type t0, const ContainerType &u0, value_type dt)
 Initialize and bind the step function of a Multistep stepper. More...
 
template<class ... Params>
void construct (Params &&...ps)
 Perfect forward parameters to one of the constructors. More...
 
virtual MultistepTimeloopclone () const
 Abstract copy method that returns a copy of *this on the heap. More...
 
- Public Member Functions inherited from dg::aTimeloop< ContainerType >
void integrate (value_type t0, const ContainerType &u0, value_type t1, ContainerType &u1)
 Integrate a differential equation between given bounds. More...
 
void integrate (value_type &t0, const ContainerType &u0, value_type t1, ContainerType &u1, enum to mode)
 Build your own timeloop. More...
 
value_type get_dt () const
 The current timestep. More...
 
virtual aTimeloopclone () const =0
 Abstract copy method that returns a copy of *this on the heap. More...
 
virtual ~aTimeloop ()
 

Additional Inherited Members

- Protected Member Functions inherited from dg::aTimeloop< ContainerType >
 aTimeloop ()
 empty More...
 
 aTimeloop (const aTimeloop &)
 empty More...
 
aTimeloopoperator= (const aTimeloop &)
 return *this More...
 

Detailed Description

template<class ContainerType>
struct dg::MultistepTimeloop< ContainerType >

Integrate using a for loop and a fixed non-changeable time-step.

The implementation (of integrate) is equivalent to

dg::blas1::copy( u0, u1);
unsigned N = round((t1 - t0)/dt);
for( unsigned i=0; i<N; i++)
step( t0, u1);
void copy(const ContainerTypeIn &source, ContainerTypeOut &target)
Definition: blas1.h:164

where dt is a given constant. t1 can only be matched exactly if the timestep evenly divides the given interval.

Note
the difference to dg::SinglestepTimeloop is the way the step function is called and the fact that dt cannot be changed
See also
AdaptiveTimeloop, SinglestepTimeloop
Template Parameters
ContainerTypeAny class for which a specialization of TensorTraits exists and which fulfills the requirements of the there defined data and execution policies derived from AnyVectorTag and AnyPolicyTag. Among others
  • dg::HVec (serial), dg::DVec (cuda / omp), dg::MHVec (mpi + serial) or dg::MDVec (mpi + cuda / omp)
  • std::vector<dg::DVec> (vector of shared device vectors), std::array<double, 4> (array of 4 doubles) or std::map < std::string, dg::DVec> ( a map of named vectors)
  • double (scalar) and other primitive types ...
If there are several ContainerTypes in the argument list, then TensorTraits must exist for all of them
See also
See The dg dispatch system for a detailed explanation of our type dispatch system

Member Typedef Documentation

◆ container_type

template<class ContainerType >
using dg::MultistepTimeloop< ContainerType >::container_type = ContainerType

◆ value_type

template<class ContainerType >
using dg::MultistepTimeloop< ContainerType >::value_type = dg::get_value_type<ContainerType>

Constructor & Destructor Documentation

◆ MultistepTimeloop() [1/3]

template<class ContainerType >
dg::MultistepTimeloop< ContainerType >::MultistepTimeloop ( )
default

no allocation

◆ MultistepTimeloop() [2/3]

template<class ContainerType >
dg::MultistepTimeloop< ContainerType >::MultistepTimeloop ( std::function< void(value_type &, ContainerType &)>  step,
value_type  dt 
)
inline

Construct using a std::function.

Parameters
stepCalled in the timeloop as step( t0, u1) . Has to advance the ode in-place by dt
dtThe constant timestep. Can be set later with set_dt. Can be negative.

◆ MultistepTimeloop() [3/3]

template<class ContainerType >
template<class Stepper , class ODE >
dg::MultistepTimeloop< ContainerType >::MultistepTimeloop ( Stepper &&  stepper,
ODE &&  ode,
value_type  t0,
const ContainerType &  u0,
value_type  dt 
)
inline

Initialize and bind the step function of a Multistep stepper.

First call stepper.init(). Then construct a lambda function that calls the step function of stepper with given parameters and stores it internally in a std::function

Template Parameters
Stepperpossible steppers are for example dg::ExplicitMultistep, dg::ImplicitMultistep or dg::ImExMultistep
Parameters
stepperIf constructed in-place (rvalue), will be copied into the lambda. If an lvalue, then the lambda stores a reference
Attention
If stepper is an lvalue then you need to make sure that stepper remains valid to avoid a "dangling reference"
Template Parameters
ODEThe ExplicitRHS or tuple type that corresponds to what is inserted into the step member of the Stepper
Parameters
oderhs or tuple
t0The initial time (forwarded to stepper.init( ode, t0, u0, dt) )
u0The initial condition (forwarded to stepper.init( ode, t0, u0, dt) )
dtThe constant timestep. Can be negative. Cannot be changed as changing it would require to re-init the multistep stepper (which is hidden in the lambda). (forwarded to stepper.init( ode, t0, u0, dt) )

Member Function Documentation

◆ clone()

template<class ContainerType >
virtual MultistepTimeloop * dg::MultistepTimeloop< ContainerType >::clone ( ) const
inlinevirtual

Abstract copy method that returns a copy of *this on the heap.

Returns
a copy of *this on the heap
See also
dg::ClonePtr

Implements dg::aTimeloop< ContainerType >.

◆ construct()

template<class ContainerType >
template<class ... Params>
void dg::MultistepTimeloop< ContainerType >::construct ( Params &&...  ps)
inline

Perfect forward parameters to one of the constructors.

Template Parameters
Paramsdeduced by the compiler
Parameters
psparameters forwarded to constructors

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