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