4 #include <AMReX_REAL.H>
5 #include <AMReX_Vector.H>
6 #include <AMReX_ParmParse.H>
7 #include <AMReX_IntegratorBase.H>
21 std::function<void(
T&,
const T&,
const amrex::Real,
const amrex::Real )>
rhs;
22 std::function<void(
T&,
T&,
T&,
T&,
const amrex::Real,
const amrex::Real,
const amrex::Real,
const int)>
slow_rhs_pre;
23 std::function<void(
T&,
T&,
T&,
T&,
const amrex::Real,
const amrex::Real,
const amrex::Real,
const int)>
slow_rhs_inc;
24 std::function<void(
T&,
T&,
T&,
T&,
T&,
const amrex::Real,
const amrex::Real,
const amrex::Real,
const int )>
slow_rhs_post;
25 std::function<void(
int,
int,
int,
T&,
const T&,
T&,
T&,
T&,
const amrex::Real,
const amrex::Real,
26 const amrex::Real,
const amrex::Real)>
fast_rhs;
64 std::function<void (
T&,
T&,
T&, amrex::Real, amrex::Real,
int)>
no_substep;
67 amrex::Vector<std::unique_ptr<T> >
T_store;
76 const bool include_ghost =
true;
77 amrex::IntegratorOps<T>::CreateLike(
T_store, S_data, include_ghost);
79 amrex::IntegratorOps<T>::CreateLike(
T_store, S_data, include_ghost);
81 amrex::IntegratorOps<T>::CreateLike(
T_store, S_data, include_ghost);
137 void set_slow_rhs_pre (std::function<
void(
T&,
T&,
T&,
T&,
const amrex::Real,
const amrex::Real,
const amrex::Real,
const int)>
F)
141 void set_slow_rhs_inc (std::function<
void(
T&,
T&,
T&,
T&,
const amrex::Real,
const amrex::Real,
const amrex::Real,
const int)>
F)
145 void set_slow_rhs_post (std::function<
void(
T&,
T&,
T&,
T&,
T&,
const amrex::Real,
const amrex::Real,
const amrex::Real,
const int)>
F)
151 const amrex::Real,
const amrex::Real,
152 const amrex::Real,
const amrex::Real)>
F)
182 std::function<void(
T&,
const T&,
const amrex::Real,
int)>
get_rhs ()
187 amrex::Real
advance (
T& S_old,
T& S_new, amrex::Real time,
const amrex::Real time_step)
189 BL_PROFILE_REGION(
"MRI_advance");
190 using namespace amrex;
206 AMREX_ALWAYS_ASSERT(substep_ratio > 1 && substep_ratio % 2 == 0);
226 for (
int i(0); i<n_data; ++i)
229 MultiFab::Copy(S_new[i],S_old[i],0,0,num_vars[i],S_old[i].nGrowVect());
241 amrex::Real time_stage = time;
242 amrex::Real old_time_stage;
244 const amrex::Real sub_timestep =
timestep / substep_ratio;
248 for (
int nrk = 0; nrk < 3; nrk++)
253 old_time_stage = time_stage;
257 nsubsteps = 1; dtau =
timestep / 3.0;
259 nsubsteps = substep_ratio/3; dtau = sub_timestep ;
265 nsubsteps = 1; dtau = 0.5 *
timestep;
267 nsubsteps = substep_ratio/2; dtau = sub_timestep;
275 nsubsteps = substep_ratio; dtau = sub_timestep;
301 amrex::Real inv_fac = 1.0 /
static_cast<amrex::Real
>(nsubsteps);
311 for (
int ks = 0; ks < nsubsteps; ++ks)
313 fast_rhs(ks, nsubsteps, nrk, *
F_slow, S_old, S_new, *
S_sum, *
S_scratch, dtau, inv_fac,
314 time + ks*dtau, time + (ks+1) * dtau);
338 for (
int nrk = 0; nrk < 2; nrk++)
341 old_time_stage = time_stage;
343 if (nrk == 0) { nsubsteps = 1; dtau =
timestep; time_stage = time +
timestep; }
344 if (nrk == 1) { nsubsteps = 1; dtau =
timestep; time_stage = time +
timestep; }
std::function< void(T &, amrex::Real, int, int)> post_update
Definition: ERF_MRI.H:63
T * F_slow
Definition: ERF_MRI.H:70
amrex::Vector< std::unique_ptr< T > > T_store
Definition: ERF_MRI.H:67
void set_slow_rhs_pre(std::function< void(T &, T &, T &, T &, const amrex::Real, const amrex::Real, const amrex::Real, const int)> F)
Definition: ERF_MRI.H:137
void map_data(std::function< void(T &)> Map)
Definition: ERF_MRI.H:371
std::function< void(T &, T &, T &, T &, T &, const amrex::Real, const amrex::Real, const amrex::Real, const int)> slow_rhs_post
Definition: ERF_MRI.H:24
void set_no_substep(std::function< void(T &, T &, T &, amrex::Real, amrex::Real, int)> F)
Definition: ERF_MRI.H:177
void set_slow_rhs_inc(std::function< void(T &, T &, T &, T &, const amrex::Real, const amrex::Real, const amrex::Real, const int)> F)
Definition: ERF_MRI.H:141
int anelastic
Should we use the anelastic integrator.
Definition: ERF_MRI.H:46
void setNcompCons(int _ncomp_cons)
Definition: ERF_MRI.H:117
amrex::Real timestep
Integrator timestep size (Real)
Definition: ERF_MRI.H:31
MRISplitIntegrator()=default
std::function< void(T &, T &, T &, T &, const amrex::Real, const amrex::Real, const amrex::Real, const int)> slow_rhs_pre
Definition: ERF_MRI.H:22
void setForceFirstStageSingleSubstep(int _force_stage1_single_substep)
Definition: ERF_MRI.H:132
int force_stage1_single_substep
Do we follow the recommendation to only perform a single substep in the first RK stage.
Definition: ERF_MRI.H:56
std::function< void(T &, int)> pre_update
The pre_update function is called by the integrator on stage data before using it to evaluate a right...
Definition: ERF_MRI.H:62
int ncomp_cons
How many components in the cell-centered MultiFab.
Definition: ERF_MRI.H:51
T * S_scratch
Definition: ERF_MRI.H:69
void setNoSubstepping(int _no_substepping)
Definition: ERF_MRI.H:127
void initialize(const T &S_data)
Definition: ERF_MRI.H:93
void set_pre_update(std::function< void(T &, int)> F)
Definition: ERF_MRI.H:167
MRISplitIntegrator(MRISplitIntegrator &&) noexcept=default
std::function< void(T &, T &, T &, T &, const amrex::Real, const amrex::Real, const amrex::Real, const int)> slow_rhs_inc
Definition: ERF_MRI.H:23
std::function< void(int, int, int, T &, const T &, T &, T &, T &, const amrex::Real, const amrex::Real, const amrex::Real, const amrex::Real)> fast_rhs
Definition: ERF_MRI.H:26
void initialize_data(const T &S_data)
Definition: ERF_MRI.H:72
void set_post_update(std::function< void(T &, amrex::Real, int, int)> F)
Definition: ERF_MRI.H:172
MRISplitIntegrator(const T &S_data)
Definition: ERF_MRI.H:88
std::function< void(T &, const T &, const amrex::Real, int)> get_rhs()
Definition: ERF_MRI.H:182
void set_fast_rhs(std::function< void(int, int, int, T &, const T &, T &, T &, T &, const amrex::Real, const amrex::Real, const amrex::Real, const amrex::Real)> F)
Definition: ERF_MRI.H:150
std::function< void(T &, const T &, const amrex::Real, const amrex::Real)> rhs
rhs is the right-hand-side function the integrator will use.
Definition: ERF_MRI.H:21
void setAnelastic(int _anelastic)
Definition: ERF_MRI.H:122
int get_slow_fast_timestep_ratio()
Definition: ERF_MRI.H:162
std::function< void(T &, T &, T &, amrex::Real, amrex::Real, int)> no_substep
Definition: ERF_MRI.H:64
int slow_fast_timestep_ratio
The ratio of slow timestep size / fast timestep size (int)
Definition: ERF_MRI.H:36
~MRISplitIntegrator()=default
void set_slow_fast_timestep_ratio(const int timestep_ratio=1)
Definition: ERF_MRI.H:157
T * S_sum
Definition: ERF_MRI.H:68
amrex::Real advance(T &S_old, T &S_new, amrex::Real time, const amrex::Real time_step)
Definition: ERF_MRI.H:187
void set_slow_rhs_post(std::function< void(T &, T &, T &, T &, T &, const amrex::Real, const amrex::Real, const amrex::Real, const int)> F)
Definition: ERF_MRI.H:145
int no_substepping
Should we not do acoustic substepping.
Definition: ERF_MRI.H:41
@ NumTypes
Definition: ERF_IndexDefines.H:143
@ cons
Definition: ERF_IndexDefines.H:139
@ xmom
Definition: ERF_IndexDefines.H:140
@ T
Definition: ERF_IndexDefines.H:99
Definition: ERF_console_io.cpp:12