Gyselalib++
 
Loading...
Searching...
No Matches
RK2< FieldMem, DerivFieldMem, ExecSpace > Class Template Reference

A class which provides an implementation of a second-order Runge-Kutta method. More...

Inheritance diagram for RK2< FieldMem, DerivFieldMem, ExecSpace >:
ITimeStepper< FieldMem, DerivFieldMem, ExecSpace >

Public Types

using IdxRange = typename FieldMem::discrete_domain_type
 The type of the index range on which the values of the function are defined.
 
using ValConstField = typename FieldMem::view_type
 The constant type of the values of the function being evolved.
 
using ValField = typename FieldMem::span_type
 The type of the values of the function being evolved.
 
using DerivConstField = typename DerivFieldMem::view_type
 The constant type of the derivatives values of the function being evolved.
 
using DerivField = typename DerivFieldMem::span_type
 The type of the derivatives of the function being evolved.
 
- Public Types inherited from ITimeStepper< FieldMem, DerivFieldMem, ExecSpace >
using IdxRange = typename FieldMem::discrete_domain_type
 The type of the index range on which the values of the function are defined.
 
using ValField = typename FieldMem::span_type
 The type of the values of the function being evolved.
 
using ValConstField = typename FieldMem::view_type
 The constant type of the values of the function being evolved.
 
using DerivField = typename DerivFieldMem::span_type
 The type of the derivatives of the function being evolved.
 
using DerivConstField = typename DerivFieldMem::view_type
 The constant type of the derivatives values of the function being evolved.
 

Public Member Functions

 RK2 (IdxRange idx_range)
 Create a RK2 object.
 
void update (ExecSpace const &exec_space, ValField y, double dt, std::function< void(DerivField, ValConstField)> dy_calculator, std::function< void(ValField, DerivConstField, double)> y_update) const final
 Carry out one step of the Runge-Kutta scheme.
 
void update (ValField y, double dt, std::function< void(DerivField, ValConstField)> dy_calculator) const
 Carry out one step of the timestepping scheme.
 
void update (ExecSpace const &exec_space, ValField y, double dt, std::function< void(DerivField, ValConstField)> dy_calculator) const
 Carry out one step of the timestepping scheme.
 
virtual void update (ExecSpace const &exec_space, ValField y, double dt, std::function< void(DerivField, ValConstField)> dy_calculator, std::function< void(ValField, DerivConstField, double)> y_update) const=0
 Carry out one step of the timestepping scheme.
 
- Public Member Functions inherited from ITimeStepper< FieldMem, DerivFieldMem, ExecSpace >
void update (ValField y, double dt, std::function< void(DerivField, ValConstField)> dy_calculator) const
 Carry out one step of the timestepping scheme.
 
void update (ExecSpace const &exec_space, ValField y, double dt, std::function< void(DerivField, ValConstField)> dy_calculator) const
 Carry out one step of the timestepping scheme.
 
template<class FieldType , class FuncType , std::size_t n_args>
void assemble_field_k_total (ExecSpace const &exec_space, FieldType k_total, FuncType func, std::array< FieldType, n_args > k_arr) const
 Calculate func(k_arr[0], k_arr[1], ...) when FieldType is a Field (ddc::ChunkSpan).
 
template<class FieldType , class FuncType , std::size_t n_args>
void assemble_vector_field_k_total (ExecSpace const &exec_space, FieldType k_total, FuncType func, std::array< FieldType, n_args > k_arr) const
 Calculate func(k_arr[0], k_arr[1], ...) when FieldType is a VectorField.
 

Additional Inherited Members

- Protected Member Functions inherited from ITimeStepper< FieldMem, DerivFieldMem, ExecSpace >
void copy (ValField copy_to, ValConstField copy_from) const
 Make a copy of the values of the function being evolved.
 
template<class FuncType , class... T>
void assemble_k_total (ExecSpace const &exec_space, DerivField k_total, FuncType func, T... k) const
 A method to assemble multiple derivative fields into one.
 
- Static Protected Member Functions inherited from ITimeStepper< FieldMem, DerivFieldMem, ExecSpace >
template<class DerivFieldType , class Idx , class... DDims>
static KOKKOS_FUNCTION void fill_k_total (DerivFieldType k_total, Idx i, Coord< DDims... > new_val)
 A method to fill an element of a vector field.
 

Detailed Description

template<class FieldMem, class DerivFieldMem = FieldMem, class ExecSpace = Kokkos::DefaultExecutionSpace>
class RK2< FieldMem, DerivFieldMem, ExecSpace >

A class which provides an implementation of a second-order Runge-Kutta method.

