ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_Substep_NS.cpp File Reference
#include <ERF_TI_fast_headers.H>
#include "ERF_Constants.H"
Include dependency graph for ERF_Substep_NS.cpp:

Functions

void erf_substep_NS (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 &qt, const MultiFab &pi_stage, const MultiFab &fast_coeffs, Vector< MultiFab > &S_data, MultiFab &lagged_delta_rt, MultiFab &avg_xmom, MultiFab &avg_ymom, MultiFab &avg_zmom, const MultiFab &cc_src, const MultiFab &xmom_src, const MultiFab &ymom_src, const MultiFab &zmom_src, const Geometry geom, const Real gravity, amrex::Gpu::DeviceVector< amrex::Real > &stretched_dz_d, const double dtau_d, const Real facinv, Vector< std::unique_ptr< MultiFab >> &mapfac, YAFluxRegister *fr_as_crse, YAFluxRegister *fr_as_fine, bool l_use_moisture, bool l_reflux, bool l_real_bc, const amrex::Real *sinesq_stag_d, const Real l_damp_coef, const Real beta_d, const CFFaceFluxes &cf_fluxes, MultiFab *mom_reflux_p, const GpuArray< bool, 4 > &lateral_walls)
 

Function Documentation

◆ erf_substep_NS()

void erf_substep_NS ( 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 &  qt,
const MultiFab &  pi_stage,
const MultiFab &  fast_coeffs,
Vector< MultiFab > &  S_data,
MultiFab &  lagged_delta_rt,
MultiFab &  avg_xmom,
MultiFab &  avg_ymom,
MultiFab &  avg_zmom,
const MultiFab &  cc_src,
const MultiFab &  xmom_src,
const MultiFab &  ymom_src,
const MultiFab &  zmom_src,
const Geometry  geom,
const Real  gravity,
amrex::Gpu::DeviceVector< amrex::Real > &  stretched_dz_d,
const double  dtau_d,
const Real  facinv,
Vector< std::unique_ptr< MultiFab >> &  mapfac,
YAFluxRegister *  fr_as_crse,
YAFluxRegister *  fr_as_fine,
bool  l_use_moisture,
bool  l_reflux,
bool  l_real_bc,
const amrex::Real *  sinesq_stag_d,
const Real  l_damp_coef,
const Real  beta_d,
const CFFaceFluxes &  cf_fluxes,
MultiFab *  mom_reflux_p,
const GpuArray< bool, 4 > &  lateral_walls 
)

Function for computing the fast RHS with no terrain and variable vertical spacing

