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