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 << std::setprecision(timeprecision)
18 <<
" from " << old_substep_time <<
" to " << new_substep_time
19 <<
" with dt = " << dtau << std::endl;
27 if (solverChoice.substepping_type[level] == SubsteppingType::Implicit)
37 const bool l_reflux = (solverChoice.coupling_type == CouplingType::TwoWay);
39 YAFluxRegister* fr_as_crse =
nullptr;
40 YAFluxRegister* fr_as_fine =
nullptr;
42 if (level < finest_level) {
43 fr_as_crse = getAdvFluxReg(level+1);
46 fr_as_fine = getAdvFluxReg(level);
51 std::unique_ptr<MultiFab> z_t_pert;
52 if ( solverChoice.terrain_type == TerrainType::MovingFittedMesh )
55 Box terrain_bx(surroundingNodes(Geom(0).Domain())); terrain_bx.grow(z_phys_nd[level]->nGrow());
57 if (verbose) Print() <<
"Making geometry at start of substep time: "
58 << std::setprecision(timeprecision) << old_substep_time << std::endl;
59 FArrayBox terrain_fab_old(makeSlab(terrain_bx,2,0),1);
60 prob->init_terrain_surface(fine_geom,terrain_fab_old,old_substep_time);
63 if (verbose) Print() <<
"Making geometry for end of substep time :"
64 << std::setprecision(timeprecision) << new_substep_time << std::endl;
65 FArrayBox terrain_fab_new(makeSlab(terrain_bx,2,0),1);
66 prob->init_terrain_surface(fine_geom,terrain_fab_new,new_substep_time);
69 for (MFIter mfi(*z_phys_nd[level],
false); mfi.isValid(); ++mfi)
71 Box isect = terrain_fab_old.box() & (*z_phys_nd[level])[mfi].box();
72 ( *z_phys_nd[level])[mfi].
template copy<RunOn::Device>(terrain_fab_old,isect,0,isect,0,1);
73 (*z_phys_nd_new[level])[mfi].
template copy<RunOn::Device>(terrain_fab_new,isect,0,isect,0,1);
77 make_J (fine_geom,*z_phys_nd[level], *detJ_cc[level]);
80 make_J (fine_geom,*z_phys_nd_new[level], *detJ_cc_new[level]);
81 make_areas (fine_geom,*z_phys_nd_new[level], *ax_new[level], *ay_new[level], *az_new[level]);
83 Real inv_dt = 1./dtau;
87 for (MFIter mfi(*z_t_rk[level],TilingIfNotGPU()); mfi.isValid(); ++mfi)
89 Box gbx = mfi.growntilebox(IntVect(1,1,0));
91 const Array4<Real >& z_t_arr = z_t_rk[level]->array(mfi);
92 const Array4<Real >& zp_t_arr = z_t_pert->array(mfi);
94 const Array4<Real const>& z_nd_new_arr = z_phys_nd_new[level]->const_array(mfi);
95 const Array4<Real const>& z_nd_old_arr = z_phys_nd[level]->const_array(mfi);
98 amrex::ParallelFor(gbx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept
101 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)
102 +z_nd_new_arr(i ,j+1,k) - z_nd_old_arr( i,j+1,k)
103 +z_nd_new_arr(i+1,j ,k) - z_nd_old_arr(i+1,j ,k)
104 +z_nd_new_arr(i ,j ,k) - z_nd_old_arr(i ,j ,k));
106 zp_t_arr(i,j,k) -= z_t_arr(i,j,k);
114 detJ_cc[level], r0, pi0, dtau, beta_s, phys_bc_type);
116 if (fast_step == 0) {
119 S_slow_rhs, S_old, S_stage, S_prim, pi_stage, fast_coeffs,
120 S_data, S_scratch, fine_geom,
121 solverChoice.gravity, solverChoice.use_lagged_delta_rt,
122 z_t_rk[level], z_t_pert.get(),
123 z_phys_nd[level], z_phys_nd_new[level], z_phys_nd_src[level],
124 detJ_cc[level], detJ_cc_new[level], detJ_cc_src[level],
125 dtau, beta_s, inv_fac,
126 mapfac_m[level], mapfac_u[level], mapfac_v[level],
127 fr_as_crse, fr_as_fine, l_use_moisture, l_reflux, l_implicit_substepping);
131 S_slow_rhs, S_data, S_stage, S_prim, pi_stage, fast_coeffs,
132 S_data, S_scratch, fine_geom,
133 solverChoice.gravity, solverChoice.use_lagged_delta_rt,
134 z_t_rk[level], z_t_pert.get(),
135 z_phys_nd[level], z_phys_nd_new[level], z_phys_nd_src[level],
136 detJ_cc[level], detJ_cc_new[level], detJ_cc_src[level],
137 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);
141 }
else if (solverChoice.mesh_type != MeshType::ConstantDz) {
142 if (fast_step == 0) {
147 detJ_cc[level], r0, pi0, dtau, beta_s, phys_bc_type);
152 S_slow_rhs, S_old, S_stage, S_prim, pi_stage, fast_coeffs,
153 S_data, S_scratch, fine_geom, solverChoice.gravity,
154 z_phys_nd[level], detJ_cc[level], dtau, beta_s, inv_fac,
155 mapfac_m[level], mapfac_u[level], mapfac_v[level],
156 fr_as_crse, fr_as_fine, l_use_moisture, l_reflux, l_implicit_substepping);
161 S_slow_rhs, S_data, S_stage, S_prim, pi_stage, fast_coeffs,
162 S_data, S_scratch, fine_geom, solverChoice.gravity,
163 z_phys_nd[level], detJ_cc[level], 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);
168 if (fast_step == 0) {
173 detJ_cc[level], r0, pi0, dtau, beta_s, phys_bc_type);
178 S_slow_rhs, S_old, S_stage, S_prim, pi_stage, fast_coeffs,
179 S_data, S_scratch, fine_geom, solverChoice.gravity,
180 dtau, beta_s, inv_fac,
181 mapfac_m[level], mapfac_u[level], mapfac_v[level],
182 fr_as_crse, fr_as_fine, l_use_moisture, l_reflux, l_implicit_substepping);
187 S_slow_rhs, S_data, S_stage, S_prim, pi_stage, fast_coeffs,
188 S_data, S_scratch, fine_geom, solverChoice.gravity,
189 dtau, beta_s, inv_fac,
190 mapfac_m[level], mapfac_u[level], mapfac_v[level],
191 fr_as_crse, fr_as_fine, l_use_moisture, l_reflux, l_implicit_substepping);
204 if (!solverChoice.use_num_diff) {
208 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 make_areas(const Geometry &geom, MultiFab &z_phys_nd, MultiFab &ax, MultiFab &ay, MultiFab &az)
Definition: ERF_TerrainMetrics.cpp:558
void make_terrain_fitted_coords(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:46
void make_J(const Geometry &geom, MultiFab &z_phys_nd, MultiFab &detJ_cc)
Definition: ERF_TerrainMetrics.cpp:520
@ cons
Definition: ERF_IndexDefines.H:150
@ zmom
Definition: ERF_IndexDefines.H:153
@ xmom
Definition: ERF_IndexDefines.H:151
static MeshType mesh_type
Definition: ERF_DataStruct.H:665