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