ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_SlowRhsPre.cpp File Reference
#include "AMReX_MultiFab.H"
#include "AMReX_iMultiFab.H"
#include "AMReX_ArrayLim.H"
#include "AMReX_BCRec.H"
#include "AMReX_GpuContainers.H"
#include "AMReX_GpuPrint.H"
#include "ERF_TI_slow_headers.H"
#include "ERF_EOS.H"
#include "ERF_Utils.H"
#include "ERF_Diffusion.H"
#include "ERF_EBAdvection.H"
#include "ERF_EB.H"
#include "ERF_SurfaceLayer.H"
Include dependency graph for ERF_SlowRhsPre.cpp:

Functions

void erf_slow_rhs_pre (int level, int finest_level, int nrk, Real dt, Vector< MultiFab > &S_rhs, Vector< MultiFab > &S_old, Vector< MultiFab > &S_data, const MultiFab &S_prim, const MultiFab &qt, MultiFab &avg_xmom, MultiFab &avg_ymom, MultiFab &avg_zmom, const MultiFab &xvel, const MultiFab &yvel, const MultiFab &zvel, std::unique_ptr< MultiFab > &z_t_mf, const MultiFab &cc_src, const MultiFab &xmom_src, const MultiFab &ymom_src, const MultiFab &zmom_src, const MultiFab &buoyancy, const MultiFab *zmom_crse_rhs, Vector< std::unique_ptr< MultiFab >> &Tau_lev, Vector< std::unique_ptr< MultiFab >> &Tau_corr_lev, MultiFab *SmnSmn, MultiFab *eddyDiffs, MultiFab *Hfx1, MultiFab *Hfx2, MultiFab *Hfx3, MultiFab *Q1fx1, MultiFab *Q1fx2, MultiFab *Q1fx3, MultiFab *Q2fx3, MultiFab *Diss, const Geometry geom, const SolverChoice &solverChoice, std::unique_ptr< SurfaceLayer > &SurfLayer, const Gpu::DeviceVector< BCRec > &domain_bcs_type_d, const Vector< BCRec > &domain_bcs_type_h, const MultiFab &z_phys_nd, const MultiFab &z_phys_cc, const MultiFab &ax, const MultiFab &ay, const MultiFab &az, const MultiFab &detJ, Gpu::DeviceVector< Real > &stretched_dz_d, Vector< MultiFab > &gradp, Vector< std::unique_ptr< MultiFab >> &mapfac, const eb_ &ebfact, YAFluxRegister *fr_as_crse, YAFluxRegister *fr_as_fine)
 

Function Documentation

◆ erf_slow_rhs_pre()

void erf_slow_rhs_pre ( int  level,
int  finest_level,
int  nrk,
Real  dt,
Vector< MultiFab > &  S_rhs,
Vector< MultiFab > &  S_old,
Vector< MultiFab > &  S_data,
const MultiFab &  S_prim,
const MultiFab &  qt,
MultiFab &  avg_xmom,
MultiFab &  avg_ymom,
MultiFab &  avg_zmom,
const MultiFab &  xvel,
const MultiFab &  yvel,
const MultiFab &  zvel,
std::unique_ptr< MultiFab > &  z_t_mf,
const MultiFab &  cc_src,
const MultiFab &  xmom_src,
const MultiFab &  ymom_src,
const MultiFab &  zmom_src,
const MultiFab &  buoyancy,
const MultiFab *  zmom_crse_rhs,
Vector< std::unique_ptr< MultiFab >> &  Tau_lev,
Vector< std::unique_ptr< MultiFab >> &  Tau_corr_lev,
MultiFab *  SmnSmn,
MultiFab *  eddyDiffs,
MultiFab *  Hfx1,
MultiFab *  Hfx2,
MultiFab *  Hfx3,
MultiFab *  Q1fx1,
MultiFab *  Q1fx2,
MultiFab *  Q1fx3,
MultiFab *  Q2fx3,
MultiFab *  Diss,
const Geometry  geom,
const SolverChoice solverChoice,
std::unique_ptr< SurfaceLayer > &  SurfLayer,
const Gpu::DeviceVector< BCRec > &  domain_bcs_type_d,
const Vector< BCRec > &  domain_bcs_type_h,
const MultiFab &  z_phys_nd,
const MultiFab &  z_phys_cc,
const MultiFab &  ax,
const MultiFab &  ay,
const MultiFab &  az,
const MultiFab &  detJ,
Gpu::DeviceVector< Real > &  stretched_dz_d,
Vector< MultiFab > &  gradp,
Vector< std::unique_ptr< MultiFab >> &  mapfac,
const eb_ ebfact,
YAFluxRegister *  fr_as_crse,
YAFluxRegister *  fr_as_fine 
)

Function for computing the slow RHS for the evolution equations for the density, potential temperature and momentum.