A class which provides an implementation of a second-order Runge-Kutta method in order to evolve values over time. The values may be either scalars or vectors. In the case of vectors the appropriate dimensions must be passed as template parameters. The values which evolve are defined on an index range.

For the following ODE : \(\partial_t y(t) = f(t, y(t)) \),

the Runge-Kutta 2 method is given by : \( y^{n+1} = y^{n} + dt k_2 \),

with

  • \( k_1 = f(t^{n}, y^{n}) \),
  • \( k_2 = f(t^{n+1/2}, y^{n} + \frac{dt}{2} k_1 ) \),

Constructor & Destructor Documentation

◆ RK2()

template<class FieldMem , class DerivFieldMem = FieldMem, class ExecSpace = Kokkos::DefaultExecutionSpace>
RK2< FieldMem, DerivFieldMem, ExecSpace >::RK2 ( IdxRange  idx_range)
inlineexplicit

Create a RK2 object.

Parameters
[in]idx_rangeThe index range on which the points which evolve over time are defined.

Member Function Documentation

◆ update() [1/4]

template<class FieldMem , class DerivFieldMem = FieldMem, class ExecSpace = Kokkos::DefaultExecutionSpace>
void RK2< FieldMem, DerivFieldMem, ExecSpace >::update ( ExecSpace const &  exec_space,
ValField  y,
double  dt,
std::function< void(DerivField, ValConstField)>  dy_calculator,
std::function< void(ValField, DerivConstField, double)>  y_update 
) const
inlinefinalvirtual

Carry out one step of the Runge-Kutta scheme.

Parameters
[in]exec_spaceThe space on which the function is executed (CPU/GPU).
[in,out]yThe value(s) which should be evolved over time defined on each of the dimensions at each point of the index range.
[in]dtThe time step over which the values should be evolved.
[in]dy_calculatorThe function describing how the derivative of the evolve function is calculated.
[in]y_updateThe function describing how the value(s) are updated using the derivative.

Implements ITimeStepper< FieldMem, DerivFieldMem, ExecSpace >.

◆ update() [2/4]

template<class FieldMem , class DerivFieldMem = FieldMem, class ExecSpace = Kokkos::DefaultExecutionSpace>
void ITimeStepper< FieldMem, DerivFieldMem, ExecSpace >::update ( ValField  y,
double  dt,
std::function< void(DerivField, ValConstField)>  dy_calculator 
) const
inline

Carry out one step of the timestepping scheme.

This function is a wrapper around the update function below. The values of the function are updated using the trivial method $f += df * dt$. This is the standard method however some cases may need a more complex update function which is why the more explicit method is also provided.

Parameters
[in,out]yThe value(s) which should be evolved over time defined on each of the dimensions at each point of the index range.
[in]dtThe time step over which the values should be evolved.
[in]dy_calculatorThe function describing how the derivative of the evolve function is calculated.

◆ update() [3/4]

template<class FieldMem , class DerivFieldMem = FieldMem, class ExecSpace = Kokkos::DefaultExecutionSpace>
void ITimeStepper< FieldMem, DerivFieldMem, ExecSpace >::update ( ExecSpace const &  exec_space,
ValField  y,
double  dt,
std::function< void(DerivField, ValConstField)>  dy_calculator 
) const
inline

Carry out one step of the timestepping scheme.

This function is a wrapper around the update function below. The values of the function are updated using the trivial method $f += df * dt$. This is the standard method however some cases may need a more complex update function which is why the more explicit method is also provided.

Parameters
[in]exec_spaceThe space on which the function is executed (CPU/GPU).
[in,out]yThe value(s) which should be evolved over time defined on each of the dimensions at each point of the index range.
[in]dtThe time step over which the values should be evolved.
[in]dy_calculatorThe function describing how the derivative of the evolve function is calculated.

◆ update() [4/4]

template<class FieldMem , class DerivFieldMem = FieldMem, class ExecSpace = Kokkos::DefaultExecutionSpace>
virtual void ITimeStepper< FieldMem, DerivFieldMem, ExecSpace >::update ( ExecSpace const &  exec_space,
ValField  y,
double  dt,
std::function< void(DerivField, ValConstField)>  dy_calculator,
std::function< void(ValField, DerivConstField, double)>  y_update 
) const
virtual

Carry out one step of the timestepping scheme.

Parameters
[in]exec_spaceThe space on which the function is executed (CPU/GPU).
[in,out]yThe value(s) which should be evolved over time defined on each of the dimensions at each point of the index range.
[in]dtThe time step over which the values should be evolved.
[in]dy_calculatorThe function describing how the derivative of the evolve function is calculated.
[in]y_updateThe function describing how the value(s) are updated using the derivative.

Implements ITimeStepper< FieldMem, DerivFieldMem, ExecSpace >.


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