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;
61 std::function<void (
T&,
T&,
T&, amrex::Real, amrex::Real,
int)>
no_substep;
64 amrex::Vector<std::unique_ptr<T> >
T_store;
73 const bool include_ghost =
true;
74 amrex::IntegratorOps<T>::CreateLike(
T_store, S_data, include_ghost);
76 amrex::IntegratorOps<T>::CreateLike(
T_store, S_data, include_ghost);
78 amrex::IntegratorOps<T>::CreateLike(
T_store, S_data, include_ghost);
134 void set_slow_rhs_pre (std::function<
void(
T&,
T&,
T&,
T&,
const amrex::Real,
const amrex::Real,
const amrex::Real,
const int)>
F)
138 void set_slow_rhs_inc (std::function<
void(
T&,
T&,
T&,
T&,
const amrex::Real,
const amrex::Real,
const amrex::Real,
const int)>
F)
142 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)
148 const amrex::Real,
const amrex::Real,
149 const amrex::Real,
const amrex::Real)>
F)
169 std::function<void(
T&,
const T&,
const amrex::Real,
int)>
get_rhs ()
174 amrex::Real
advance (
T& S_old,
T& S_new, amrex::Real time,
const amrex::Real time_step)
176 BL_PROFILE_REGION(
"MRI_advance");
177 using namespace amrex;
193 AMREX_ALWAYS_ASSERT(substep_ratio > 1 && substep_ratio % 2 == 0);
213 for (
int i(0); i<n_data; ++i)
216 MultiFab::Copy(S_new[i],S_old[i],0,0,num_vars[i],S_old[i].nGrowVect());
228 amrex::Real time_stage = time;
229 amrex::Real old_time_stage;
231 const amrex::Real sub_timestep =
timestep / substep_ratio;
235 for (
int nrk = 0; nrk < 3; nrk++)
238 old_time_stage = time_stage;
242 nsubsteps = 1; dtau =
timestep / 3.0;
244 nsubsteps = substep_ratio/3; dtau = sub_timestep ;
250 nsubsteps = 1; dtau = 0.5 *
timestep;
252 nsubsteps = substep_ratio/2; dtau = sub_timestep;
260 nsubsteps = substep_ratio; dtau = sub_timestep;
280 amrex::Real inv_fac = 1.0 /
static_cast<amrex::Real
>(nsubsteps);
290 for (
int ks = 0; ks < nsubsteps; ++ks)
292 fast_rhs(ks, nsubsteps, nrk, *
F_slow, S_old, S_new, *
S_sum, *
S_scratch, dtau, inv_fac,
293 time + ks*dtau, time + (ks+1) * dtau);
313 for (
int nrk = 0; nrk < 2; nrk++)
316 old_time_stage = time_stage;
318 if (nrk == 0) { nsubsteps = 1; dtau =
timestep; time_stage = time +
timestep; }
319 if (nrk == 1) { nsubsteps = 1; dtau =
timestep; time_stage = time +
timestep; }
T * F_slow
Definition: ERF_MRI.H:67
amrex::Vector< std::unique_ptr< T > > T_store
Definition: ERF_MRI.H:64
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:134
void map_data(std::function< void(T &)> Map)
Definition: ERF_MRI.H:345
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:164
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:138
int anelastic
Should we use the anelastic integrator.
Definition: ERF_MRI.H:46
void setNcompCons(int _ncomp_cons)
Definition: ERF_MRI.H:114
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:129
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
int ncomp_cons
How many components in the cell-centered MultiFab.
Definition: ERF_MRI.H:51
T * S_scratch
Definition: ERF_MRI.H:66
void setNoSubstepping(int _no_substepping)
Definition: ERF_MRI.H:124
void initialize(const T &S_data)
Definition: ERF_MRI.H:90
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:69
MRISplitIntegrator(const T &S_data)
Definition: ERF_MRI.H:85
std::function< void(T &, const T &, const amrex::Real, int)> get_rhs()
Definition: ERF_MRI.H:169
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:147
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:119
int get_slow_fast_timestep_ratio()
Definition: ERF_MRI.H:159
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:61
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:154
T * S_sum
Definition: ERF_MRI.H:65
amrex::Real advance(T &S_old, T &S_new, amrex::Real time, const amrex::Real time_step)
Definition: ERF_MRI.H:174
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:142
int no_substepping
Should we not do acoustic substepping.
Definition: ERF_MRI.H:41
@ NumTypes
Definition: ERF_IndexDefines.H:143
@ T
Definition: ERF_IndexDefines.H:99
Definition: ERF_ConsoleIO.cpp:12