Parameters
[in]levellevel of resolution
[in]finest_levelfinest level of resolution
[in]nrkwhich RK stage
[in]dtslow time step
[out]S_rhsRHS computed here
[in]S_oldold-time solution – used only for anelastic
[in]S_datacurrent solution
[in]S_primprimitive variables (i.e. conserved variables divided by density)
[in,out]avg_xmom
[in,out]avg_ymom
[in,out]avg_zmom
[in]xvelx-component of velocity
[in]yvely-component of velocity
[in]zvelz-component of velocity
[in]z_t_mf rate of change of grid height – only relevant for moving terrain
[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]buoyancybuoyancy source term for z-momentum
[in]zmom_crse_rhsupdate term from coarser level for z-momentum; non-zero on c/f boundary only
[in]Tau_levcomponents of stress tensor
[in]SmnSmnstrain rate magnitude
[in]eddyDiffsdiffusion coefficients for LES turbulence models
[in]Hfx3heat flux in z-dir
[in]Dissdissipation of turbulent kinetic energy
[in]geomContainer for geometric information
[in]solverChoiceContainer for solver parameters
[in]SurfLayerPointer to SurfaceLayer class for Monin-Obukhov Similarity Theory boundary condition
[in]domain_bcs_type_ddevice vector for domain boundary conditions
[in]domain_bcs_type_hhost vector for domain boundary conditions
[in]z_phys_ndheight coordinate at nodes
[in]axarea fractions on x-faces
[in]ayarea fractions on y-faces
[in]azarea fractions on z-faces
[in]detJJacobian of the metric transformation (= 1 if use_terrain_fitted_coords is false)
[in]gradppressure gradient
[in]mapfacmap factors
[in]ebfactEB factories for cell- and face-centered variables
[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
112 {
113  BL_PROFILE_REGION("erf_slow_rhs_pre()");
114 
115  const BCRec* bc_ptr_d = domain_bcs_type_d.data();
116  const BCRec* bc_ptr_h = domain_bcs_type_h.data();
117 
118  DiffChoice dc = solverChoice.diffChoice;
119  TurbChoice tc = solverChoice.turbChoice[level];
120 
121  const MultiFab* t_mean_mf = nullptr;
122  if (SurfLayer) { t_mean_mf = SurfLayer->get_mac_avg(level,2); }
123 
124  const Box& domain = geom.Domain();
125  int klo = domain.smallEnd(2);
126  int khi = domain.bigEnd(2);
127 
128  const AdvType l_horiz_adv_type = solverChoice.advChoice.dycore_horiz_adv_type;
129  const AdvType l_vert_adv_type = solverChoice.advChoice.dycore_vert_adv_type;
130  const Real l_horiz_upw_frac = solverChoice.advChoice.dycore_horiz_upw_frac;
131  const Real l_vert_upw_frac = solverChoice.advChoice.dycore_vert_upw_frac;
132  const bool l_use_stretched_dz = (solverChoice.mesh_type == MeshType::StretchedDz);
133  const bool l_use_terrain_fitted_coords = (solverChoice.mesh_type == MeshType::VariableDz);
134  const bool l_moving_terrain = (solverChoice.terrain_type == TerrainType::MovingFittedMesh);
135  if (l_moving_terrain) AMREX_ALWAYS_ASSERT (l_use_stretched_dz || l_use_terrain_fitted_coords);
136 
137  const bool l_use_diff = ( (dc.molec_diff_type != MolecDiffType::None) ||
138  (tc.les_type != LESType::None) ||
139  (tc.rans_type != RANSType::None) ||
140  (tc.pbl_type != PBLType::None) );
141  const bool l_use_turb = tc.use_kturb;
142  const bool l_need_SmnSmn = tc.use_keqn;
143 
144  const Real l_vert_implicit_fac = (solverChoice.vert_implicit_fac[nrk] > 0 &&
145  solverChoice.implicit_thermal_diffusion);
146 
147  const bool l_use_moisture = (solverChoice.moisture_type != MoistureType::None);
148  const bool l_use_SurfLayer = (SurfLayer != nullptr);
149  const bool l_rotate = (solverChoice.use_rotate_surface_flux);
150 
151  const bool l_anelastic = solverChoice.anelastic[level];
152  const bool l_fixed_rho = solverChoice.fixed_density[level];
153 
154  const bool l_reflux = ( (solverChoice.coupling_type == CouplingType::TwoWay) && (finest_level > 0) &&
155  ( (l_anelastic && nrk == 1) || (!l_anelastic && nrk == 2) ) );
156 
157  const GpuArray<Real, AMREX_SPACEDIM> dxInv = geom.InvCellSizeArray();
158  const Real* dx = geom.CellSize();
159 
160  // *****************************************************************************
161  // Combine external forcing terms
162  // *****************************************************************************
163  const Array<Real,AMREX_SPACEDIM> grav{0.0, 0.0, -solverChoice.gravity};
164  const GpuArray<Real,AMREX_SPACEDIM> grav_gpu{grav[0], grav[1], grav[2]};
165 
166  // **************************************************************************************
167  // If doing advection with EB we need the extra values for tangential interpolation
168  // **************************************************************************************
169  if (solverChoice.terrain_type == TerrainType::EB) {
170  S_data[IntVars::xmom].FillBoundary(geom.periodicity());
171  S_data[IntVars::ymom].FillBoundary(geom.periodicity());
172  S_data[IntVars::zmom].FillBoundary(geom.periodicity());
173  }
174 
175  // *****************************************************************************
176  // Pre-computed quantities
177  // *****************************************************************************
178  int nvars = S_data[IntVars::cons].nComp();
179  const BoxArray& ba = S_data[IntVars::cons].boxArray();
180  const DistributionMapping& dm = S_data[IntVars::cons].DistributionMap();
181 
182  int nGhost = (solverChoice.terrain_type == TerrainType::EB) ? 2 : 1;
183  MultiFab Omega(convert(ba,IntVect(0,0,1)), dm, 1, nGhost);
184 
185  std::unique_ptr<MultiFab> expr;
186  std::unique_ptr<MultiFab> dflux_x;
187  std::unique_ptr<MultiFab> dflux_y;
188  std::unique_ptr<MultiFab> dflux_z;
189 
190  if (l_use_diff) {
191 #ifdef ERF_USE_SHOC
192  if (solverChoice.use_shoc) {
193  // Populate vertical component of eddyDiffs
194  shoc_lev->set_eddy_diffs();
195  }
196 #endif
197 
198  erf_make_tau_terms(level,nrk,domain_bcs_type_h,z_phys_nd,
199  S_data,xvel,yvel,zvel,
200  Tau_lev,Tau_corr_lev,
201  SmnSmn,eddyDiffs,geom,solverChoice,SurfLayer,
202  stretched_dz_d, detJ,mapfac);
203 
204  dflux_x = std::make_unique<MultiFab>(convert(ba,IntVect(1,0,0)), dm, nvars, 0);
205  dflux_y = std::make_unique<MultiFab>(convert(ba,IntVect(0,1,0)), dm, nvars, 0);
206  dflux_z = std::make_unique<MultiFab>(convert(ba,IntVect(0,0,1)), dm, nvars, 0);
207 
208 #ifdef ERF_USE_SHOC
209  if (solverChoice.use_shoc) {
210  // Zero out the surface stresses of tau13/tau23
211  shoc_lev->set_diff_stresses();
212  } else if (l_use_SurfLayer) {
213  // Set surface shear stresses, update heat and moisture fluxes
214  // (fluxes will be later applied in the diffusion source update)
215  Vector<const MultiFab*> mfs = {&S_data[IntVars::cons], &xvel, &yvel, &zvel};
216  SurfLayer->impose_SurfaceLayer_bcs(level, mfs, Tau_lev,
217  Hfx1, Hfx2, Hfx3,
218  Q1fx1, Q1fx2, Q1fx3,
219  &z_phys_nd);
220  }
221 #else
222  // This is computed pre step in Advance if we use SHOC
223  if (l_use_SurfLayer) {
224  // Set surface shear stresses, update heat and moisture fluxes
225  // (fluxes will be later applied in the diffusion source update)
226  Vector<const MultiFab*> mfs = {&S_data[IntVars::cons], &xvel, &yvel, &zvel};
227  SurfLayer->impose_SurfaceLayer_bcs(level, mfs, Tau_lev,
228  Hfx1, Hfx2, Hfx3,
229  Q1fx1, Q1fx2, Q1fx3,
230  &z_phys_nd);
231 
232  //if (l_vert_implicit_fac > 0 && solverChoice.implicit_momentum_diffusion) {
233  // copy_surface_tau_for_implicit(Tau_lev, Tau_corr_lev);
234  //}
235  }
236 #endif
237  } // l_use_diff
238 
239  // This is just cautionary to deal with grid boundaries that aren't domain boundaries
240  S_rhs[IntVars::zmom].setVal(0.0);
241 
242  // *****************************************************************************
243  // Define updates and fluxes in the current RK stage
244  // *****************************************************************************
245  // Cell-centered masks for EB (used for flux interpolation)
246  bool already_on_centroids = false;
247  Vector<iMultiFab> physbnd_mask;
248  physbnd_mask.resize(IntVars::NumTypes);
249  if (solverChoice.terrain_type == TerrainType::EB) {
250  physbnd_mask[IntVars::cons].define(S_data[IntVars::cons].boxArray(), S_data[IntVars::cons].DistributionMap(), 1, 1);
251  physbnd_mask[IntVars::cons].BuildMask(geom.Domain(), geom.periodicity(), 1, 1, 0, 1);
252  // physbnd_mask[IntVars::cons].FillBoundary(geom.periodicity());
253  for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
254  physbnd_mask[1+dir].define(S_data[1+dir].boxArray(), S_data[1+dir].DistributionMap(), 1, 1);
255  physbnd_mask[1+dir].BuildMask(geom.Domain(), geom.periodicity(), 1, 1, 0, 1);
256  // physbnd_mask[1+dir].FillBoundary(geom.periodicity());
257  }
258  }
259 
260 #ifdef _OPENMP
261 #pragma omp parallel if (Gpu::notInLaunchRegion())
262 #endif
263  {
264  for ( MFIter mfi(S_data[IntVars::cons],TileNoZ()); mfi.isValid(); ++mfi)
265  {
266  Box bx = mfi.tilebox();
267  Box tbx = mfi.nodaltilebox(0);
268  Box tby = mfi.nodaltilebox(1);
269  Box tbz = mfi.nodaltilebox(2);
270 
271  // Boxes for momentum fluxes
272  Vector<Box> tbx_grown(AMREX_SPACEDIM);
273  Vector<Box> tby_grown(AMREX_SPACEDIM);
274  Vector<Box> tbz_grown(AMREX_SPACEDIM);
275  if (solverChoice.terrain_type == TerrainType::EB) {
276  for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
277  tbx_grown[dir] = tbx;
278  tby_grown[dir] = tby;
279  tbz_grown[dir] = tbz;
280  IntVect iv(1, 1, 1);
281  iv[dir] = 0;
282  tbx_grown[dir] = (tbx_grown[dir].growHi(dir,1)).grow(iv);
283  tby_grown[dir] = (tby_grown[dir].growHi(dir,1)).grow(iv);
284  tbz_grown[dir] = (tbz_grown[dir].growHi(dir,1)).grow(iv);
285  }
286  }
287 
288  // We don't compute a source term for z-momentum on the bottom or top domain boundary
289  if (tbz.smallEnd(2) == domain.smallEnd(2)) {
290  tbz.growLo(2,-1);
291  }
292  if (tbz.bigEnd(2) == domain.bigEnd(2)+1) {
293  tbz.growHi(2,-1);
294  }
295 
296  const Array4<const Real> & cell_data = S_data[IntVars::cons].array(mfi);
297  const Array4<const Real> & cell_prim = S_prim.array(mfi);
298  const Array4<Real> & cell_rhs = S_rhs[IntVars::cons].array(mfi);
299 
300  const Array4<const Real> & cell_old = S_old[IntVars::cons].array(mfi);
301 
302  const Array4<Real const>& xmom_src_arr = xmom_src.const_array(mfi);
303  const Array4<Real const>& ymom_src_arr = ymom_src.const_array(mfi);
304  const Array4<Real const>& zmom_src_arr = zmom_src.const_array(mfi);
305  const Array4<Real const>& buoyancy_arr = buoyancy.const_array(mfi);
306 
307  const Array4<Real const>& gpx_arr = gradp[GpVars::gpx].const_array(mfi);
308  const Array4<Real const>& gpy_arr = gradp[GpVars::gpy].const_array(mfi);
309  const Array4<Real const>& gpz_arr = gradp[GpVars::gpz].const_array(mfi);
310 
311  const Array4<Real const>& qt_arr = qt.const_array(mfi);
312 
313  const Array4<Real>& rho_u_old = S_old[IntVars::xmom].array(mfi);
314  const Array4<Real>& rho_v_old = S_old[IntVars::ymom].array(mfi);
315 
316  if (l_anelastic) {
317  // When anelastic we must reset these to 0 each RK step
318  avg_xmom[mfi].template setVal<RunOn::Device>(0.0,tbx);
319  avg_ymom[mfi].template setVal<RunOn::Device>(0.0,tby);
320  avg_zmom[mfi].template setVal<RunOn::Device>(0.0,tbz);
321  }
322 
323  Array4<Real> avg_xmom_arr = avg_xmom.array(mfi);
324  Array4<Real> avg_ymom_arr = avg_ymom.array(mfi);
325  Array4<Real> avg_zmom_arr = avg_zmom.array(mfi);
326 
327  const Array4<const Real> & u = xvel.array(mfi);
328  const Array4<const Real> & v = yvel.array(mfi);
329  const Array4<const Real> & w = zvel.array(mfi);
330 
331  const Array4<const Real>& rho_u = S_data[IntVars::xmom].array(mfi);
332  const Array4<const Real>& rho_v = S_data[IntVars::ymom].array(mfi);
333  const Array4<const Real>& rho_w = S_data[IntVars::zmom].array(mfi);
334 
335  // Map factors
336  const Array4<const Real>& mf_mx = mapfac[MapFacType::m_x]->const_array(mfi);
337  const Array4<const Real>& mf_ux = mapfac[MapFacType::u_x]->const_array(mfi);
338  const Array4<const Real>& mf_vx = mapfac[MapFacType::v_x]->const_array(mfi);
339  const Array4<const Real>& mf_my = mapfac[MapFacType::m_y]->const_array(mfi);
340  const Array4<const Real>& mf_uy = mapfac[MapFacType::u_y]->const_array(mfi);
341  const Array4<const Real>& mf_vy = mapfac[MapFacType::v_y]->const_array(mfi);
342 
343  const Array4< Real>& omega_arr = Omega.array(mfi);
344 
345  Array4<const Real> z_t;
346  if (z_t_mf) {
347  z_t = z_t_mf->array(mfi);
348  } else {
349  z_t = Array4<const Real>{};
350  }
351 
352  const Array4<Real>& rho_u_rhs = S_rhs[IntVars::xmom].array(mfi);
353  const Array4<Real>& rho_v_rhs = S_rhs[IntVars::ymom].array(mfi);
354  const Array4<Real>& rho_w_rhs = S_rhs[IntVars::zmom].array(mfi);
355 
356  const Array4<Real const>& mu_turb = l_use_turb ? eddyDiffs->const_array(mfi) : Array4<const Real>{};
357 
358  // Terrain metrics
359  const Array4<const Real>& z_nd = z_phys_nd.const_array(mfi);
360  const Array4<const Real>& z_cc = z_phys_cc.const_array(mfi);
361 
362  // *****************************************************************************
363  // Define flux arrays for use in advection
364  // *****************************************************************************
365  std::array<FArrayBox,AMREX_SPACEDIM> flux;
366  std::array<FArrayBox,AMREX_SPACEDIM> flux_u;
367  std::array<FArrayBox,AMREX_SPACEDIM> flux_v;
368  std::array<FArrayBox,AMREX_SPACEDIM> flux_w;
369 
370  for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
371  if (solverChoice.terrain_type != TerrainType::EB) {
372  flux[dir].resize(surroundingNodes(bx,dir),2,The_Async_Arena());
373  } else {
374  flux[dir].resize(surroundingNodes(bx,dir).grow(1),2,The_Async_Arena());
375  }
376  flux[dir].setVal<RunOn::Device>(0.);
377  }
378  const GpuArray<const Array4<Real>, AMREX_SPACEDIM>
379  flx_arr{{AMREX_D_DECL(flux[0].array(), flux[1].array(), flux[2].array())}};
380 
381  // Define flux arrays for momentum variables (used only for EB now)
382  GpuArray<Array4<Real>, AMREX_SPACEDIM> flx_u_arr{};
383  GpuArray<Array4<Real>, AMREX_SPACEDIM> flx_v_arr{};
384  GpuArray<Array4<Real>, AMREX_SPACEDIM> flx_w_arr{};
385 
386  if (solverChoice.terrain_type == TerrainType::EB) {
387  for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
388  flux_u[dir].resize(tbx_grown[dir],1,The_Async_Arena());
389  flux_v[dir].resize(tby_grown[dir],1,The_Async_Arena());
390  flux_w[dir].resize(tbz_grown[dir],1,The_Async_Arena());
391  flux_u[dir].setVal<RunOn::Device>(0.);
392  flux_v[dir].setVal<RunOn::Device>(0.);
393  flux_w[dir].setVal<RunOn::Device>(0.);
394  flx_u_arr[dir] = flux_u[dir].array();
395  flx_v_arr[dir] = flux_v[dir].array();
396  flx_w_arr[dir] = flux_w[dir].array();
397  }
398  }
399 
400  // *****************************************************************************
401  // Contravariant flux field
402  // *****************************************************************************
403  {
404  BL_PROFILE("slow_rhs_making_omega");
405  IntVect nGrowVect = (solverChoice.terrain_type == TerrainType::EB)
406  ? IntVect(AMREX_D_DECL(2, 2, 2)) : IntVect(AMREX_D_DECL(1, 1, 1));
407  Box gbxo = surroundingNodes(bx,2); gbxo.grow(nGrowVect);
408  //
409  // Now create Omega with momentum (not velocity) with z_t subtracted if moving terrain
410  // ONLY if not doing anelastic + terrain -- in that case Omega will be defined coming
411  // out of the projection
412  //
413  if (!l_use_terrain_fitted_coords) {
414  ParallelFor(gbxo, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
415  omega_arr(i,j,k) = rho_w(i,j,k);
416  });
417 
418  } else {
419 
420  Box gbxo_lo = gbxo; gbxo_lo.setBig(2,domain.smallEnd(2));
421  int lo_z_face = domain.smallEnd(2);
422  if (gbxo_lo.smallEnd(2) <= lo_z_face) {
423  ParallelFor(gbxo_lo, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
424  omega_arr(i,j,k) = 0.;
425  });
426  }
427  Box gbxo_hi = gbxo; gbxo_hi.setSmall(2,gbxo.bigEnd(2));
428  int hi_z_face = domain.bigEnd(2)+1;
429  if (gbxo_hi.bigEnd(2) >= hi_z_face) {
430  ParallelFor(gbxo_hi, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
431  omega_arr(i,j,k) = rho_w(i,j,k);
432  });
433  }
434 
435  if (z_t) { // Note we never do anelastic with moving terrain
436  Box gbxo_mid = gbxo; gbxo_mid.setSmall(2,1); gbxo_mid.setBig(2,gbxo.bigEnd(2)-1);
437  ParallelFor(gbxo_mid, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
438  // We define rho on the z-face the same way as in MomentumToVelocity/VelocityToMomentum
439  Real rho_at_face = 0.5 * (cell_data(i,j,k,Rho_comp) + cell_data(i,j,k-1,Rho_comp));
440  omega_arr(i,j,k) = OmegaFromW(i,j,k,rho_w(i,j,k),
441  rho_u,rho_v,mf_ux,mf_vy,z_nd,dxInv) -
442  rho_at_face * z_t(i,j,k);
443  });
444  } else {
445  Box gbxo_mid = gbxo;
446  if (gbxo_mid.smallEnd(2) <= domain.smallEnd(2)) {
447  gbxo_mid.setSmall(2,1);
448  }
449  if (gbxo_mid.bigEnd(2) >= domain.bigEnd(2)+1) {
450  gbxo_mid.setBig(2,gbxo.bigEnd(2)-1);
451  }
452  ParallelFor(gbxo_mid, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
453  omega_arr(i,j,k) = OmegaFromW(i,j,k,rho_w(i,j,k),
454  rho_u,rho_v,mf_ux,mf_vy,z_nd,dxInv);
455  });
456  }
457  }
458  } // end profile
459 
460  // *****************************************************************************
461  // Diffusive terms (pre-computed above)
462  // *****************************************************************************
463  // No terrain diffusion
464  Array4<Real> tau11,tau22,tau33;
465  Array4<Real> tau12,tau13,tau23;
466  if (Tau_lev[TauType::tau11]) {
467  tau11 = Tau_lev[TauType::tau11]->array(mfi); tau22 = Tau_lev[TauType::tau22]->array(mfi);
468  tau33 = Tau_lev[TauType::tau33]->array(mfi); tau12 = Tau_lev[TauType::tau12]->array(mfi);
469  tau13 = Tau_lev[TauType::tau13]->array(mfi); tau23 = Tau_lev[TauType::tau23]->array(mfi);
470  } else {
471  tau11 = Array4<Real>{}; tau22 = Array4<Real>{}; tau33 = Array4<Real>{};
472  tau12 = Array4<Real>{}; tau13 = Array4<Real>{}; tau23 = Array4<Real>{};
473  }
474  // Terrain diffusion
475  Array4<Real> tau21,tau31,tau32;
476  if (Tau_lev[TauType::tau21]) {
477  tau21 = Tau_lev[TauType::tau21]->array(mfi);
478  tau31 = Tau_lev[TauType::tau31]->array(mfi);
479  tau32 = Tau_lev[TauType::tau32]->array(mfi);
480  } else {
481  tau21 = Array4<Real>{}; tau31 = Array4<Real>{}; tau32 = Array4<Real>{};
482  }
483 
484  // Strain magnitude
485  Array4<Real> SmnSmn_a;
486  if (l_need_SmnSmn) {
487  SmnSmn_a = SmnSmn->array(mfi);
488  } else {
489  SmnSmn_a = Array4<Real>{};
490  }
491 
492  // *****************************************************************************
493  // Define updates in the RHS of continuity and potential temperature equations
494  // *****************************************************************************
495  bool l_eb_terrain_cc = false; // EB terrain on cell-centered grid
496  Array4<const int> mask_arr{};
497  Array4<const EBCellFlag> cfg_arr{};
498  Array4<const Real> ax_arr{};
499  Array4<const Real> ay_arr{};
500  Array4<const Real> az_arr{};
501  Array4<const Real> fcx_arr{};
502  Array4<const Real> fcy_arr{};
503  Array4<const Real> fcz_arr{};
504  Array4<const Real> detJ_arr{};
505 
506  if (solverChoice.terrain_type == TerrainType::EB)
507  {
508  EBCellFlagFab const& cfg = (ebfact.get_const_factory())->getMultiEBCellFlagFab()[mfi];
509  cfg_arr = cfg.const_array();
510  if (cfg.getType(bx) == FabType::singlevalued) {
511  l_eb_terrain_cc = true;
512  ax_arr = (ebfact.get_const_factory())->getAreaFrac()[0]->const_array(mfi);
513  ay_arr = (ebfact.get_const_factory())->getAreaFrac()[1]->const_array(mfi);
514  az_arr = (ebfact.get_const_factory())->getAreaFrac()[2]->const_array(mfi);
515  fcx_arr = (ebfact.get_const_factory())->getFaceCent()[0]->const_array(mfi);
516  fcy_arr = (ebfact.get_const_factory())->getFaceCent()[1]->const_array(mfi);
517  fcz_arr = (ebfact.get_const_factory())->getFaceCent()[2]->const_array(mfi);
518  detJ_arr = (ebfact.get_const_factory())->getVolFrac().const_array(mfi);
519  // if (!already_on_centroids) {mask_arr = physbnd_mask[IntVars::cons].const_array(mfi);}
520  mask_arr = physbnd_mask[IntVars::cons].const_array(mfi);
521  } else {
522  ax_arr = ax.const_array(mfi);
523  ay_arr = ay.const_array(mfi);
524  az_arr = az.const_array(mfi);
525  detJ_arr = detJ.const_array(mfi);
526  }
527  } else {
528  ax_arr = ax.const_array(mfi);
529  ay_arr = ay.const_array(mfi);
530  az_arr = az.const_array(mfi);
531  detJ_arr = detJ.const_array(mfi);
532  }
533 
534  int icomp = RhoTheta_comp; int ncomp = 1;
535  if (!l_eb_terrain_cc){
536  AdvectionSrcForRho( bx, cell_rhs,
537  rho_u, rho_v, omega_arr, // these are being used to build the fluxes
538  avg_xmom_arr, avg_ymom_arr, avg_zmom_arr, // these are being defined from the fluxes
539  ax_arr, ay_arr, az_arr, detJ_arr,
540  dxInv, mf_mx, mf_my, mf_uy, mf_vx,
541  flx_arr, l_fixed_rho);
542  AdvectionSrcForScalars(bx, icomp, ncomp,
543  avg_xmom_arr, avg_ymom_arr, avg_zmom_arr,
544  cell_prim, cell_rhs,
545  detJ_arr, dxInv, mf_mx, mf_my,
546  l_horiz_adv_type, l_vert_adv_type,
547  l_horiz_upw_frac, l_vert_upw_frac,
548  flx_arr, domain, bc_ptr_h);
549  } else {
550  EBAdvectionSrcForRho(bx, cell_rhs,
551  rho_u, rho_v, omega_arr,
552  avg_xmom_arr, avg_ymom_arr, avg_zmom_arr,
553  mask_arr, cfg_arr,
554  ax_arr, ay_arr, az_arr,
555  fcx_arr, fcy_arr, fcz_arr, detJ_arr,
556  dxInv, mf_mx, mf_my, mf_uy, mf_vx,
557  flx_arr, l_fixed_rho,
558  already_on_centroids);
559  EBAdvectionSrcForScalars(bx, icomp, ncomp,
560  avg_xmom_arr, avg_ymom_arr, avg_zmom_arr,
561  cell_prim, cell_rhs,
562  mask_arr, cfg_arr, ax_arr, ay_arr, az_arr,
563  fcx_arr, fcy_arr, fcz_arr,
564  detJ_arr, dxInv, mf_mx, mf_my,
565  l_horiz_adv_type, l_vert_adv_type,
566  l_horiz_upw_frac, l_vert_upw_frac,
567  flx_arr, domain, bc_ptr_h,
568  already_on_centroids);
569  }
570 
571  if (l_use_diff) {
572  Array4<Real> diffflux_x = dflux_x->array(mfi);
573  Array4<Real> diffflux_y = dflux_y->array(mfi);
574  Array4<Real> diffflux_z = dflux_z->array(mfi);
575 
576  Array4<Real> hfx_x = Hfx1->array(mfi);
577  Array4<Real> hfx_y = Hfx2->array(mfi);
578  Array4<Real> hfx_z = Hfx3->array(mfi);
579 
580  Array4<Real> q1fx_x = (Q1fx1) ? Q1fx1->array(mfi) : Array4<Real>{};
581  Array4<Real> q1fx_y = (Q1fx2) ? Q1fx2->array(mfi) : Array4<Real>{};
582  Array4<Real> q1fx_z = (Q1fx3) ? Q1fx3->array(mfi) : Array4<Real>{};
583 
584  Array4<Real> q2fx_z = (Q2fx3) ? Q2fx3->array(mfi) : Array4<Real>{};
585  Array4<Real> diss = Diss->array(mfi);
586 
587  const Array4<const Real> tm_arr = t_mean_mf ? t_mean_mf->const_array(mfi) : Array4<const Real>{};
588 
589  // NOTE: No diffusion for continuity, so n starts at 1.
590  int n_start = RhoTheta_comp;
591  int n_comp = 1;
592 
593  // For l_vert_implicit_fac > 0, we scale the rho*theta contribution
594  // by (1 - implicit_fac) and add in the implicit contribution with
595  // ERF_Implicit.H
596  if (l_use_stretched_dz) {
597  DiffusionSrcForState_S(bx, domain, n_start, n_comp, u, v,
598  cell_data, cell_prim, cell_rhs,
599  diffflux_x, diffflux_y, diffflux_z,
600  stretched_dz_d, dxInv, SmnSmn_a,
601  mf_mx, mf_ux, mf_vx,
602  mf_my, mf_uy, mf_vy,
603  hfx_z, q1fx_z, q2fx_z, diss,
604  mu_turb, solverChoice, level,
605  tm_arr, grav_gpu, bc_ptr_d, l_use_SurfLayer, l_vert_implicit_fac);
606  } else if (l_use_terrain_fitted_coords) {
607  DiffusionSrcForState_T(bx, domain, n_start, n_comp, l_rotate, u, v,
608  cell_data, cell_prim, cell_rhs,
609  diffflux_x, diffflux_y, diffflux_z,
610  z_nd, z_cc, ax_arr, ay_arr, az_arr, detJ_arr,
611  dxInv, SmnSmn_a,
612  mf_mx, mf_ux, mf_vx,
613  mf_my, mf_uy, mf_vy,
614  hfx_x, hfx_y, hfx_z, q1fx_x, q1fx_y, q1fx_z, q2fx_z, diss,
615  mu_turb, solverChoice, level,
616  tm_arr, grav_gpu, bc_ptr_d, l_use_SurfLayer, l_vert_implicit_fac);
617  } else {
618  DiffusionSrcForState_N(bx, domain, n_start, n_comp, u, v,
619  cell_data, cell_prim, cell_rhs,
620  diffflux_x, diffflux_y, diffflux_z,
621  dxInv, SmnSmn_a,
622  mf_mx, mf_ux, mf_vx,
623  mf_my, mf_uy, mf_vy,
624  hfx_z, q1fx_z, q2fx_z, diss,
625  mu_turb, solverChoice, level,
626  tm_arr, grav_gpu, bc_ptr_d, l_use_SurfLayer, l_vert_implicit_fac);
627  }
628  }
629 
630  const Array4<Real const>& source_arr = cc_src.const_array(mfi);
631  ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
632  {
633  cell_rhs(i,j,k,Rho_comp) += source_arr(i,j,k,Rho_comp);
634  cell_rhs(i,j,k,RhoTheta_comp) += source_arr(i,j,k,RhoTheta_comp);
635  });
636 
637  // If anelastic and in second RK stage, take average of old-time and new-time source
638  if ( l_anelastic && (nrk == 1) )
639  {
640  ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
641  {
642  cell_rhs(i,j,k, Rho_comp) *= 0.5;
643  cell_rhs(i,j,k,RhoTheta_comp) *= 0.5;
644 
645  cell_rhs(i,j,k, Rho_comp) += 0.5 / dt * (cell_data(i,j,k, Rho_comp) - cell_old(i,j,k, Rho_comp));
646  cell_rhs(i,j,k,RhoTheta_comp) += 0.5 / dt * (cell_data(i,j,k,RhoTheta_comp) - cell_old(i,j,k,RhoTheta_comp));
647  });
648  }
649 
650  // *****************************************************************************
651  // Define updates in the RHS of {x, y, z}-momentum equations
652  // *****************************************************************************
653  int lo_z_face = domain.smallEnd(2);
654  int hi_z_face = domain.bigEnd(2)+1;
655 
656  AdvectionSrcForMom(mfi, bx, tbx, tby, tbz, tbx_grown, tby_grown, tbz_grown,
657  rho_u_rhs, rho_v_rhs, rho_w_rhs,
658  cell_data, u, v, w,
659  rho_u, rho_v, omega_arr,
660  z_nd, ax_arr, ay_arr, az_arr,
661  detJ_arr, stretched_dz_d,
662  dxInv, mf_mx, mf_ux, mf_vx, mf_my, mf_uy, mf_vy,
663  l_horiz_adv_type, l_vert_adv_type,
664  l_horiz_upw_frac, l_vert_upw_frac,
665  solverChoice.mesh_type, solverChoice.terrain_type,
666  ebfact, flx_u_arr, flx_v_arr, flx_w_arr,
667  physbnd_mask, already_on_centroids,
668  lo_z_face, hi_z_face, domain, bc_ptr_h);
669 
670  if (l_use_diff) {
671  // Note: tau** were calculated with calls to
672  // ComputeStress[Cons|Var]Visc_[N|S|T] in which ConsVisc ("constant
673  // viscosity") means that there is no contribution from a
674  // turbulence model. However, whether this field truly is constant
675  // depends on whether MolecDiffType is Constant or ConstantAlpha.
676  if (solverChoice.terrain_type != TerrainType::EB) {
677  DiffusionSrcForMom(tbx, tby, tbz,
678  rho_u_rhs, rho_v_rhs, rho_w_rhs,
679  tau11, tau22, tau33,
681  detJ_arr, stretched_dz_d, dxInv,
682  mf_mx, mf_ux, mf_vx,
683  mf_my, mf_uy, mf_vy,
684  l_use_stretched_dz,
685  l_use_terrain_fitted_coords);
686  } else {
687  DiffusionSrcForMom_EB(mfi, domain, tbx, tby, tbz,
688  rho_u_rhs, rho_v_rhs, rho_w_rhs,
689  u, v, w,
690  tau11, tau22, tau33,
691  tau12, tau13, tau23,
692  dx, dxInv,
693  mf_mx, mf_ux, mf_vx,
694  mf_my, mf_uy, mf_vy,
695  solverChoice, ebfact, bc_ptr_d);
696  }
697  }
698 
699  auto abl_pressure_grad = solverChoice.abl_pressure_grad;
700 
701  ParallelFor(tbx, tby,
702  [=] AMREX_GPU_DEVICE (int i, int j, int k)
703  { // x-momentum equation
704 
705  // Note that gradp arrays now carry the map factor in them
706 
707  Real q = (l_use_moisture) ? 0.5 * (qt_arr(i,j,k) + qt_arr(i-1,j,k)) : 0.0;
708 
709  rho_u_rhs(i, j, k) += (-gpx_arr(i,j,k) - abl_pressure_grad[0]) / (1.0 + q) + xmom_src_arr(i,j,k);
710 
711  if (l_moving_terrain) {
712  Real h_zeta = Compute_h_zeta_AtIface(i, j, k, dxInv, z_nd);
713  rho_u_rhs(i, j, k) *= h_zeta;
714  }
715 
716  if ( l_anelastic && (nrk == 1) ) {
717  rho_u_rhs(i,j,k) *= 0.5;
718  rho_u_rhs(i,j,k) += 0.5 / dt * (rho_u(i,j,k) - rho_u_old(i,j,k));
719  }
720  },
721  [=] AMREX_GPU_DEVICE (int i, int j, int k)
722  { // y-momentum equation
723 
724  // Note that gradp arrays now carry the map factor in them
725 
726  Real q = (l_use_moisture) ? 0.5 * (qt_arr(i,j,k) + qt_arr(i,j-1,k)) : 0.0;
727 
728  rho_v_rhs(i, j, k) += (-gpy_arr(i,j,k) - abl_pressure_grad[1]) / (1.0 + q) + ymom_src_arr(i,j,k);
729 
730  if (l_moving_terrain) {
731  Real h_zeta = Compute_h_zeta_AtJface(i, j, k, dxInv, z_nd);
732  rho_v_rhs(i, j, k) *= h_zeta;
733  }
734 
735  if ( l_anelastic && (nrk == 1) ) {
736  rho_v_rhs(i,j,k) *= 0.5;
737  rho_v_rhs(i,j,k) += 0.5 / dt * (rho_v(i,j,k) - rho_v_old(i,j,k));
738  }
739  });
740 
741  // *****************************************************************************
742  // Zero out source terms for x- and y- momenta if at walls or inflow
743  // We need to do this -- even though we call the boundary conditions later --
744  // because the slow source is used to update the state in the fast interpolater.
745  // *****************************************************************************
746  if (bx.smallEnd(0) == domain.smallEnd(0)) {
747  Box lo_x_dom_face(bx); lo_x_dom_face.setBig(0,bx.smallEnd(0));
748  if (bc_ptr_h[BCVars::xvel_bc].lo(0) == ERFBCType::ext_dir) {
749  ParallelFor(lo_x_dom_face, [=] AMREX_GPU_DEVICE (int i, int j, int k) {
750  rho_u_rhs(i,j,k) = 0.;
751  });
752  } else if (bc_ptr_h[BCVars::xvel_bc].lo(0) == ERFBCType::ext_dir_upwind) {
753  ParallelFor(lo_x_dom_face, [=] AMREX_GPU_DEVICE (int i, int j, int k) {
754  if (u(i,j,k) >= 0.) {
755  rho_u_rhs(i,j,k) = 0.;
756  }
757  });
758  }
759  }
760  if (bx.bigEnd(0) == domain.bigEnd(0)) {
761  Box hi_x_dom_face(bx); hi_x_dom_face.setSmall(0,bx.bigEnd(0)+1); hi_x_dom_face.setBig(0,bx.bigEnd(0)+1);
762  if (bc_ptr_h[BCVars::xvel_bc].hi(0) == ERFBCType::ext_dir) {
763  ParallelFor(hi_x_dom_face, [=] AMREX_GPU_DEVICE (int i, int j, int k) {
764  rho_u_rhs(i,j,k) = 0.;
765  });
766  } else if (bc_ptr_h[BCVars::xvel_bc].hi(0) == ERFBCType::ext_dir_upwind) {
767  ParallelFor(hi_x_dom_face, [=] AMREX_GPU_DEVICE (int i, int j, int k) {
768  if (u(i,j,k) <= 0.) {
769  rho_u_rhs(i,j,k) = 0.;
770  }
771  });
772  }
773  }
774  if (bx.smallEnd(1) == domain.smallEnd(1)) {
775  Box lo_y_dom_face(bx); lo_y_dom_face.setBig(1,bx.smallEnd(1));
776  if (bc_ptr_h[BCVars::yvel_bc].lo(1) == ERFBCType::ext_dir) {
777  ParallelFor(lo_y_dom_face, [=] AMREX_GPU_DEVICE (int i, int j, int k) {
778  rho_v_rhs(i,j,k) = 0.;
779  });
780  } else if (bc_ptr_h[BCVars::yvel_bc].lo(1) == ERFBCType::ext_dir_upwind) {
781  ParallelFor(lo_y_dom_face, [=] AMREX_GPU_DEVICE (int i, int j, int k) {
782  if (v(i,j,k) >= 0.) {
783  rho_v_rhs(i,j,k) = 0.;
784  }
785  });
786  }
787  }
788  if (bx.bigEnd(1) == domain.bigEnd(1)) {
789  Box hi_y_dom_face(bx); hi_y_dom_face.setSmall(1,bx.bigEnd(1)+1); hi_y_dom_face.setBig(1,bx.bigEnd(1)+1);
790  if (bc_ptr_h[BCVars::yvel_bc].hi(1) == ERFBCType::ext_dir) {
791  ParallelFor(hi_y_dom_face, [=] AMREX_GPU_DEVICE (int i, int j, int k) {
792  rho_v_rhs(i,j,k) = 0.;
793  });
794  } else if (bc_ptr_h[BCVars::yvel_bc].hi(1) == ERFBCType::ext_dir_upwind) {
795  ParallelFor(hi_y_dom_face, [=] AMREX_GPU_DEVICE (int i, int j, int k) {
796  if (v(i,j,k) <= 0.) {
797  rho_v_rhs(i,j,k) = 0.;
798  }
799  });
800  }
801  }
802 
803  ParallelFor(tbz, [=] AMREX_GPU_DEVICE (int i, int j, int k)
804  { // z-momentum equation
805 
806  Real gpz = gpz_arr(i,j,k);
807 
808  Real q = (l_use_moisture) ? 0.5 * (qt_arr(i,j,k) + qt_arr(i,j,k-1)) : 0.0;
809 
810  rho_w_rhs(i, j, k) += (-gpz - abl_pressure_grad[2] + buoyancy_arr(i,j,k)) / (1.0 + q) + zmom_src_arr(i,j,k);
811 
812  if (l_moving_terrain) {
813  rho_w_rhs(i, j, k) *= 0.5 * (detJ_arr(i,j,k) + detJ_arr(i,j,k-1));
814  }
815  });
816 
817  auto const lo = lbound(bx);
818  auto const hi = ubound(bx);
819 
820  // Note: the logic below assumes no tiling in z!
821  if (level > 0) {
822 
823  const Array4<const Real>& rho_w_rhs_crse = zmom_crse_rhs->const_array(mfi);
824 
825  Box b2d = bx; b2d.setRange(2,0);
826 
827  if (lo.z > klo) {
828  ParallelFor(b2d, [=] AMREX_GPU_DEVICE (int i, int j, int ) // bottom of box but not of domain
829  {
830  rho_w_rhs(i,j,lo.z) = rho_w_rhs_crse(i,j,lo.z);
831  });
832  }
833 
834  if (hi.z < khi+1) {
835  ParallelFor(b2d, [=] AMREX_GPU_DEVICE (int i, int j, int ) // top of box but not of domain
836  {
837  rho_w_rhs(i,j,hi.z+1) = rho_w_rhs_crse(i,j,hi.z+1);
838  });
839  }
840  }
841 
842  {
843  BL_PROFILE("slow_rhs_pre_fluxreg");
844  // We only add to the flux registers in the final RK step
845  // NOTE: for now we are only refluxing density not (rho theta) since the latter seems to introduce
846  // a problem at top and bottom boundaries
847  if (l_reflux) {
848  int strt_comp_reflux = (l_fixed_rho) ? 1 : 0;
849  int num_comp_reflux = 1;
850  if (level < finest_level) {
851  fr_as_crse->CrseAdd(mfi,
852  {{AMREX_D_DECL(&(flux[0]), &(flux[1]), &(flux[2]))}},
853  dx, dt, strt_comp_reflux, strt_comp_reflux, num_comp_reflux, RunOn::Device);
854  }
855  if (level > 0) {
856  fr_as_fine->FineAdd(mfi,
857  {{AMREX_D_DECL(&(flux[0]), &(flux[1]), &(flux[2]))}},
858  dx, dt, strt_comp_reflux, strt_comp_reflux, num_comp_reflux, RunOn::Device);
859  }
860 
861  } // two-way coupling
862  } // end profile
863  } // mfi
864  } // OMP
865 }
void AdvectionSrcForRho(const amrex::Box &bx, const amrex::Array4< amrex::Real > &src, const amrex::Array4< const amrex::Real > &rho_u, const amrex::Array4< const amrex::Real > &rho_v, const amrex::Array4< const amrex::Real > &omega, const amrex::Array4< amrex::Real > &avg_xmom, const amrex::Array4< amrex::Real > &avg_ymom, const amrex::Array4< amrex::Real > &avg_zmom, const amrex::Array4< const amrex::Real > &ax_arr, const amrex::Array4< const amrex::Real > &ay_arr, const amrex::Array4< const amrex::Real > &az_arr, const amrex::Array4< const amrex::Real > &detJ, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_mx, const amrex::Array4< const amrex::Real > &mf_my, const amrex::Array4< const amrex::Real > &mf_uy, const amrex::Array4< const amrex::Real > &mf_vx, const amrex::GpuArray< const amrex::Array4< amrex::Real >, AMREX_SPACEDIM > &flx_arr, const bool fixed_rho)
void AdvectionSrcForScalars(const amrex::Box &bx, const int icomp, const int ncomp, const amrex::Array4< const amrex::Real > &avg_xmom, const amrex::Array4< const amrex::Real > &avg_ymom, const amrex::Array4< const amrex::Real > &avg_zmom, const amrex::Array4< const amrex::Real > &cell_prim, const amrex::Array4< amrex::Real > &src, const amrex::Array4< const amrex::Real > &vf_arr, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_mx, const amrex::Array4< const amrex::Real > &mf_my, const AdvType horiz_adv_type, const AdvType vert_adv_type, const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac, const amrex::GpuArray< const amrex::Array4< amrex::Real >, AMREX_SPACEDIM > &flx_arr, const amrex::Box &domain, const amrex::BCRec *bc_ptr_h)
void AdvectionSrcForMom(const amrex::MFIter &mfi, const amrex::Box &bx, const amrex::Box &bxx, const amrex::Box &bxy, const amrex::Box &bxz, const amrex::Vector< amrex::Box > &bxx_grown, const amrex::Vector< amrex::Box > &bxy_grown, const amrex::Vector< amrex::Box > &bxz_grown, const amrex::Array4< amrex::Real > &rho_u_rhs, const amrex::Array4< amrex::Real > &rho_v_rhs, const amrex::Array4< amrex::Real > &rho_w_rhs, const amrex::Array4< const amrex::Real > &rho, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &w, const amrex::Array4< const amrex::Real > &rho_u, const amrex::Array4< const amrex::Real > &rho_v, const amrex::Array4< const amrex::Real > &Omega, const amrex::Array4< const amrex::Real > &z_nd, const amrex::Array4< const amrex::Real > &ax, const amrex::Array4< const amrex::Real > &ay, const amrex::Array4< const amrex::Real > &az, const amrex::Array4< const amrex::Real > &detJ, amrex::Gpu::DeviceVector< amrex::Real > &stretched_dz_d, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_mx, const amrex::Array4< const amrex::Real > &mf_ux, const amrex::Array4< const amrex::Real > &mf_vx, const amrex::Array4< const amrex::Real > &mf_my, const amrex::Array4< const amrex::Real > &mf_uy, const amrex::Array4< const amrex::Real > &mf_vy, const AdvType horiz_adv_type, const AdvType vert_adv_type, const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac, MeshType &mesh_type, TerrainType &terrain_type, const eb_ &ebfact, amrex::GpuArray< amrex::Array4< amrex::Real >, AMREX_SPACEDIM > &flx_u_arr, amrex::GpuArray< amrex::Array4< amrex::Real >, AMREX_SPACEDIM > &flx_v_arr, amrex::GpuArray< amrex::Array4< amrex::Real >, AMREX_SPACEDIM > &flx_w_arr, const amrex::Vector< amrex::iMultiFab > &physbnd_mask, const bool already_on_centroids, const int lo_z_face, const int hi_z_face, const amrex::Box &domain, const amrex::BCRec *bc_ptr_h)
@ tau12
Definition: ERF_DataStruct.H:31
@ tau23
Definition: ERF_DataStruct.H:31
@ tau33
Definition: ERF_DataStruct.H:31
@ tau22
Definition: ERF_DataStruct.H:31
@ tau11
Definition: ERF_DataStruct.H:31
@ tau32
Definition: ERF_DataStruct.H:31
@ tau31
Definition: ERF_DataStruct.H:31
@ tau21
Definition: ERF_DataStruct.H:31
@ tau13
Definition: ERF_DataStruct.H:31
@ nvars
Definition: ERF_DataStruct.H:96
@ v_x
Definition: ERF_DataStruct.H:23
@ u_y
Definition: ERF_DataStruct.H:24
@ v_y
Definition: ERF_DataStruct.H:24
@ m_y
Definition: ERF_DataStruct.H:24
@ u_x
Definition: ERF_DataStruct.H:23
@ m_x
Definition: ERF_DataStruct.H:23
void DiffusionSrcForMom(const amrex::Box &bxx, const amrex::Box &bxy, const amrex::Box &bxz, const amrex::Array4< amrex::Real > &rho_u_rhs, const amrex::Array4< amrex::Real > &rho_v_rhs, const amrex::Array4< amrex::Real > &rho_w_rhs, const amrex::Array4< const amrex::Real > &tau11, const amrex::Array4< const amrex::Real > &tau22, const amrex::Array4< const amrex::Real > &tau33, const amrex::Array4< const amrex::Real > &tau12, const amrex::Array4< const amrex::Real > &tau21, const amrex::Array4< const amrex::Real > &tau13, const amrex::Array4< const amrex::Real > &tau31, const amrex::Array4< const amrex::Real > &tau23, const amrex::Array4< const amrex::Real > &tau32, const amrex::Array4< const amrex::Real > &detJ_arr, const amrex::Gpu::DeviceVector< amrex::Real > &stretched_dz_d, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dxInv, const amrex::Array4< const amrex::Real > &mf_mx, const amrex::Array4< const amrex::Real > &mf_ux, const amrex::Array4< const amrex::Real > &mf_vx, const amrex::Array4< const amrex::Real > &mf_my, const amrex::Array4< const amrex::Real > &mf_uy, const amrex::Array4< const amrex::Real > &mf_vy, const bool use_stretched_dz, const bool use_variable_dz)
void DiffusionSrcForMom_EB(const amrex::MFIter &mfi, [[maybe_unused]] const amrex::Box &domain, const amrex::Box &bxx, const amrex::Box &bxy, const amrex::Box &bxz, const amrex::Array4< amrex::Real > &rho_u_rhs, const amrex::Array4< amrex::Real > &rho_v_rhs, const amrex::Array4< amrex::Real > &rho_w_rhs, const amrex::Array4< const amrex::Real > &u_arr, const amrex::Array4< const amrex::Real > &v_arr, const amrex::Array4< const amrex::Real > &w_arr, const amrex::Array4< const amrex::Real > &tau11, const amrex::Array4< const amrex::Real > &tau22, const amrex::Array4< const amrex::Real > &tau33, const amrex::Array4< const amrex::Real > &tau12, const amrex::Array4< const amrex::Real > &tau13, const amrex::Array4< const amrex::Real > &tau23, const amrex::Real *dx_arr, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dxInv, const amrex::Array4< const amrex::Real > &mf_mx, const amrex::Array4< const amrex::Real > &mf_ux, const amrex::Array4< const amrex::Real > &mf_vx, const amrex::Array4< const amrex::Real > &mf_my, const amrex::Array4< const amrex::Real > &mf_uy, const amrex::Array4< const amrex::Real > &mf_vy, const SolverChoice &solverChoice, const eb_ &ebfact, [[maybe_unused]] const amrex::BCRec *bc_ptr)
void DiffusionSrcForState_S(const amrex::Box &bx, const amrex::Box &domain, int start_comp, int num_comp, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &cell_data, const amrex::Array4< const amrex::Real > &cell_prim, const amrex::Array4< amrex::Real > &cell_rhs, const amrex::Array4< amrex::Real > &xflux, const amrex::Array4< amrex::Real > &yflux, const amrex::Array4< amrex::Real > &zflux, const amrex::Gpu::DeviceVector< amrex::Real > &stretched_dz_d, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dxInv, const amrex::Array4< const amrex::Real > &SmnSmn_a, const amrex::Array4< const amrex::Real > &mf_mx, const amrex::Array4< const amrex::Real > &mf_ux, const amrex::Array4< const amrex::Real > &mf_vx, const amrex::Array4< const amrex::Real > &mf_my, const amrex::Array4< const amrex::Real > &mf_uy, const amrex::Array4< const amrex::Real > &mf_vy, amrex::Array4< amrex::Real > &hfx_z, amrex::Array4< amrex::Real > &qfx1_z, amrex::Array4< amrex::Real > &qfx2_z, amrex::Array4< amrex::Real > &diss, const amrex::Array4< const amrex::Real > &mu_turb, const SolverChoice &solverChoice, const int level, const amrex::Array4< const amrex::Real > &tm_arr, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > grav_gpu, const amrex::BCRec *bc_ptr, const bool use_SurfLayer, const amrex::Real implicit_fac)
void DiffusionSrcForState_T(const amrex::Box &bx, const amrex::Box &domain, int start_comp, int num_comp, const bool &rotate, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &cell_data, const amrex::Array4< const amrex::Real > &cell_prim, const amrex::Array4< amrex::Real > &cell_rhs, const amrex::Array4< amrex::Real > &xflux, const amrex::Array4< amrex::Real > &yflux, const amrex::Array4< amrex::Real > &zflux, const amrex::Array4< const amrex::Real > &z_nd, const amrex::Array4< const amrex::Real > &z_cc, const amrex::Array4< const amrex::Real > &ax, const amrex::Array4< const amrex::Real > &ay, const amrex::Array4< const amrex::Real > &az, const amrex::Array4< const amrex::Real > &detJ, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dxInv, const amrex::Array4< const amrex::Real > &SmnSmn_a, const amrex::Array4< const amrex::Real > &mf_mx, const amrex::Array4< const amrex::Real > &mf_ux, const amrex::Array4< const amrex::Real > &mf_vx, const amrex::Array4< const amrex::Real > &mf_my, const amrex::Array4< const amrex::Real > &mf_uy, const amrex::Array4< const amrex::Real > &mf_vy, amrex::Array4< amrex::Real > &hfx_x, amrex::Array4< amrex::Real > &hfx_y, amrex::Array4< amrex::Real > &hfx_z, amrex::Array4< amrex::Real > &qfx1_x, amrex::Array4< amrex::Real > &qfx1_y, amrex::Array4< amrex::Real > &qfx1_z, amrex::Array4< amrex::Real > &qfx2_z, amrex::Array4< amrex::Real > &diss, const amrex::Array4< const amrex::Real > &mu_turb, const SolverChoice &solverChoice, const int level, const amrex::Array4< const amrex::Real > &tm_arr, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > grav_gpu, const amrex::BCRec *bc_ptr, const bool use_SurfLayer, const amrex::Real implicit_fac)
void DiffusionSrcForState_N(const amrex::Box &bx, const amrex::Box &domain, int start_comp, int num_comp, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &cell_data, const amrex::Array4< const amrex::Real > &cell_prim, const amrex::Array4< amrex::Real > &cell_rhs, const amrex::Array4< amrex::Real > &xflux, const amrex::Array4< amrex::Real > &yflux, const amrex::Array4< amrex::Real > &zflux, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &SmnSmn_a, const amrex::Array4< const amrex::Real > &mf_mx, const amrex::Array4< const amrex::Real > &mf_ux, const amrex::Array4< const amrex::Real > &mf_vx, const amrex::Array4< const amrex::Real > &mf_my, const amrex::Array4< const amrex::Real > &mf_uy, const amrex::Array4< const amrex::Real > &mf_vy, amrex::Array4< amrex::Real > &hfx_z, amrex::Array4< amrex::Real > &qfx1_z, amrex::Array4< amrex::Real > &qfx2_z, amrex::Array4< amrex::Real > &diss, const amrex::Array4< const amrex::Real > &mu_turb, const SolverChoice &solverChoice, const int level, const amrex::Array4< const amrex::Real > &tm_arr, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > grav_gpu, const amrex::BCRec *bc_ptr, const bool use_SurfLayer, const amrex::Real implicit_fac)
void EBAdvectionSrcForScalars(const amrex::Box &bx, const int icomp, const int ncomp, const amrex::Array4< const amrex::Real > &avg_xmom, const amrex::Array4< const amrex::Real > &avg_ymom, const amrex::Array4< const amrex::Real > &avg_zmom, const amrex::Array4< const amrex::Real > &cell_prim, const amrex::Array4< amrex::Real > &src, const amrex::Array4< const int > &mask_arr, const amrex::Array4< const amrex::EBCellFlag > &cfg_arr, const amrex::Array4< const amrex::Real > &ax_arr, const amrex::Array4< const amrex::Real > &ay_arr, const amrex::Array4< const amrex::Real > &az_arr, const amrex::Array4< const amrex::Real > &fcx_arr, const amrex::Array4< const amrex::Real > &fcy_arr, const amrex::Array4< const amrex::Real > &fcz_arr, const amrex::Array4< const amrex::Real > &vf_arr, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_mx, const amrex::Array4< const amrex::Real > &mf_my, const AdvType horiz_adv_type, const AdvType vert_adv_type, const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac, const amrex::GpuArray< const amrex::Array4< amrex::Real >, AMREX_SPACEDIM > &flx_arr, const amrex::Box &domain, const amrex::BCRec *bc_ptr_h, bool already_on_centroids)
void EBAdvectionSrcForRho(const amrex::Box &bx, const amrex::Array4< amrex::Real > &src, const amrex::Array4< const amrex::Real > &rho_u, const amrex::Array4< const amrex::Real > &rho_v, const amrex::Array4< const amrex::Real > &omega, const amrex::Array4< amrex::Real > &avg_xmom, const amrex::Array4< amrex::Real > &avg_ymom, const amrex::Array4< amrex::Real > &avg_zmom, const amrex::Array4< const int > &mask_arr, const amrex::Array4< const amrex::EBCellFlag > &cfg_arr, const amrex::Array4< const amrex::Real > &ax_arr, const amrex::Array4< const amrex::Real > &ay_arr, const amrex::Array4< const amrex::Real > &az_arr, const amrex::Array4< const amrex::Real > &fcx_arr, const amrex::Array4< const amrex::Real > &fcy_arr, const amrex::Array4< const amrex::Real > &fcz_arr, const amrex::Array4< const amrex::Real > &detJ, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_mx, const amrex::Array4< const amrex::Real > &mf_my, const amrex::Array4< const amrex::Real > &mf_uy, const amrex::Array4< const amrex::Real > &mf_vx, const amrex::GpuArray< const amrex::Array4< amrex::Real >, AMREX_SPACEDIM > &flx_arr, const bool fixed_rho, bool already_on_centroids)
#define Rho_comp
Definition: ERF_IndexDefines.H:36
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:37
AdvType
Definition: ERF_IndexDefines.H:221
void erf_make_tau_terms(int level, int nrk, const Vector< BCRec > &domain_bcs_type_h, const MultiFab &z_phys_nd, Vector< MultiFab > &S_data, const MultiFab &xvel, const MultiFab &yvel, const MultiFab &zvel, Vector< std::unique_ptr< MultiFab >> &Tau_lev, Vector< std::unique_ptr< MultiFab >> &Tau_corr_lev, MultiFab *SmnSmn, MultiFab *eddyDiffs, const Geometry geom, const SolverChoice &solverChoice, std::unique_ptr< SurfaceLayer > &, Gpu::DeviceVector< Real > &stretched_dz_d, const MultiFab &detJ, Vector< std::unique_ptr< MultiFab >> &mapfac)
Definition: ERF_MakeTauTerms.cpp:12
amrex::Real Real
Definition: ERF_ShocInterface.H:19
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real OmegaFromW(int &i, int &j, int &k, amrex::Real w, const amrex::Array4< const amrex::Real > &u_arr, const amrex::Array4< const amrex::Real > &v_arr, const amrex::Array4< const amrex::Real > &mf_u, const amrex::Array4< const amrex::Real > &mf_v, const amrex::Array4< const amrex::Real > &z_nd, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dxInv)
Definition: ERF_TerrainMetrics.H:412
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_zeta_AtIface(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:102
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_h_zeta_AtJface(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:142
AMREX_FORCE_INLINE amrex::IntVect TileNoZ()
Definition: ERF_TileNoZ.H:11
const std::unique_ptr< amrex::EBFArrayBoxFactory > & get_const_factory() const noexcept
Definition: ERF_EB.H:46
@ yvel_bc
Definition: ERF_IndexDefines.H:88
@ xvel_bc
Definition: ERF_IndexDefines.H:87
@ ext_dir
Definition: ERF_IndexDefines.H:209
@ ext_dir_upwind
Definition: ERF_IndexDefines.H:217
@ gpz
Definition: ERF_IndexDefines.H:152
@ gpy
Definition: ERF_IndexDefines.H:151
@ gpx
Definition: ERF_IndexDefines.H:150
@ NumTypes
Definition: ERF_IndexDefines.H:162
@ ymom
Definition: ERF_IndexDefines.H:160
@ cons
Definition: ERF_IndexDefines.H:158
@ zmom
Definition: ERF_IndexDefines.H:161
@ xmom
Definition: ERF_IndexDefines.H:159
@ qt
Definition: ERF_Kessler.H:27
@ xvel
Definition: ERF_IndexDefines.H:141
@ zvel
Definition: ERF_IndexDefines.H:143
@ yvel
Definition: ERF_IndexDefines.H:142
AdvType dycore_vert_adv_type
Definition: ERF_AdvStruct.H:420
amrex::Real dycore_vert_upw_frac
Definition: ERF_AdvStruct.H:430
AdvType dycore_horiz_adv_type
Definition: ERF_AdvStruct.H:419
amrex::Real dycore_horiz_upw_frac
Definition: ERF_AdvStruct.H:429
Definition: ERF_DiffStruct.H:19
MolecDiffType molec_diff_type
Definition: ERF_DiffStruct.H:84
static MeshType mesh_type
Definition: ERF_DataStruct.H:983
DiffChoice diffChoice
Definition: ERF_DataStruct.H:992
amrex::Real gravity
Definition: ERF_DataStruct.H:1056
bool use_shoc
Definition: ERF_DataStruct.H:1085
amrex::Vector< amrex::Real > vert_implicit_fac
Definition: ERF_DataStruct.H:1016
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > abl_pressure_grad
Definition: ERF_DataStruct.H:1108
bool implicit_thermal_diffusion
Definition: ERF_DataStruct.H:1018
amrex::Vector< TurbChoice > turbChoice
Definition: ERF_DataStruct.H:995
amrex::Vector< int > anelastic
Definition: ERF_DataStruct.H:1000
AdvChoice advChoice
Definition: ERF_DataStruct.H:991
MoistureType moisture_type
Definition: ERF_DataStruct.H:1101
static TerrainType terrain_type
Definition: ERF_DataStruct.H:971
amrex::Vector< int > fixed_density
Definition: ERF_DataStruct.H:1001
bool use_rotate_surface_flux
Definition: ERF_DataStruct.H:1082
CouplingType coupling_type
Definition: ERF_DataStruct.H:1100
Definition: ERF_TurbStruct.H:41
PBLType pbl_type
Definition: ERF_TurbStruct.H:390
bool use_keqn
Definition: ERF_TurbStruct.H:397
RANSType rans_type
Definition: ERF_TurbStruct.H:387
LESType les_type
Definition: ERF_TurbStruct.H:345
bool use_kturb
Definition: ERF_TurbStruct.H:396
Here is the call graph for this function: