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&,
T&,
const amrex::Real,
const amrex::Real,
const amrex::Real,
const int )>
slow_rhs_post;
24 std::function<void(
int,
int,
int,
T&,
const T&,
T&,
T&,
T&,
const amrex::Real,
const amrex::Real,
25 const amrex::Real,
const amrex::Real)>
fast_rhs;
60 std::function<void (
T&,
T&,
T&, amrex::Real, amrex::Real,
int)>
no_substep;
63 amrex::Vector<std::unique_ptr<T> >
T_store;
72 const bool include_ghost =
true;
73 amrex::IntegratorOps<T>::CreateLike(
T_store, S_data, include_ghost);
75 amrex::IntegratorOps<T>::CreateLike(
T_store, S_data, include_ghost);
77 amrex::IntegratorOps<T>::CreateLike(
T_store, S_data, include_ghost);
133 void set_slow_rhs_pre (std::function<
void(
T&,
T&,
T&,
T&,
const amrex::Real,
const amrex::Real,
const amrex::Real,
const int)> F)
137 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)
143 const amrex::Real,
const amrex::Real,
144 const amrex::Real,
const amrex::Real)> F)
164 std::function<void(
T&,
const T&,
const amrex::Real,
int)>
get_rhs ()
169 amrex::Real
advance (
T& S_old,
T& S_new, amrex::Real time,
const amrex::Real time_step)
171 BL_PROFILE_REGION(
"MRI_advance");
172 using namespace amrex;
188 AMREX_ALWAYS_ASSERT(substep_ratio > 1 && substep_ratio % 2 == 0);
208 for (
int i(0); i<n_data; ++i)
211 MultiFab::Copy(S_new[i],S_old[i],0,0,num_vars[i],S_old[i].nGrowVect());
223 amrex::Real time_stage = time;
224 amrex::Real old_time_stage;
226 const amrex::Real sub_timestep =
timestep / substep_ratio;
230 for (
int nrk = 0; nrk < 3; nrk++)
233 old_time_stage = time_stage;
237 nsubsteps = 1; dtau =
timestep / 3.0;
239 nsubsteps = substep_ratio/3; dtau = sub_timestep ;
245 nsubsteps = 1; dtau = 0.5 *
timestep;
247 nsubsteps = substep_ratio/2; dtau = sub_timestep;
255 nsubsteps = substep_ratio; dtau = sub_timestep;
275 amrex::Real inv_fac = 1.0 /
static_cast<amrex::Real
>(nsubsteps);
285 for (
int ks = 0; ks < nsubsteps; ++ks)
287 fast_rhs(ks, nsubsteps, nrk, *
F_slow, S_old, S_new, *
S_sum, *
S_scratch, dtau, inv_fac,
288 time + ks*dtau, time + (ks+1) * dtau);
308 for (
int nrk = 0; nrk < 2; nrk++)
311 old_time_stage = time_stage;
313 if (nrk == 0) { nsubsteps = 1; dtau =
timestep; time_stage = time +
timestep; }
314 if (nrk == 1) { nsubsteps = 1; dtau =
timestep; time_stage = time +
timestep; }
T * F_slow
Definition: ERF_MRI.H:66
amrex::Vector< std::unique_ptr< T > > T_store
Definition: ERF_MRI.H:63
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:133
void map_data(std::function< void(T &)> Map)
Definition: ERF_MRI.H:340
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:23
void set_no_substep(std::function< void(T &, T &, T &, amrex::Real, amrex::Real, int)> F)
Definition: ERF_MRI.H:159
int anelastic
Should we use the anelastic integrator.
Definition: ERF_MRI.H:45
void setNcompCons(int _ncomp_cons)
Definition: ERF_MRI.H:113
amrex::Real timestep
Integrator timestep size (Real)
Definition: ERF_MRI.H:30
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:128
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:55
int ncomp_cons
How many components in the cell-centered MultiFab.
Definition: ERF_MRI.H:50
T * S_scratch
Definition: ERF_MRI.H:65
void setNoSubstepping(int _no_substepping)
Definition: ERF_MRI.H:123
void initialize(const T &S_data)
Definition: ERF_MRI.H:89
MRISplitIntegrator(MRISplitIntegrator &&) noexcept=default
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:25
void initialize_data(const T &S_data)
Definition: ERF_MRI.H:68
MRISplitIntegrator(const T &S_data)
Definition: ERF_MRI.H:84
std::function< void(T &, const T &, const amrex::Real, int)> get_rhs()
Definition: ERF_MRI.H:164
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:142
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:118
int get_slow_fast_timestep_ratio()
Definition: ERF_MRI.H:154
std::function< void(T &, T &, T &, amrex::Real, amrex::Real, int)> no_substep
The no_substep function is called when we have no acoustic substepping.
Definition: ERF_MRI.H:60
int slow_fast_timestep_ratio
The ratio of slow timestep size / fast timestep size (int)
Definition: ERF_MRI.H:35
~MRISplitIntegrator()=default
void set_slow_fast_timestep_ratio(const int timestep_ratio=1)
Definition: ERF_MRI.H:149
T * S_sum
Definition: ERF_MRI.H:64
amrex::Real advance(T &S_old, T &S_new, amrex::Real time, const amrex::Real time_step)
Definition: ERF_MRI.H:169
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:137
int no_substepping
Should we not do acoustic substepping.
Definition: ERF_MRI.H:40
@ NumTypes
Definition: ERF_IndexDefines.H:162
@ T
Definition: ERF_IndexDefines.H:110
Definition: ERF_ConsoleIO.cpp:12