5 Vector<MultiFab>& S_slow_rhs,
6 const Vector<MultiFab>& S_old,
7 Vector<MultiFab>& S_stage,
8 Vector<MultiFab>& S_data,
9 Vector<MultiFab>& S_scratch,
12 const Real old_substep_time,
13 const Real new_substep_time)
15 BL_PROFILE(
"fast_rhs_fun");
16 if (verbose) amrex::Print() <<
"Fast time integration at level " << level
17 <<
" from " << old_substep_time <<
" to " << new_substep_time
18 <<
" with dt = " << dtau << std::endl;
26 if (solverChoice.substepping_type[level] == SubsteppingType::Implicit)
36 const bool l_reflux = (solverChoice.coupling_type == CouplingType::TwoWay);
38 YAFluxRegister* fr_as_crse =
nullptr;
39 YAFluxRegister* fr_as_fine =
nullptr;
41 if (level < finest_level) {
42 fr_as_crse = getAdvFluxReg(level+1);
45 fr_as_fine = getAdvFluxReg(level);
50 std::unique_ptr<MultiFab> z_t_pert;
51 if ( solverChoice.terrain_type == TerrainType::Moving )
54 if (verbose) Print() <<
"Making geometry at start of substep time: " << old_substep_time << std::endl;
55 prob->init_custom_terrain(fine_geom,*z_phys_nd[level],old_substep_time);
56 init_terrain_grid (level,fine_geom,*z_phys_nd[level], zlevels_stag[level], phys_bc_type);
57 make_J (fine_geom,*z_phys_nd[level], *detJ_cc[level]);
60 if (verbose) Print() <<
"Making geometry for end of substep time :" << new_substep_time << std::endl;
61 prob->init_custom_terrain(fine_geom,*z_phys_nd_new[level],new_substep_time);
62 init_terrain_grid (level,fine_geom,*z_phys_nd_new[level], zlevels_stag[level], phys_bc_type);
63 make_J (fine_geom,*z_phys_nd_new[level], *detJ_cc_new[level]);
64 make_areas (fine_geom,*z_phys_nd_new[level], *ax_new[level], *ay_new[level], *az_new[level]);
66 Real inv_dt = 1./dtau;
70 for (MFIter mfi(*z_t_rk[level],TilingIfNotGPU()); mfi.isValid(); ++mfi)
72 Box gbx = mfi.growntilebox(IntVect(1,1,0));
74 const Array4<Real >& z_t_arr = z_t_rk[level]->array(mfi);
75 const Array4<Real >& zp_t_arr = z_t_pert->array(mfi);
77 const Array4<Real const>& z_nd_new_arr = z_phys_nd_new[level]->const_array(mfi);
78 const Array4<Real const>& z_nd_old_arr = z_phys_nd[level]->const_array(mfi);
81 amrex::ParallelFor(gbx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept
84 zp_t_arr(i,j,k) = 0.25 * inv_dt * (z_nd_new_arr(i+1,j+1,k) - z_nd_old_arr(i+1,j+1,k)
85 +z_nd_new_arr(i ,j+1,k) - z_nd_old_arr( i,j+1,k)
86 +z_nd_new_arr(i+1,j ,k) - z_nd_old_arr(i+1,j ,k)
87 +z_nd_new_arr(i ,j ,k) - z_nd_old_arr(i ,j ,k));
89 zp_t_arr(i,j,k) -= z_t_arr(i,j,k);
97 detJ_cc[level], r0, pi0, dtau, beta_s, phys_bc_type);
102 S_slow_rhs, S_old, S_stage, S_prim, pi_stage, fast_coeffs,
103 S_data, S_scratch, fine_geom,
104 solverChoice.gravity, solverChoice.use_lagged_delta_rt,
105 z_t_rk[level], z_t_pert.get(),
106 z_phys_nd[level], z_phys_nd_new[level], z_phys_nd_src[level],
107 detJ_cc[level], detJ_cc_new[level], detJ_cc_src[level],
108 dtau, beta_s, inv_fac,
109 mapfac_m[level], mapfac_u[level], mapfac_v[level],
110 fr_as_crse, fr_as_fine, l_use_moisture, l_reflux, l_implicit_substepping);
114 S_slow_rhs, S_data, S_stage, S_prim, pi_stage, fast_coeffs,
115 S_data, S_scratch, fine_geom,
116 solverChoice.gravity, solverChoice.use_lagged_delta_rt,
117 z_t_rk[level], z_t_pert.get(),
118 z_phys_nd[level], z_phys_nd_new[level], z_phys_nd_src[level],
119 detJ_cc[level], detJ_cc_new[level], detJ_cc_src[level],
120 dtau, beta_s, inv_fac,
121 mapfac_m[level], mapfac_u[level], mapfac_v[level],
122 fr_as_crse, fr_as_fine, l_use_moisture, l_reflux, l_implicit_substepping);
124 }
else if (solverChoice.mesh_type != MeshType::ConstantDz) {
125 if (fast_step == 0) {
130 detJ_cc[level], r0, pi0, dtau, beta_s, phys_bc_type);
135 S_slow_rhs, S_old, S_stage, S_prim, pi_stage, fast_coeffs,
136 S_data, S_scratch, fine_geom, solverChoice.gravity,
137 z_phys_nd[level], detJ_cc[level], dtau, beta_s, inv_fac,
138 mapfac_m[level], mapfac_u[level], mapfac_v[level],
139 fr_as_crse, fr_as_fine, l_use_moisture, l_reflux, l_implicit_substepping);
144 S_slow_rhs, S_data, S_stage, S_prim, pi_stage, fast_coeffs,
145 S_data, S_scratch, fine_geom, solverChoice.gravity,
146 z_phys_nd[level], detJ_cc[level], dtau, beta_s, inv_fac,
147 mapfac_m[level], mapfac_u[level], mapfac_v[level],
148 fr_as_crse, fr_as_fine, l_use_moisture, l_reflux, l_implicit_substepping);
151 if (fast_step == 0) {
156 detJ_cc[level], r0, pi0, dtau, beta_s, phys_bc_type);
161 S_slow_rhs, S_old, S_stage, S_prim, pi_stage, fast_coeffs,
162 S_data, S_scratch, fine_geom, solverChoice.gravity,
163 dtau, beta_s, inv_fac,
164 mapfac_m[level], mapfac_u[level], mapfac_v[level],
165 fr_as_crse, fr_as_fine, l_use_moisture, l_reflux, l_implicit_substepping);
170 S_slow_rhs, S_data, S_stage, S_prim, pi_stage, fast_coeffs,
171 S_data, S_scratch, fine_geom, solverChoice.gravity,
172 dtau, beta_s, inv_fac,
173 mapfac_m[level], mapfac_u[level], mapfac_v[level],
174 fr_as_crse, fr_as_fine, l_use_moisture, l_reflux, l_implicit_substepping);
187 if (!solverChoice.use_num_diff) {
191 apply_bcs(S_data, new_substep_time, ng_cons, ng_vel, fast_only=
true, vel_and_mom_synced=
false);
void erf_fast_rhs_MT(int step, int nrk, int level, int finest_level, Vector< MultiFab > &S_slow_rhs, const Vector< MultiFab > &S_prev, Vector< MultiFab > &S_stg_data, const MultiFab &S_stg_prim, const MultiFab &pi_stage, const MultiFab &fast_coeffs, Vector< MultiFab > &S_data, Vector< MultiFab > &S_scratch, const Geometry geom, const Real gravity, const bool use_lagged_delta_rt, std::unique_ptr< MultiFab > &z_t_rk, const MultiFab *z_t_pert, std::unique_ptr< MultiFab > &z_phys_nd_old, std::unique_ptr< MultiFab > &z_phys_nd_new, std::unique_ptr< MultiFab > &z_phys_nd_stg, std::unique_ptr< MultiFab > &detJ_cc_old, std::unique_ptr< MultiFab > &detJ_cc_new, std::unique_ptr< MultiFab > &detJ_cc_stg, const Real dtau, const Real beta_s, const Real facinv, std::unique_ptr< MultiFab > &mapfac_m, std::unique_ptr< MultiFab > &mapfac_u, std::unique_ptr< MultiFab > &mapfac_v, YAFluxRegister *fr_as_crse, YAFluxRegister *fr_as_fine, bool l_use_moisture, bool l_reflux, bool)
Definition: ERF_FastRhs_MT.cpp:45
void erf_fast_rhs_N(int step, int nrk, int level, int finest_level, Vector< MultiFab > &S_slow_rhs, const Vector< MultiFab > &S_prev, Vector< MultiFab > &S_stage_data, const MultiFab &S_stage_prim, const MultiFab &pi_stage, const MultiFab &fast_coeffs, Vector< MultiFab > &S_data, Vector< MultiFab > &S_scratch, const Geometry geom, const Real gravity, const Real dtau, const Real beta_s, const Real facinv, std::unique_ptr< MultiFab > &mapfac_m, std::unique_ptr< MultiFab > &mapfac_u, std::unique_ptr< MultiFab > &mapfac_v, YAFluxRegister *fr_as_crse, YAFluxRegister *fr_as_fine, bool l_use_moisture, bool l_reflux, bool l_implicit_substepping)
Definition: ERF_FastRhs_N.cpp:36
void erf_fast_rhs_T(int step, int nrk, int level, int finest_level, Vector< MultiFab > &S_slow_rhs, const Vector< MultiFab > &S_prev, Vector< MultiFab > &S_stage_data, const MultiFab &S_stage_prim, const MultiFab &pi_stage, const MultiFab &fast_coeffs, Vector< MultiFab > &S_data, Vector< MultiFab > &S_scratch, const Geometry geom, const Real gravity, std::unique_ptr< MultiFab > &z_phys_nd, std::unique_ptr< MultiFab > &detJ_cc, const Real dtau, const Real beta_s, const Real facinv, std::unique_ptr< MultiFab > &mapfac_m, std::unique_ptr< MultiFab > &mapfac_u, std::unique_ptr< MultiFab > &mapfac_v, YAFluxRegister *fr_as_crse, YAFluxRegister *fr_as_fine, bool l_use_moisture, bool l_reflux, bool)
Definition: ERF_FastRhs_T.cpp:38
void make_fast_coeffs(int, MultiFab &fast_coeffs, Vector< MultiFab > &S_stage_data, const MultiFab &S_stage_prim, const MultiFab &pi_stage, const amrex::Geometry geom, bool l_use_moisture, MeshType mesh_type, Real gravity, Real c_p, std::unique_ptr< MultiFab > &detJ_cc, const MultiFab *r0, const MultiFab *pi0, Real dtau, Real beta_s, amrex::GpuArray< ERF_BC, AMREX_SPACEDIM *2 > &phys_bc_type)
Definition: ERF_MakeFastCoeffs.cpp:26
auto fast_rhs_fun
Definition: ERF_TI_substep_fun.H:4
auto apply_bcs
Definition: ERF_TI_utils.H:50
void init_terrain_grid(int lev, const Geometry &geom, MultiFab &z_phys_nd, Vector< Real > const &z_levels_h, GpuArray< ERF_BC, AMREX_SPACEDIM *2 > &phys_bc_type)
Definition: ERF_TerrainMetrics.cpp:118
void make_areas(const Geometry &geom, MultiFab &z_phys_nd, MultiFab &ax, MultiFab &ay, MultiFab &az)
Definition: ERF_TerrainMetrics.cpp:651
void make_J(const Geometry &geom, MultiFab &z_phys_nd, MultiFab &detJ_cc)
Definition: ERF_TerrainMetrics.cpp:613
@ cons
Definition: ERF_IndexDefines.H:139
@ zmom
Definition: ERF_IndexDefines.H:142
@ xmom
Definition: ERF_IndexDefines.H:140
static MeshType mesh_type
Definition: ERF_DataStruct.H:570