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