Parameters
[in]stepwhich fast time step within each Runge-Kutta step
[in]nrkwhich Runge-Kutta step
[in]levellevel of resolution
[in]finest_levelfinest level of resolution
[in]S_slow_rhsslow RHS computed in erf_slow_rhs_pre
[in]S_previf step == 0, this is S_old, else the previous fast solution
[in]S_stage_datasolution at previous RK stage
[in]S_stage_primprimitive variables at previous RK stage
[in]pi_stageExner function at previous RK stage
[in]fast_coeffscoefficients for the tridiagonal solve used in the fast integrator, and beta_s on the w-faces (component 5)
[out]S_datacurrent solution
[in,out]lagged_delta_rt
[in,out]avg_xmomtime-averaged x-momentum to be used for updating slow variables
[in,out]avg_ymomtime-averaged y-momentum to be used for updating slow variables
[in,out]avg_zmomtime-averaged z-momentum to be used for updating slow variables
[in]cc_srcsource terms for conserved variables
[in]xmom_srcsource terms for x-momentum
[in]ymom_srcsource terms for y-momentum
[in]zmom_srcsource terms for z-momentum
[in]geomcontainer for geometric information
[in]gravitymagnitude of gravity
[in]stretched_dz_d
[in]dtaufast time step
[in]facinvinverse factor for time-averaging the momenta
[in]mapfacvector of map factors
[in,out]fr_as_crseYAFluxRegister at level l at level l / l+1 interface
[in,out]fr_as_fineYAFluxRegister at level l at level l-1 / l interface
[in]l_use_moisture
[in]l_refluxshould we add fluxes to the FluxRegisters?
[in]l_real_bc
[in,out]cf_fluxescoarse/fine face fluxes: recorded here on a coarse level, imposed on a fine one
[in,out]mom_reflux_pif not null, the sum of the pressure the horizontal momenta see, added to (ERF_MomentumReflux.cpp)
[in]lateral_wallswhether the xlo, xhi, ylo and yhi faces are walls (zero normal velocity)
82 {
83  //
84  // NOTE: for step > 0, S_data and S_prev point to the same MultiFab data!!
85  //
86 
87  BL_PROFILE_REGION("erf_substep_NS()");
88 
89  Real dtau = static_cast<Real>(dtau_d);
90 
91  const Box& domain = geom.Domain();
92  auto const domlo = lbound(domain);
93  auto const domhi = ubound(domain);
94 
95  int ilo = domlo.x;
96  int ihi = domhi.x + 1;
97  int jlo = domlo.y;
98  int jhi = domhi.y + 1;
99 
100  // The substeps keep the normal momentum on a lateral wall face (slip, no-slip, symmetry or
101  // surface layer) at its stage value, zero on all but a symmetry face, as the terrain
102  // substeps do. The pressure gradient on a wall face, the difference of theta_extrap across
103  // it, is zero only while the ghost cell is an even reflection, which it is not on a wall
104  // with a given theta or density; and the fast sources in xmom_src and ymom_src (Rayleigh
105  // damping toward a nonzero mean wind) are not zero on the face either. Updating the face
106  // carried mass through the wall: on a slip or no-slip wall until the boundary fill reset it
107  // after the substep, and on a symmetry face, which the fill does not set and where the slow
108  // RHS is not zeroed, for good
109  const bool wall_xlo = lateral_walls[0];
110  const bool wall_xhi = lateral_walls[1];
111  const bool wall_ylo = lateral_walls[2];
112  const bool wall_yhi = lateral_walls[3];
113 
114  bool l_rayleigh_impl_for_w = (sinesq_stag_d != nullptr);
115 
116  const Real* dx = geom.CellSize();
117  const GpuArray<Real, AMREX_SPACEDIM> dxInv = geom.InvCellSizeArray();
118 
119  Real dxi = dxInv[0];
120  Real dyi = dxInv[1];
121  Real dzi = dxInv[2];
122 
123  auto dz_ptr = stretched_dz_d.data();
124  const bool l_stretched = (SolverChoice::mesh_type != MeshType::ConstantDz);
125 
126  const auto& ba = S_stage_data[IntVars::cons].boxArray();
127  const auto& dm = S_stage_data[IntVars::cons].DistributionMap();
128 
129  MultiFab Delta_rho_theta( ba , dm, 1, 1);
130  MultiFab Delta_rho_w (convert(ba,IntVect(0,0,1)), dm, 1, IntVect(1,1,0));
131 
132  MultiFab coeff_A_mf(fast_coeffs, make_alias, 0, 1);
133  MultiFab inv_coeff_B_mf(fast_coeffs, make_alias, 1, 1);
134  MultiFab coeff_C_mf(fast_coeffs, make_alias, 2, 1);
135  MultiFab coeff_P_mf(fast_coeffs, make_alias, 3, 1);
136  MultiFab coeff_Q_mf(fast_coeffs, make_alias, 4, 1);
137 
138  // beta_s on the w-faces, from which
139  // beta_1 = myhalf * (one - beta_s) multiplies explicit terms
140  // beta_2 = myhalf * (one + beta_s) multiplies implicit terms
141  MultiFab beta_s_mf(fast_coeffs, make_alias, 5, 1);
142 
143  // *************************************************************************
144  // Set gravity as a vector
145  const Array<Real,AMREX_SPACEDIM> grav{zero, zero, -gravity};
146  const GpuArray<Real,AMREX_SPACEDIM> grav_gpu{grav[0], grav[1], grav[2]};
147 
148  // This will hold theta extrapolated forward in time
149  MultiFab extrap(S_data[IntVars::cons].boxArray(),S_data[IntVars::cons].DistributionMap(),1,1);
150 
151  // This will hold the update for (rho) and (rho theta)
152  MultiFab temp_rhs(S_stage_data[IntVars::zmom].boxArray(),S_stage_data[IntVars::zmom].DistributionMap(),2,0);
153 
154  // This will hold the new x- and y-momenta temporarily (so that we don't overwrite values we need when tiling)
155  MultiFab temp_cur_xmom(S_stage_data[IntVars::xmom].boxArray(),S_stage_data[IntVars::xmom].DistributionMap(),1,0);
156  MultiFab temp_cur_ymom(S_stage_data[IntVars::ymom].boxArray(),S_stage_data[IntVars::ymom].DistributionMap(),1,0);
157 
158  // We assume that in the first step (nrk == 0) we are only doing one substep.
159  AMREX_ALWAYS_ASSERT(nrk > 0 || step == 0);
160 
161  // *************************************************************************
162  // First set up some arrays we'll need
163  // *************************************************************************
164 
165 #ifdef _OPENMP
166 #pragma omp parallel if (Gpu::notInLaunchRegion())
167 #endif
168  for ( MFIter mfi(S_stage_data[IntVars::cons],TilingIfNotGPU()); mfi.isValid(); ++mfi)
169  {
170  const Array4<const Real>& prev_cons = S_prev[IntVars::cons].const_array(mfi);
171  const Array4<const Real>& prev_zmom = S_prev[IntVars::zmom].const_array(mfi);
172 
173  const Array4<const Real>& stage_cons = S_stage_data[IntVars::cons].const_array(mfi);
174  const Array4<const Real>& stage_zmom = S_stage_data[IntVars::zmom].const_array(mfi);
175 
176  const Array4<Real>& prev_drho_w = Delta_rho_w.array(mfi);
177  const Array4<Real>& prev_drho_theta = Delta_rho_theta.array(mfi);
178  const Array4<Real>& lagged_arr = lagged_delta_rt.array(mfi);
179  const Array4<Real>& theta_extrap = extrap.array(mfi);
180  const Array4<const Real>& prim = S_stage_prim.const_array(mfi);
181 
182  Box gbx = mfi.growntilebox(1);
183  ParallelFor(gbx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
184  {
185  prev_drho_theta(i,j,k) = prev_cons(i,j,k,RhoTheta_comp) - stage_cons(i,j,k,RhoTheta_comp);
186 
187  if (step == 0) {
188  theta_extrap(i,j,k) = prev_drho_theta(i,j,k);
189  } else {
190  theta_extrap(i,j,k) = prev_drho_theta(i,j,k) + beta_d *
191  ( prev_drho_theta(i,j,k) - lagged_arr(i,j,k) );
192  }
193 
194  // NOTE: qv is not changing over the fast steps so we use the stage data
195  Real qv = (l_use_moisture) ? prim(i,j,k,PrimQ1_comp) : zero;
196  theta_extrap(i,j,k) *= (one + RvoRd*qv);
197 
198  // We define lagged_delta_rt for our next step as the current delta_rt
199  // (after using it above to extrapolate theta for this step)
200  lagged_arr(i,j,k) = prev_drho_theta(i,j,k);
201  });
202 
203  // The acoustic pressure the horizontal momenta see in this substep, gamma R_d pi (rho theta)'',
204  // for the reflux of the pressure impulse on the coarse/fine faces (ERF_MomentumReflux.cpp)
205  if (mom_reflux_p && !(nrk == 0 && step == 0)) {
206  const Array4<Real>& p_reflux = mom_reflux_p->array(mfi);
207  const Array4<const Real>& pi_arr = pi_stage.const_array(mfi);
208  const Array4<const Real>& qt_arr = qt.const_array(mfi);
209  ParallelFor(mfi.tilebox(), [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
210  {
211  Real q = (l_use_moisture) ? qt_arr(i,j,k) : zero;
212  p_reflux(i,j,k) += dtau * Gamma * R_d * pi_arr(i,j,k,0) * theta_extrap(i,j,k) / (one + q);
213  });
214  }
215 
216  // NOTE: We must do this here because for step > 0, prev_zmom and cur_zmom both point to the same data,
217  // so by the time we would use prev_zmom to define zflux, it would have already been over-written.
218  //
219  // NOTE: grownnodaltilebox, not nodaltilebox(2) grown by hand. Growing by hand pushes
220  // every tile one cell past its own share of the grid in x and y, so once the grid
221  // is tiled two tiles write the same Delta_rho_w cells -- a data race under OpenMP,
222  // even though both store the same value. This is identical to the old expression
223  // when there is one tile per grid.
224  //
225  Box gtbz = mfi.grownnodaltilebox(2,IntVect(1,1,0));
226  ParallelFor(gtbz, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
227  prev_drho_w(i,j,k) = prev_zmom(i,j,k) - stage_zmom(i,j,k);
228  });
229  } // mfi
230 
231  // *************************************************************************
232  // Define updates in the current RK stage
233  // *************************************************************************
234 
235 #ifdef _OPENMP
236 #pragma omp parallel if (Gpu::notInLaunchRegion())
237 #endif
238  for ( MFIter mfi(S_stage_data[IntVars::cons],TilingIfNotGPU()); mfi.isValid(); ++mfi)
239  {
240  Box tbx = mfi.nodaltilebox(0);
241  Box tby = mfi.nodaltilebox(1);
242 
243  const Array4<Real const>& xmom_src_arr = xmom_src.const_array(mfi);
244  const Array4<Real const>& ymom_src_arr = ymom_src.const_array(mfi);
245 
246  const Array4<const Real> & stage_xmom = S_stage_data[IntVars::xmom].const_array(mfi);
247  const Array4<const Real> & stage_ymom = S_stage_data[IntVars::ymom].const_array(mfi);
248  const Array4<const Real> & qt_arr = qt.const_array(mfi);
249 
250  const Array4<const Real>& slow_rhs_rho_u = S_slow_rhs[IntVars::xmom].const_array(mfi);
251  const Array4<const Real>& slow_rhs_rho_v = S_slow_rhs[IntVars::ymom].const_array(mfi);
252 
253  const Array4<Real>& temp_cur_xmom_arr = temp_cur_xmom.array(mfi);
254  const Array4<Real>& temp_cur_ymom_arr = temp_cur_ymom.array(mfi);
255 
256  const Array4<const Real>& prev_xmom = S_prev[IntVars::xmom].const_array(mfi);
257  const Array4<const Real>& prev_ymom = S_prev[IntVars::ymom].const_array(mfi);
258 
259  // These store the advection momenta which we will use to update the slow variables
260  const Array4< Real>& avg_xmom_arr = avg_xmom.array(mfi);
261  const Array4< Real>& avg_ymom_arr = avg_ymom.array(mfi);
262 
263  const Array4<const Real>& pi_stage_ca = pi_stage.const_array(mfi);
264 
265  const Array4<Real>& theta_extrap = extrap.array(mfi);
266 
267  // Map factors
268  const Array4<const Real>& mf_ux = mapfac[MapFacType::u_x]->const_array(mfi);
269  const Array4<const Real>& mf_uy = mapfac[MapFacType::u_y]->const_array(mfi);
270  const Array4<const Real>& mf_vx = mapfac[MapFacType::v_x]->const_array(mfi);
271  const Array4<const Real>& mf_vy = mapfac[MapFacType::v_y]->const_array(mfi);
272 
273  // *********************************************************************
274  // Define updates in the RHS of {x, y, z}-momentum equations
275  //
276  // NOTE: avg_{x,y}mom is a *flux* that is later handed to the scalar
277  // advection in erf_slow_rhs_post, which applies (mfsq/detJ) to its
278  // divergence. So what we accumulate here must be in the same
279  // convention as the base value set in AdvectionSrcForRho, namely
280  // ax*rho_u/mf_uy (and ay*rho_v/mf_vx). Two weightings are needed:
281  //
282  // (1) the map factor, matching the density fluxes formed below;
283  //
284  // (2) h_zeta = ax = detJ, which for this (laterally homogeneous)
285  // mesh is just dz_ptr[k]/dz. Note this factor cancels out of
286  // the rho update we do here -- temp_rhs uses a bare dxi and no
287  // 1/detJ -- but it does NOT cancel for avg_{x,y}mom, because
288  // the consumer downstream re-applies the 1/detJ that we never
289  // applied. It is identically 1 for MeshType::ConstantDz.
290  // *********************************************************************
291  if (nrk == 0 and step == 0) { // prev == stage
292  // The wall faces are held here too, for consistency with the branch below. This
293  // branch runs only in the first RK stage, whose result feeds only the next stage's
294  // slow RHS, so the domain mass at the end of the step does not show these guards
295  ParallelFor(tbx, tby,
296  [=] AMREX_GPU_DEVICE (int i, int j, int k)
297  {
298  Real h_zeta = dz_ptr[k] * dzi;
299  Real new_drho_u = dtau * slow_rhs_rho_u(i,j,k) + dtau * xmom_src_arr(i,j,k);
300  if ((wall_xlo && i == ilo) || (wall_xhi && i == ihi)) { new_drho_u = zero; }
301  avg_xmom_arr(i,j,k) += facinv * new_drho_u * h_zeta / mf_uy(i,j,0);
302  temp_cur_xmom_arr(i,j,k) = stage_xmom(i,j,k) + new_drho_u;
303  },
304  [=] AMREX_GPU_DEVICE (int i, int j, int k)
305  {
306  Real h_zeta = dz_ptr[k] * dzi;
307  Real new_drho_v = dtau * slow_rhs_rho_v(i,j,k) + dtau * ymom_src_arr(i,j,k);
308  if ((wall_ylo && j == jlo) || (wall_yhi && j == jhi)) { new_drho_v = zero; }
309  avg_ymom_arr(i,j,k) += facinv * new_drho_v * h_zeta / mf_vx(i,j,0);
310  temp_cur_ymom_arr(i,j,k) = stage_ymom(i,j,k) + new_drho_v;
311  });
312  } else {
313  ParallelFor(tbx, tby,
314  [=] AMREX_GPU_DEVICE (int i, int j, int k)
315  {
316  // Add (negative) gradient of (rho theta) multiplied by lagged "pi"
317  Real gpx = (l_real_bc && (level==0) && (i==ilo || i==ihi)) ? Real(0.) :
318  (theta_extrap(i,j,k) - theta_extrap(i-1,j,k))*dxi;
319  gpx *= mf_ux(i,j,0);
320 
321  Real q = (l_use_moisture) ? myhalf * (qt_arr(i,j,k) + qt_arr(i-1,j,k)) : zero;
322 
323  Real pi_c = myhalf * (pi_stage_ca(i-1,j,k,0) + pi_stage_ca(i,j,k,0));
324  Real fast_rhs_rho_u = -Gamma * R_d * pi_c * gpx / (one + q);
325 
326  Real new_drho_u = prev_xmom(i,j,k) - stage_xmom(i,j,k)
327  + dtau * fast_rhs_rho_u + dtau * slow_rhs_rho_u(i,j,k)
328  + dtau * xmom_src_arr(i,j,k);
329  if ((wall_xlo && i == ilo) || (wall_xhi && i == ihi)) { new_drho_u = zero; }
330 
331  Real h_zeta = dz_ptr[k] * dzi;
332  avg_xmom_arr(i,j,k) += facinv * new_drho_u * h_zeta / mf_uy(i,j,0);
333 
334  temp_cur_xmom_arr(i,j,k) = stage_xmom(i,j,k) + new_drho_u;
335  },
336  [=] AMREX_GPU_DEVICE (int i, int j, int k)
337  {
338  // Add (negative) gradient of (rho theta) multiplied by lagged "pi"
339  Real gpy = (l_real_bc && (level==0) && (j==jlo || j==jhi)) ? Real(0.) :
340  (theta_extrap(i,j,k) - theta_extrap(i,j-1,k))*dyi;
341  gpy *= mf_vy(i,j,0);
342 
343  Real q = (l_use_moisture) ? myhalf * (qt_arr(i,j,k) + qt_arr(i,j-1,k)) : zero;
344 
345  Real pi_c = myhalf * (pi_stage_ca(i,j-1,k,0) + pi_stage_ca(i,j,k,0));
346  Real fast_rhs_rho_v = -Gamma * R_d * pi_c * gpy / (one + q);
347 
348  Real new_drho_v = prev_ymom(i,j,k) - stage_ymom(i,j,k)
349  + dtau * fast_rhs_rho_v + dtau * slow_rhs_rho_v(i,j,k)
350  + dtau * ymom_src_arr(i,j,k);
351  if ((wall_ylo && j == jlo) || (wall_yhi && j == jhi)) { new_drho_v = zero; }
352 
353  Real h_zeta = dz_ptr[k] * dzi;
354  avg_ymom_arr(i,j,k) += facinv * new_drho_v * h_zeta / mf_vx(i,j,0);
355 
356  temp_cur_ymom_arr(i,j,k) = stage_ymom(i,j,k) + new_drho_v;
357  });
358  } // nrk > 0 and/or step > 0
359 
360  // On the coarse/fine faces of a fine level, the coarse level's flux over this substep
361  // (CFFaceFluxes) in place of the level's own
362  for (int dir = 0; dir < 2; ++dir) {
363  if (!cf_fluxes.tgt[dir]) { continue; }
364  const Box& fbx = (dir == 0) ? tbx : tby;
365  const Array4<const Real>& tgt = cf_fluxes.tgt[dir]->const_array(mfi);
366  const Array4<Real>& cur = (dir == 0) ? temp_cur_xmom_arr : temp_cur_ymom_arr;
367  const Array4<Real>& avg = (dir == 0) ? avg_xmom_arr : avg_ymom_arr;
368  const Array4<const Real>& mf = (dir == 0) ? mf_uy : mf_vx;
369  ParallelFor(fbx, [=] AMREX_GPU_DEVICE (int i, int j, int k)
370  {
371  if (tgt(i,j,k,1) > myhalf) {
372  Real new_mom = tgt(i,j,k,0) * mf(i,j,0);
373  Real h_zeta = dz_ptr[k] * dzi;
374  avg(i,j,k) += facinv * (new_mom - cur(i,j,k)) * h_zeta / mf(i,j,0);
375  cur(i,j,k) = new_mom;
376  }
377  });
378  }
379 
380  // On a coarse level, the flux each face applied over this substep
381  for (int dir = 0; dir < 2; ++dir) {
382  if (!cf_fluxes.rec[dir]) { continue; }
383  const Box& fbx = (dir == 0) ? tbx : tby;
384  const Array4<Real>& rec = cf_fluxes.rec[dir]->array(mfi);
385  const Array4<const Real>& cur = (dir == 0) ? temp_cur_xmom_arr : temp_cur_ymom_arr;
386  const Array4<const Real>& mf = (dir == 0) ? mf_uy : mf_vx;
387  ParallelFor(fbx, [=] AMREX_GPU_DEVICE (int i, int j, int k)
388  {
389  rec(i,j,k) = cur(i,j,k) / mf(i,j,0);
390  });
391  }
392  } //mfi
393 
394 #ifdef _OPENMP
395 #pragma omp parallel if (Gpu::notInLaunchRegion())
396 #endif
397  {
398  std::array<FArrayBox,AMREX_SPACEDIM> flux;
399  for ( MFIter mfi(S_stage_data[IntVars::cons],TileNoZ()); mfi.isValid(); ++mfi)
400  {
401  Box bx = mfi.tilebox();
402  Box tbz = surroundingNodes(bx,2);
403 
404  Box vbx = mfi.validbox();
405  const auto& vbx_hi = ubound(vbx);
406 
407  // The flux arrays cover the faces of the tile, so the faces on its high sides are
408  // written by the cells at the high end of the tile, not of the valid box
409  const auto& bx_hi = ubound(bx);
410 
411  const Array4<Real const>& zmom_src_arr = zmom_src.const_array(mfi);
412 
413  const Array4<const Real>& stage_xmom = S_stage_data[IntVars::xmom].const_array(mfi);
414  const Array4<const Real>& stage_ymom = S_stage_data[IntVars::ymom].const_array(mfi);
415  const Array4<const Real>& stage_zmom = S_stage_data[IntVars::zmom].const_array(mfi);
416  const Array4<const Real> & prim = S_stage_prim.const_array(mfi);
417 
418  const Array4<const Real>& prev_drho_theta = Delta_rho_theta.array(mfi);
419 
420  const Array4<const Real>& prev_cons = S_prev[IntVars::cons].const_array(mfi);
421  const Array4<const Real>& stage_cons = S_stage_data[IntVars::cons].const_array(mfi);
422 
423  const Array4<const Real>& slow_rhs_cons = S_slow_rhs[IntVars::cons].const_array(mfi);
424  const Array4<const Real>& slow_rhs_rho_w = S_slow_rhs[IntVars::zmom].const_array(mfi);
425 
426  const Array4<const Real>& prev_zmom = S_prev[IntVars::zmom].const_array(mfi);
427  const Array4< Real>& cur_zmom = S_data[IntVars::zmom].array(mfi);
428 
429  const Array4<Real>& temp_cur_xmom_arr = temp_cur_xmom.array(mfi);
430  const Array4<Real>& temp_cur_ymom_arr = temp_cur_ymom.array(mfi);
431 
432  // These store the advection momenta which we will use to update the slow variables
433  const Array4< Real>& avg_zmom_arr = avg_zmom.array(mfi);
434 
435  // Map factors
436  const Array4<const Real>& mf_mx = mapfac[MapFacType::m_x]->const_array(mfi);
437  const Array4<const Real>& mf_my = mapfac[MapFacType::m_y]->const_array(mfi);
438  const Array4<const Real>& mf_uy = mapfac[MapFacType::u_y]->const_array(mfi);
439  const Array4<const Real>& mf_vx = mapfac[MapFacType::v_x]->const_array(mfi);
440 
441  FArrayBox RHS_fab;
442  RHS_fab.resize(tbz,1, The_Async_Arena());
443 
444  FArrayBox soln_fab;
445  soln_fab.resize(tbz,1, The_Async_Arena());
446 
447  auto const& RHS_a = RHS_fab.array();
448  auto const& soln_a = soln_fab.array();
449 
450  auto const& temp_rhs_arr = temp_rhs.array(mfi);
451 
452  auto const& coeffA_a = coeff_A_mf.array(mfi);
453  auto const& inv_coeffB_a = inv_coeff_B_mf.array(mfi);
454  auto const& coeffC_a = coeff_C_mf.array(mfi);
455  auto const& coeffP_a = coeff_P_mf.array(mfi);
456  auto const& coeffQ_a = coeff_Q_mf.array(mfi);
457  auto const& beta_s_a = beta_s_mf.const_array(mfi);
458 
459  // *************************************************************************
460  // Define flux arrays for use in advection
461  // *************************************************************************
462  for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
463  flux[dir].resize(surroundingNodes(bx,dir),2,The_Async_Arena());
464  flux[dir].setVal<RunOn::Device>(0);
465  }
466  const GpuArray<const Array4<Real>, AMREX_SPACEDIM>
467  flx_arr{{AMREX_D_DECL(flux[0].array(), flux[1].array(), flux[2].array())}};
468 
469  // *********************************************************************
470  ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
471  Real xflux_lo = (temp_cur_xmom_arr(i ,j,k) - stage_xmom(i ,j,k)) / mf_uy(i ,j,0);
472  Real xflux_hi = (temp_cur_xmom_arr(i+1,j,k) - stage_xmom(i+1,j,k)) / mf_uy(i+1,j,0);
473  Real yflux_lo = (temp_cur_ymom_arr(i,j ,k) - stage_ymom(i,j ,k)) / mf_vx(i,j ,0);
474  Real yflux_hi = (temp_cur_ymom_arr(i,j+1,k) - stage_ymom(i,j+1,k)) / mf_vx(i,j+1,0);
475 
476  Real mfsq = mf_mx(i,j,0) * mf_my(i,j,0);
477 
478  temp_rhs_arr(i,j,k,Rho_comp ) = ( xflux_hi - xflux_lo ) * dxi * mfsq
479  + ( yflux_hi - yflux_lo ) * dyi * mfsq;
480  temp_rhs_arr(i,j,k,RhoTheta_comp) = (( xflux_hi * (prim(i,j,k,0) + prim(i+1,j,k,0)) -
481  xflux_lo * (prim(i,j,k,0) + prim(i-1,j,k,0)) ) * dxi * mfsq +
482  ( yflux_hi * (prim(i,j,k,0) + prim(i,j+1,k,0)) -
483  yflux_lo * (prim(i,j,k,0) + prim(i,j-1,k,0)) ) * dyi * mfsq) * myhalf;
484 
485  if (l_reflux) {
486  // The flux registers take fluxes through the face area h_zeta = dz_ptr[k]/dz, as the
487  // slow fluxes are (ax*rho_u/mf_uy): ERF::post_timestep divides the correction by detJ
488  const Real h_zeta = (l_stretched) ? dz_ptr[k] * dzi : one;
489 
490  (flx_arr[0])(i,j,k,0) = xflux_lo * h_zeta;
491  (flx_arr[0])(i,j,k,1) = (flx_arr[0])(i ,j,k,0) * myhalf * (prim(i,j,k,0) + prim(i-1,j,k,0));
492 
493  (flx_arr[1])(i,j,k,0) = yflux_lo * h_zeta;
494  (flx_arr[1])(i,j,k,1) = (flx_arr[1])(i,j ,k,0) * myhalf * (prim(i,j,k,0) + prim(i,j-1,k,0));
495 
496  if (i == bx_hi.x) {
497  (flx_arr[0])(i+1,j,k,0) = xflux_hi * h_zeta;
498  (flx_arr[0])(i+1,j,k,1) = (flx_arr[0])(i+1,j,k,0) * myhalf * (prim(i,j,k,0) + prim(i+1,j,k,0));
499  }
500  if (j == bx_hi.y) {
501  (flx_arr[1])(i,j+1,k,0) = yflux_hi * h_zeta;
502  (flx_arr[1])(i,j+1,k,1) = (flx_arr[1])(i,j+1,k,0) * myhalf * (prim(i,j,k,0) + prim(i,j+1,k,0));
503  }
504  }
505  });
506 
507  Box bx_shrunk_in_k = bx;
508  int klo = tbz.smallEnd(2);
509  int khi = tbz.bigEnd(2);
510  bx_shrunk_in_k.setSmall(2,klo+1);
511  bx_shrunk_in_k.setBig(2,khi-1);
512 
513  // Note that the notes use "g" to mean the magnitude of gravity, so it is positive
514  // We set grav_gpu[2] to be the vector component which is negative
515  // We define halfg to match the notes (which is why we take the absolute value)
516  Real halfg = std::abs(myhalf * grav_gpu[2]);
517 
518  // *********************************************************************
519  // fast_loop_on_shrunk
520  // *********************************************************************
521  //Note we don't act on the bottom or top boundaries of the domain
522  ParallelFor(bx_shrunk_in_k, [=] AMREX_GPU_DEVICE (int i, int j, int k)
523  {
524  Real coeff_P = coeffP_a(i,j,k);
525  Real coeff_Q = coeffQ_a(i,j,k);
526 
527  Real theta_t_lo = myhalf * ( prim(i,j,k-2,PrimTheta_comp) + prim(i,j,k-1,PrimTheta_comp) );
528  Real theta_t_mid = myhalf * ( prim(i,j,k-1,PrimTheta_comp) + prim(i,j,k ,PrimTheta_comp) );
529  Real theta_t_hi = myhalf * ( prim(i,j,k ,PrimTheta_comp) + prim(i,j,k+1,PrimTheta_comp) );
530 
531  Real Omega_kp1 = prev_zmom(i,j,k+1) - stage_zmom(i,j,k+1);
532  Real Omega_k = prev_zmom(i,j,k ) - stage_zmom(i,j,k );
533  Real Omega_km1 = prev_zmom(i,j,k-1) - stage_zmom(i,j,k-1);
534 
535  // line 2 last two terms (order dtau)
536  Real old_drho_k = prev_cons(i,j,k ,Rho_comp) - stage_cons(i,j,k ,Rho_comp);
537  Real old_drho_km1 = prev_cons(i,j,k-1,Rho_comp) - stage_cons(i,j,k-1,Rho_comp);
538  Real R0_tmp = coeff_P * prev_drho_theta(i,j,k) + coeff_Q * prev_drho_theta(i,j,k-1)
539  - halfg * ( old_drho_k + old_drho_km1 );
540 
541  // lines 3-5 residuals (order dtau^2) one <-> beta_2
542  Real R1_tmp = halfg * (-slow_rhs_cons(i,j,k ,Rho_comp) - slow_rhs_cons(i,j,k-1,Rho_comp)
543  + temp_rhs_arr(i,j,k ,Rho_comp) + temp_rhs_arr(i,j,k-1,Rho_comp) )
544  + ( coeff_P * (slow_rhs_cons(i,j,k ,RhoTheta_comp) - temp_rhs_arr(i,j,k ,RhoTheta_comp)) +
545  coeff_Q * (slow_rhs_cons(i,j,k-1,RhoTheta_comp) - temp_rhs_arr(i,j,k-1,RhoTheta_comp)) );
546 
547  // Explicit part of the vertical flux on each face is beta_1 * Omega. beta_1 on face k
548  // is factored out, and dbeta_1 is how much larger beta_1 is on the neighboring faces,
549  // which is exactly zero (so the roundoff is that of a scalar beta_1) for uniform beta_s
550  Real beta_1 = myhalf * (one - beta_s_a(i,j,k));
551  Real dbeta_1_kp1 = myhalf * (one - beta_s_a(i,j,k+1)) - beta_1;
552  Real dbeta_1_km1 = myhalf * (one - beta_s_a(i,j,k-1)) - beta_1;
553 
554  // lines 6&7 consolidated (reuse Omega & metrics) (order dtau^2)
555  R1_tmp += beta_1 * ( ( (Omega_kp1 - Omega_k) / dz_ptr[k] + (Omega_k - Omega_km1) / dz_ptr[k-1] ) * halfg
556  +(-(Omega_kp1*theta_t_hi - Omega_k *theta_t_mid) * coeff_P / dz_ptr[k]
557  -(Omega_k *theta_t_mid - Omega_km1*theta_t_lo ) * coeff_Q / dz_ptr[k-1]) )
558  + ( ( dbeta_1_kp1*Omega_kp1 / dz_ptr[k] - dbeta_1_km1*Omega_km1 / dz_ptr[k-1] ) * halfg
559  - dbeta_1_kp1*Omega_kp1*theta_t_hi * coeff_P / dz_ptr[k]
560  + dbeta_1_km1*Omega_km1*theta_t_lo * coeff_Q / dz_ptr[k-1] );
561 
562  // line 1
563  Real beta_2 = myhalf * (one + beta_s_a(i,j,k));
564  RHS_a(i,j,k) = Omega_k + dtau * (slow_rhs_rho_w(i,j,k) + R0_tmp + dtau * beta_2 * R1_tmp + zmom_src_arr(i,j,k));
565 
566  }); // bx_shrunk_in_k
567 
568  Box b2d = tbz;
569  b2d.setRange(2,0);
570 
571  auto const lo = lbound(bx);
572  auto const hi = ubound(bx);
573 
574  ParallelFor(b2d, [=] AMREX_GPU_DEVICE (int i, int j, int)
575  {
576  // NOTE: RHS is built on a shrunk box in z, explicitly set
577  // the lo and hi faces here
578  // On a box face inside the domain (a c/f face), w = w_old + dtau * slow_rhs.
579  // At the domain bottom and top the row is zero: W'' = 0 at the ground and at
580  // a wall, and W''_top = W''_top-1 for outflow, the matrix row set in
581  // make_fast_coeffs deciding which
582  RHS_a (i,j,lo.z) = (lo.z == domlo.z)
583  ? zero
584  : prev_zmom(i,j,lo.z) - stage_zmom(i,j,lo.z)
585  + dtau * slow_rhs_rho_w(i,j,lo.z)
586  + dtau * zmom_src_arr(i,j,lo.z);
587 
588  RHS_a (i,j,hi.z+1) = (hi.z == domhi.z)
589  ? zero
590  : prev_zmom(i,j,hi.z+1) - stage_zmom(i,j,hi.z+1)
591  + dtau * slow_rhs_rho_w(i,j,hi.z+1)
592  + dtau * zmom_src_arr(i,j,hi.z+1);
593  }); // b2d
594 
595  // (rho w) on the coarse/fine faces of a fine level at the end of this substep, from the coarse level
596  if (cf_fluxes.tgt_w) {
597  const Array4<const Real>& tgt = cf_fluxes.tgt[2]->const_array(mfi);
598  const Array4<const Real>& tgt_w = cf_fluxes.tgt_w->const_array(mfi);
599  ParallelFor(b2d, [=] AMREX_GPU_DEVICE (int i, int j, int)
600  {
601  if (tgt(i,j,lo.z,1) > myhalf) {
602  RHS_a(i,j,lo.z) = tgt_w(i,j,lo.z) - stage_zmom(i,j,lo.z);
603  }
604  if (tgt(i,j,hi.z+1,1) > myhalf) {
605  RHS_a(i,j,hi.z+1) = tgt_w(i,j,hi.z+1) - stage_zmom(i,j,hi.z+1);
606  }
607  });
608  }
609 
610 #ifdef AMREX_USE_GPU
611  ParallelFor(b2d, [=] AMREX_GPU_DEVICE (int i, int j, int)
612  {
613  // Dirichlet condition at k = lo.z
614  soln_a(i,j,lo.z) = RHS_a(i,j,lo.z) * inv_coeffB_a(i,j,lo.z);
615  cur_zmom(i,j,lo.z) = stage_zmom(i,j,lo.z) + soln_a(i,j,lo.z);
616 
617  for (int k = lo.z+1; k <= hi.z+1; k++) {
618  soln_a(i,j,k) = (RHS_a(i,j,k)-coeffA_a(i,j,k)*soln_a(i,j,k-1)) * inv_coeffB_a(i,j,k);
619  }
620 
621  cur_zmom(i,j,hi.z+1) = stage_zmom(i,j,hi.z+1) + soln_a(i,j,hi.z+1);
622 
623  for (int k = hi.z; k >= lo.z; k--) {
624  soln_a(i,j,k) -= ( coeffC_a(i,j,k) * inv_coeffB_a(i,j,k) ) *soln_a(i,j,k+1);
625  cur_zmom(i,j,k) = stage_zmom(i,j,k) + soln_a(i,j,k);
626  }
627  }); // b2d
628 #else
629  for (int j = lo.y; j <= hi.y; ++j) {
630  AMREX_PRAGMA_SIMD
631  for (int i = lo.x; i <= hi.x; ++i) {
632  soln_a(i,j,lo.z) = RHS_a(i,j,lo.z) * inv_coeffB_a(i,j,lo.z);
633  }
634  }
635  for (int k = lo.z+1; k <= hi.z+1; ++k) {
636  for (int j = lo.y; j <= hi.y; ++j) {
637  AMREX_PRAGMA_SIMD
638  for (int i = lo.x; i <= hi.x; ++i) {
639  soln_a(i,j,k) = (RHS_a(i,j,k)-coeffA_a(i,j,k)*soln_a(i,j,k-1)) * inv_coeffB_a(i,j,k);
640  }
641  }
642  }
643  for (int j = lo.y; j <= hi.y; ++j) {
644  AMREX_PRAGMA_SIMD
645  for (int i = lo.x; i <= hi.x; ++i) {
646  cur_zmom(i,j,hi.z+1) = stage_zmom(i,j,hi.z+1) + soln_a(i,j,hi.z+1);
647  }
648  }
649  for (int k = hi.z; k >= lo.z; --k) {
650  for (int j = lo.y; j <= hi.y; ++j) {
651  AMREX_PRAGMA_SIMD
652  for (int i = lo.x; i <= hi.x; ++i) {
653  soln_a(i,j,k) -= ( coeffC_a(i,j,k) * inv_coeffB_a(i,j,k) ) * soln_a(i,j,k+1);
654  cur_zmom(i,j,k) = stage_zmom(i,j,k) + soln_a(i,j,k);
655  }
656  }
657  }
658 #endif
659  if (l_rayleigh_impl_for_w) {
660  // Every face but the ground, as in erf_substep_T: the top face is no longer
661  // pinned with an outflow top, and the faces at the ends of the box are solved for.
662  // A coarse/fine face whose (rho w) is imposed from the coarse level's record is not
663  // damped: the coarse level has damped it already, and it must match the record
664  const bool has_tgt_w = (cf_fluxes.tgt_w != nullptr);
665  const Array4<const Real> tgt_flag = (has_tgt_w) ? cf_fluxes.tgt[2]->const_array(mfi) : Array4<const Real>{};
666  ParallelFor(tbz, [=] AMREX_GPU_DEVICE (int i, int j, int k)
667  {
668  const bool imposed = has_tgt_w && (tgt_flag(i,j,k,1) > myhalf);
669  if (k > domlo.z && !imposed) {
670  Real damping_coeff = l_damp_coef * dtau * sinesq_stag_d[k];
671  cur_zmom(i,j,k) /= (one + damping_coeff);
672  }
673  });
674  }
675 
676  // **************************************************************************
677  // Define updates in the RHS of rho and (rho theta)
678  // **************************************************************************
679  const Array4<Real>& prev_drho_w = Delta_rho_w.array(mfi);
680  const bool has_tgt_z = (cf_fluxes.tgt[2] != nullptr);
681  const bool has_rec_z = (cf_fluxes.rec[2] != nullptr);
682  const Array4<const Real> tgt_z = (has_tgt_z) ? cf_fluxes.tgt[2]->const_array(mfi) : Array4<const Real>{};
683  const Array4< Real> rec_z = (has_rec_z) ? cf_fluxes.rec[2]->array(mfi) : Array4<Real>{};
684  ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
685  {
686  Real zflux_lo = myhalf * (one + beta_s_a(i,j,k )) * soln_a(i,j,k )
687  + myhalf * (one - beta_s_a(i,j,k )) * prev_drho_w(i,j,k );
688  Real zflux_hi = myhalf * (one + beta_s_a(i,j,k+1)) * soln_a(i,j,k+1)
689  + myhalf * (one - beta_s_a(i,j,k+1)) * prev_drho_w(i,j,k+1);
690 
691  // On the coarse/fine faces of a fine level, the coarse level's flux over this substep
692  if (has_tgt_z) {
693  Real mfsq = mf_mx(i,j,0) * mf_my(i,j,0);
694  if (tgt_z(i,j,k ,1) > myhalf) { zflux_lo = tgt_z(i,j,k ,0) * mfsq - stage_zmom(i,j,k ); }
695  if (tgt_z(i,j,k+1,1) > myhalf) { zflux_hi = tgt_z(i,j,k+1,0) * mfsq - stage_zmom(i,j,k+1); }
696  }
697 
698  // On a coarse level, the flux each face applied over this substep
699  if (has_rec_z) {
700  Real mfsq = mf_mx(i,j,0) * mf_my(i,j,0);
701  rec_z(i,j,k) = (zflux_lo + stage_zmom(i,j,k)) / mfsq;
702  if (k == vbx_hi.z) {
703  rec_z(i,j,k+1) = (zflux_hi + stage_zmom(i,j,k+1)) / mfsq;
704  }
705  }
706 
707  avg_zmom_arr(i,j,k) += facinv*zflux_lo / (mf_mx(i,j,0) * mf_my(i,j,0));
708  if (l_reflux) {
709  (flx_arr[2])(i,j,k,0) = zflux_lo / (mf_mx(i,j,0) * mf_my(i,j,0));
710  (flx_arr[2])(i,j,k,1) = (flx_arr[2])(i,j,k,0) * myhalf * (prim(i,j,k) + prim(i,j,k-1));
711  }
712 
713  if (k == vbx_hi.z) {
714  avg_zmom_arr(i,j,k+1) += facinv * zflux_hi / (mf_mx(i,j,0) * mf_my(i,j,0));
715  if (l_reflux) {
716  (flx_arr[2])(i,j,k+1,0) = zflux_hi / (mf_mx(i,j,0) * mf_my(i,j,0));
717  (flx_arr[2])(i,j,k+1,1) = (flx_arr[2])(i,j,k+1,0) * myhalf * (prim(i,j,k) + prim(i,j,k+1));
718  }
719  }
720 
721  Real dz_inv = one / dz_ptr[k];
722  temp_rhs_arr(i,j,k,Rho_comp ) += dz_inv * ( zflux_hi - zflux_lo );
723  temp_rhs_arr(i,j,k,RhoTheta_comp) += myhalf * dz_inv * ( zflux_hi * (prim(i,j,k) + prim(i,j,k+1))
724  - zflux_lo * (prim(i,j,k) + prim(i,j,k-1)) );
725  });
726 
727  // We only add to the flux registers in the final RK step
728  if (l_reflux) {
729  int strt_comp_reflux = 0;
730  // rho and (rho theta); only (rho theta) is refluxed (see ERF::post_timestep), since the
731  // coarse/fine faces of a fine level carry the coarse mass flux (CFFaceFluxes)
732  int num_comp_reflux = 2;
733  if (level < finest_level) {
734  fr_as_crse->CrseAdd(mfi,
735  {{AMREX_D_DECL(&(flux[0]), &(flux[1]), &(flux[2]))}},
736  dx, dtau, strt_comp_reflux, strt_comp_reflux, num_comp_reflux, RunOn::Device);
737  }
738  if (level > 0) {
739  fr_as_fine->FineAdd(mfi,
740  {{AMREX_D_DECL(&(flux[0]), &(flux[1]), &(flux[2]))}},
741  dx, dtau, strt_comp_reflux, strt_comp_reflux, num_comp_reflux, RunOn::Device);
742  }
743 
744  // This is necessary here so we don't go on to the next FArrayBox without
745  // having finished copying the fluxes into the FluxRegisters (since the fluxes
746  // are stored in temporary FArrayBox's)
747  Gpu::streamSynchronize();
748 
749  } // two-way coupling
750  } // mfi
751  } // OMP
752 
753 #ifdef _OPENMP
754 #pragma omp parallel if (Gpu::notInLaunchRegion())
755 #endif
756  for ( MFIter mfi(S_stage_data[IntVars::cons],TilingIfNotGPU()); mfi.isValid(); ++mfi)
757  {
758  const Box& bx = mfi.tilebox();
759 
760  const Array4< Real>& cur_cons = S_data[IntVars::cons].array(mfi);
761  const Array4<const Real>& prev_cons = S_prev[IntVars::cons].const_array(mfi);
762  auto const& temp_rhs_arr = temp_rhs.const_array(mfi);
763  auto const& slow_rhs_cons = S_slow_rhs[IntVars::cons].const_array(mfi);
764  const Array4<Real const>& cc_src_arr = cc_src.const_array(mfi);
765 
766  if (step == 0) {
767  ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
768  {
769  cur_cons(i,j,k,Rho_comp) = prev_cons(i,j,k,Rho_comp) +
770  dtau * (slow_rhs_cons(i,j,k,Rho_comp) - temp_rhs_arr(i,j,k,Rho_comp));
771  cur_cons(i,j,k,RhoTheta_comp) = prev_cons(i,j,k,RhoTheta_comp) +
772  dtau * (slow_rhs_cons(i,j,k,RhoTheta_comp) - temp_rhs_arr(i,j,k,RhoTheta_comp));
773 
774  // add in source terms for cell-centered conserved variables
775  cur_cons(i,j,k,Rho_comp) += dtau * cc_src_arr(i,j,k,Rho_comp);
776  cur_cons(i,j,k,RhoTheta_comp) += dtau * cc_src_arr(i,j,k,RhoTheta_comp);
777  });
778  } else {
779  ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
780  {
781  //
782  // We didn't need to set cur_cons = prev_cons above because they point to the same data for step > 0
783  //
784  cur_cons(i,j,k,Rho_comp) += dtau * (slow_rhs_cons(i,j,k,Rho_comp) - temp_rhs_arr(i,j,k,Rho_comp));
785  cur_cons(i,j,k,RhoTheta_comp) += dtau * (slow_rhs_cons(i,j,k,RhoTheta_comp) - temp_rhs_arr(i,j,k,RhoTheta_comp));
786 
787  // add in source terms for cell-centered conserved variables
788  cur_cons(i,j,k,Rho_comp) += dtau * cc_src_arr(i,j,k,Rho_comp);
789  cur_cons(i,j,k,RhoTheta_comp) += dtau * cc_src_arr(i,j,k,RhoTheta_comp);
790  });
791  } // step = 0
792 
793  const Array4<Real>& cur_xmom = S_data[IntVars::xmom].array(mfi);
794  const Array4<Real>& cur_ymom = S_data[IntVars::ymom].array(mfi);
795 
796  const Array4<Real const>& temp_cur_xmom_arr = temp_cur_xmom.const_array(mfi);
797  const Array4<Real const>& temp_cur_ymom_arr = temp_cur_ymom.const_array(mfi);
798 
799  Box tbx = surroundingNodes(bx,0);
800  Box tby = surroundingNodes(bx,1);
801 
802  ParallelFor(tbx, tby,
803  [=] AMREX_GPU_DEVICE (int i, int j, int k)
804  {
805  cur_xmom(i,j,k) = temp_cur_xmom_arr(i,j,k);
806  },
807  [=] AMREX_GPU_DEVICE (int i, int j, int k)
808  {
809  cur_ymom(i,j,k) = temp_cur_ymom_arr(i,j,k);
810  });
811 
812  } // mfi
813 }
GpuArray< Real, AMREX_SPACEDIM > dx
Definition: ERF_ActuatorSpreading.cpp:131
constexpr amrex::Real RvoRd
Definition: ERF_Constants.H:59
constexpr amrex::Real R_d
Definition: ERF_Constants.H:49
constexpr amrex::Real Gamma
Definition: ERF_Constants.H:70
@ v_x
Definition: ERF_DataStruct.H:40
@ u_y
Definition: ERF_DataStruct.H:41
@ v_y
Definition: ERF_DataStruct.H:41
@ m_y
Definition: ERF_DataStruct.H:41
@ u_x
Definition: ERF_DataStruct.H:40
@ m_x
Definition: ERF_DataStruct.H:40
#define PrimQ1_comp
Definition: ERF_IndexDefines.H:94
#define Rho_comp
Definition: ERF_IndexDefines.H:61
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:62
#define PrimTheta_comp
Definition: ERF_IndexDefines.H:91
amrex::GpuArray< Real, AMREX_SPACEDIM > dxInv
Definition: ERF_InitCustomPertVels_ParticleTests.H:16
if(add_bubble)
Definition: ERF_InitCustomPert_ABL.H:60
const int khi
Definition: ERF_InitCustomPert_Bubble.H:25
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
const int klo
Definition: ERF_InitCustomPert_KE.H:9
ParallelFor(fab_box, [=] AMREX_GPU_DEVICE(int i, int j, int k) { qrcuten_arr(i, j, k)=Real(0);qscuten_arr(i, j, k)=Real(0);qicuten_arr(i, j, k)=Real(0);})
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:37
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:36
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:41
AMREX_FORCE_INLINE amrex::IntVect TileNoZ()
Definition: ERF_TileNoZ.H:11
@ gpy
Definition: ERF_IndexDefines.H:242
@ gpx
Definition: ERF_IndexDefines.H:241
@ ymom
Definition: ERF_IndexDefines.H:251
@ cons
Definition: ERF_IndexDefines.H:249
@ zmom
Definition: ERF_IndexDefines.H:252
@ xmom
Definition: ERF_IndexDefines.H:250
@ qt
Definition: ERF_Kessler.H:30
@ qv
Definition: ERF_Kessler.H:31
@ q
Definition: ERF_WSM6.H:296
std::array< amrex::MultiFab *, AMREX_SPACEDIM > rec
Definition: ERF_TI_fast_headers.H:29
const amrex::MultiFab * tgt_w
Definition: ERF_TI_fast_headers.H:33
std::array< const amrex::MultiFab *, AMREX_SPACEDIM > tgt
Definition: ERF_TI_fast_headers.H:32
static MeshType mesh_type
Vertical mesh representation.
Definition: ERF_DataStruct.H:3004
Here is the call graph for this function: