4#include "ddc_alias_inline_functions.hpp"
5#include "ddc_aliases.hpp"
6#include "ddc_helper.hpp"
7#include "itimestepper.hpp"
8#include "vector_field_common.hpp"
35 class ExecSpace = Kokkos::DefaultExecutionSpace>
50 IdxRange
const m_idx_range;
60 explicit RK4(IdxRange idx_range) : m_idx_range(idx_range) {}
78 ExecSpace
const& exec_space,
85 Kokkos::SpaceAccessibility<ExecSpace, typename FieldMem::memory_space>::accessible,
86 "MemorySpace has to be accessible for ExecutionSpace.");
88 Kokkos::SpaceAccessibility<ExecSpace, typename DerivFieldMem::memory_space>::
90 "MemorySpace has to be accessible for ExecutionSpace.");
91 FieldMem y_prime_alloc(m_idx_range);
98 ValField y_prime = get_field(y_prime_alloc);
103 DerivField k_total = get_field(k_total_alloc);
111 dy_calculator(k1, get_const_field(y));
115 y_update(y_prime, get_const_field(k1), 0.5 * dt);
118 dy_calculator(k2, get_const_field(y_prime));
125 y_update(y_prime, get_const_field(k2), 0.5 * dt);
128 dy_calculator(k3, get_const_field(y_prime));
135 y_update(y_prime, get_const_field(k3), dt);
138 dy_calculator(k4, get_const_field(y_prime));
143 using element_type =
typename DerivField::element_type;
147 KOKKOS_LAMBDA(std::array<element_type, 4> k) {
148 return k[0] + 2 * k[1] + 2 * k[2] + k[3];
156 y_update(y, get_const_field(k_total), dt / 6.);
See DerivFieldMemImplementation.
Definition derivative_field.hpp:10
See DerivFieldImplementation.
Definition derivative_field.hpp:20
The superclass from which all timestepping methods inherit.
Definition itimestepper.hpp:23
typename FieldMem::discrete_domain_type IdxRange
The type of the index range on which the values of the function are defined.
Definition itimestepper.hpp:46
typename DerivFieldMem::span_type DerivField
The type of the derivatives of the function being evolved.
Definition itimestepper.hpp:56
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.
Definition itimestepper.hpp:182
typename DerivFieldMem::view_type DerivConstField
The constant type of the derivatives values of the function being evolved.
Definition itimestepper.hpp:59
typename FieldMem::span_type ValField
The type of the values of the function being evolved.
Definition itimestepper.hpp:50
void update(ValField y, double dt, std::function< void(DerivField, ValConstField)> dy_calculator) const
Carry out one step of the timestepping scheme.
Definition itimestepper.hpp:78
void copy(ValField copy_to, ValConstField copy_from) const
Make a copy of the values of the function being evolved.
Definition itimestepper.hpp:147
typename FieldMem::view_type ValConstField
The constant type of the values of the function being evolved.
Definition itimestepper.hpp:53
A class which provides an implementation of a fourth-order Runge-Kutta method.
Definition rk4.hpp:37
RK4(IdxRange idx_range)
Create a RK4 object.
Definition rk4.hpp:60
typename DerivFieldMem::view_type DerivConstField
The constant type of the derivatives values of the function being evolved.
Definition itimestepper.hpp:59
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.
Definition rk4.hpp:77
typename FieldMem::span_type ValField
The type of the values of the function being evolved.
Definition itimestepper.hpp:50
typename FieldMem::view_type ValConstField
The constant type of the values of the function being evolved.
Definition itimestepper.hpp:53