1 #ifndef AMREX_RK_INTEGRATOR_H
2 #define AMREX_RK_INTEGRATOR_H
74 weights = {1./6., 1./6., 2./3.};
84 {0.0, 0.0, 1.0, 0.0}};
85 weights = {1./6., 1./3., 1./3., 1./6.};
100 int _tableau_type = 0;
101 pp.
get(
"type", _tableau_type);
120 amrex::Error(
"integration.rk.weights should be the same length as integration.rk.nodes");
124 if (btable.
size() != nTableau)
126 amrex::Error(
"integration.rk.tableau incorrect length - should include the Butcher Tableau diagonal.");
135 for (
int j = 0; j <= i; ++j)
137 stage_row.push_back(btable[k]);
145 for (
const auto& astage :
tableau)
147 if (astage.back() != 0.0)
149 amrex::Error(
"RKIntegrator currently only supports explicit Butcher tableaus.");
156 amrex::Error(
"RKIntegrator received invalid input for integration.rk.type");
184 void initialize (
const T& S_data,
const amrex::Real time = 0.0)
192 amrex::Real
advance (T& S_old, T& S_new, amrex::Real time,
const amrex::Real dt)
override
203 amrex::Real stage_time = time + dt *
nodes[i];
212 for (
int j = 0; j < i; ++j)
246 void evolve (T& S_out,
const amrex::Real time_out)
override
251 for (
int step_number = 0; step_number <
BaseT::max_steps && !stop; ++step_number)
273 Error(
"Did not reach output time in max steps.");
278 void time_interpolate (
const T& ,
const T& S_old, amrex::Real timestep_fraction, T& data)
override
298 c = timestep_fraction - 1.5 *
std::pow(timestep_fraction, 2) + 2./3. *
std::pow(timestep_fraction, 3);
302 c =
std::pow(timestep_fraction, 2) - 2./3. *
std::pow(timestep_fraction, 3);
306 c =
std::pow(timestep_fraction, 2) - 2./3. *
std::pow(timestep_fraction, 3);
310 c = -0.5 *
std::pow(timestep_fraction, 2) + 2./3. *
std::pow(timestep_fraction, 3);
315 void map_data (std::function<
void(T&)> Map)
override
#define AMREX_ASSERT(EX)
Definition: AMReX_BLassert.H:38
amrex::ParmParse pp
Input file parser instance for the given namespace.
Definition: AMReX_HypreIJIface.cpp:15
Definition: AMReX_IntegratorBase.H:163
std::function< void(T &, amrex::Real)> post_step_action
The post_step_action function is called by the integrator on the computed state just after it is comp...
Definition: AMReX_IntegratorBase.H:198
int max_steps
Max number of internal steps before an error is returned (Long)
Definition: AMReX_IntegratorBase.H:248
std::function< void(T &rhs, T &state, const amrex::Real time)> Rhs
Rhs is the right-hand-side function the integrator will use.
Definition: AMReX_IntegratorBase.H:168
std::function< void(T &, amrex::Real)> post_stage_action
The post_stage_action function is called by the integrator on the computed stage just after it is com...
Definition: AMReX_IntegratorBase.H:192
amrex::Real time_step
Current integrator time step size (Real)
Definition: AMReX_IntegratorBase.H:221
amrex::Real previous_time_step
Step size of the last completed step (Real)
Definition: AMReX_IntegratorBase.H:226
Parse Parameters From Command Line and Input Files.
Definition: AMReX_ParmParse.H:320
void get(const char *name, bool &ref, int ival=FIRST) const
Same as getkth() but searches for the last occurrence of name.
Definition: AMReX_ParmParse.cpp:1292
int queryarr(const char *name, std::vector< int > &ref, int start_ix=FIRST, int num_val=ALL) const
Same as queryktharr() but searches for last occurrence of name.
Definition: AMReX_ParmParse.cpp:1376
void getarr(const char *name, std::vector< int > &ref, int start_ix=FIRST, int num_val=ALL) const
Same as getktharr() but searches for last occurrence of name.
Definition: AMReX_ParmParse.cpp:1362
Definition: AMReX_RKIntegrator.H:22
virtual ~RKIntegrator()
Definition: AMReX_RKIntegrator.H:190
void time_interpolate(const T &, const T &S_old, amrex::Real timestep_fraction, T &data) override
Definition: AMReX_RKIntegrator.H:278
amrex::Vector< amrex::Real > extended_weights
Definition: AMReX_RKIntegrator.H:42
ButcherTableauTypes tableau_type
Definition: AMReX_RKIntegrator.H:27
amrex::Vector< amrex::Real > nodes
Definition: AMReX_RKIntegrator.H:39
amrex::Vector< std::unique_ptr< T > > F_nodes
Definition: AMReX_RKIntegrator.H:45
RKIntegrator(const T &S_data, const amrex::Real time=0.0)
Definition: AMReX_RKIntegrator.H:179
amrex::Vector< std::unique_ptr< T > > S_current
Definition: AMReX_RKIntegrator.H:48
amrex::Vector< amrex::Real > weights
Definition: AMReX_RKIntegrator.H:36
void initialize_parameters()
Definition: AMReX_RKIntegrator.H:95
void map_data(std::function< void(T &)> Map) override
Definition: AMReX_RKIntegrator.H:315
void initialize_preset_tableau()
Definition: AMReX_RKIntegrator.H:51
void initialize_stages(const T &S_data, const amrex::Real time)
Definition: AMReX_RKIntegrator.H:160
amrex::Real advance(T &S_old, T &S_new, amrex::Real time, const amrex::Real dt) override
Take a single time step from (time, S_old) to (time + dt, S_new) with the given step size.
Definition: AMReX_RKIntegrator.H:192
amrex::Vector< amrex::Vector< amrex::Real > > tableau
Definition: AMReX_RKIntegrator.H:33
int number_nodes
Definition: AMReX_RKIntegrator.H:30
void evolve(T &S_out, const amrex::Real time_out) override
Evolve the current (internal) integrator state to time_out.
Definition: AMReX_RKIntegrator.H:246
void initialize(const T &S_data, const amrex::Real time=0.0)
Definition: AMReX_RKIntegrator.H:184
amrex::Real time_current
Definition: AMReX_RKIntegrator.H:49
RKIntegrator()
Definition: AMReX_RKIntegrator.H:177
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition: AMReX_Vector.H:27
Long size() const noexcept
Definition: AMReX_Vector.H:50
Definition: AMReX_Amr.cpp:49
void Saxpy(MF &dst, typename MF::value_type a, MF const &src, int scomp, int dcomp, int ncomp, IntVect const &nghost)
dst += a * src
Definition: AMReX_FabArrayUtility.H:1646
void Copy(FabArray< DFAB > &dst, FabArray< SFAB > const &src, int srccomp, int dstcomp, int numcomp, int nghost)
Definition: AMReX_FabArray.H:179
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE std::enable_if_t< std::is_floating_point_v< T >, bool > almostEqual(T x, T y, int ulp=2)
Definition: AMReX_Algorithm.H:93
void Error(const std::string &msg)
Print out message to cerr and exit via amrex::Abort().
Definition: AMReX.cpp:219
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > pow(const GpuComplex< T > &a_z, const T &a_y) noexcept
Raise a complex number to a (real) power.
Definition: AMReX_GpuComplex.H:418
ButcherTableauTypes
Definition: AMReX_RKIntegrator.H:11
Definition: AMReX_IntegratorBase.H:17