ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_SlowRhsPost.cpp File Reference
#include <AMReX.H>
#include <ERF_SrcHeaders.H>
#include <ERF_TI_slow_headers.H>
#include <ERF_ShocDriver.H>
#include <ERF_EBAdvection.H>
#include <ERF_EBRedistribute.H>
#include "ERF_ResolvedWallFlux.H"
#include "Prob/ERF_CloudChamberBudget.H"
Include dependency graph for ERF_SlowRhsPost.cpp:

Functions

void erf_slow_rhs_post (int level, int finest_level, int nrk, double dt_d, int n_qstate, Vector< MultiFab > &S_rhs, Vector< MultiFab > &S_old, Vector< MultiFab > &S_new, Vector< MultiFab > &S_data, const MultiFab &S_prim, MultiFab &avg_xmom, MultiFab &avg_ymom, MultiFab &avg_zmom, const MultiFab &xvel, const MultiFab &yvel, const MultiFab &, const MultiFab &source, MultiFab *terrain_blank, const MultiFab *SmnSmn, const MultiFab *eddyDiffs, MultiFab *Hfx1, MultiFab *Hfx2, MultiFab *Hfx3, MultiFab *Q1fx1, MultiFab *Q1fx2, MultiFab *Q1fx3, MultiFab *Q2fx3, MultiFab *Diss, const Geometry geom, const SolverChoice &solverChoice, std::unique_ptr< SurfaceLayer > &SurfLayer, const Gpu::DeviceVector< BCRec > &domain_bcs_type_d, const Vector< BCRec > &domain_bcs_type_h, std::unique_ptr< MultiFab > &z_phys_nd, std::unique_ptr< MultiFab > &z_phys_cc, std::unique_ptr< MultiFab > &ax, std::unique_ptr< MultiFab > &ay, std::unique_ptr< MultiFab > &az, std::unique_ptr< MultiFab > &detJ, MultiFab *detJ_new, Gpu::DeviceVector< Real > &stretched_dz_d, Vector< std::unique_ptr< MultiFab >> &mapfac, amrex::EBFArrayBoxFactory const &ebfact, ShocDriver *native_shoc_lev, YAFluxRegister *fr_as_crse, YAFluxRegister *fr_as_fine, std::unique_ptr< ReadBndryPlanes > &m_r2d, const MultiFab *cloud_chamber_base_state, const erf_cloud_chamber::Config *cloud_chamber_config, CloudChamberBudget *cloud_budget)
 

Function Documentation

◆ erf_slow_rhs_post()

void erf_slow_rhs_post ( int  level,
int  finest_level,
int  nrk,
double  dt_d,
int  n_qstate,
Vector< MultiFab > &  S_rhs,
Vector< MultiFab > &  S_old,
Vector< MultiFab > &  S_new,
Vector< MultiFab > &  S_data,
const MultiFab &  S_prim,
MultiFab &  avg_xmom,
MultiFab &  avg_ymom,
MultiFab &  avg_zmom,
const MultiFab &  xvel,
const MultiFab &  yvel,
const MultiFab &  ,
const MultiFab &  source,
MultiFab *  terrain_blank,
const MultiFab *  SmnSmn,
const MultiFab *  eddyDiffs,
MultiFab *  Hfx1,
MultiFab *  Hfx2,
MultiFab *  Hfx3,
MultiFab *  Q1fx1,
MultiFab *  Q1fx2,
MultiFab *  Q1fx3,
MultiFab *  Q2fx3,
MultiFab *  Diss,
const Geometry  geom,
const SolverChoice solverChoice,
std::unique_ptr< SurfaceLayer > &  SurfLayer,
const Gpu::DeviceVector< BCRec > &  domain_bcs_type_d,
const Vector< BCRec > &  domain_bcs_type_h,
std::unique_ptr< MultiFab > &  z_phys_nd,
std::unique_ptr< MultiFab > &  z_phys_cc,
std::unique_ptr< MultiFab > &  ax,
std::unique_ptr< MultiFab > &  ay,
std::unique_ptr< MultiFab > &  az,
std::unique_ptr< MultiFab > &  detJ,
MultiFab *  detJ_new,
Gpu::DeviceVector< Real > &  stretched_dz_d,
Vector< std::unique_ptr< MultiFab >> &  mapfac,
amrex::EBFArrayBoxFactory const &  ebfact,
ShocDriver native_shoc_lev,
YAFluxRegister *  fr_as_crse,
YAFluxRegister *  fr_as_fine,
std::unique_ptr< ReadBndryPlanes > &  m_r2d,
const MultiFab *  cloud_chamber_base_state,
const erf_cloud_chamber::Config cloud_chamber_config,
CloudChamberBudget cloud_budget 
)

Function for computing the slow RHS for the evolution equations for the scalars other than density or potential temperature

Parameters
[in]evellevel of resolution
[in]finest_levelfinest level of resolution
[in]nrkwhich RK stage
[in]dtslow time step
[out]S_rhsRHS computed here
[in]S_oldsolution at start of time step
[in]S_newsolution at end of current RK stage
[in]S_datacurrent solution
[in]S_primprimitive variables (i.e. conserved variables divided by density)
[in]avg_xmom
[in]avg_ymom
[in]avg_zmom
[in]xvelx-component of velocity
[in]yvely-component of velocity
[in]zvelz-component of velocity
[in]sourcesource terms for conserved variables
[in]terrain_blankimmersed forcing mask
[in]SmnSmnstrain rate magnitude
[in]eddyDiffsdiffusion coefficients for LES turbulence models
[in]Hfx3heat flux in z-dir
[in]Dissdissipation of turbulent kinetic energy
[in]geomContainer for geometric information
[in]solverChoiceContainer for solver parameters
[in]SurfLayerPointer to SurfaceLayer class for Monin-Obukhov Similarity Theory boundary condition
[in]domain_bcs_type_ddevice vector for domain boundary conditions
[in]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 at start of time step (= 1 if use_terrain is false)
[in]detJ_newJacobian of the metric transformation at new RK stage time (= 1 if use_terrain is false)
[in]mapfacmap factors
[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
99 {
100  BL_PROFILE_REGION("erf_slow_rhs_post()");
101 
102  Real dt = static_cast<Real>(dt_d);
103 
104  const BCRec* bc_ptr_d = domain_bcs_type_d.data();
105  const BCRec* bc_ptr_h = domain_bcs_type_h.data();
106 
107  AdvChoice ac = solverChoice.advChoice;
108  DiffChoice dc = solverChoice.diffChoice;
109  TurbChoice tc = solverChoice.turbChoice[level];
110 
111  const MultiFab* t_mean_mf = nullptr;
112  if (SurfLayer) { t_mean_mf = SurfLayer->get_mac_avg(level,2); }
113 
114  const bool l_use_terrain = (solverChoice.mesh_type != MeshType::ConstantDz);
115  const bool l_moving_terrain = (solverChoice.terrain_type == TerrainType::MovingFittedMesh);
116  const bool l_reflux = ( (solverChoice.coupling_type == CouplingType::TwoWay) && (nrk == 2) && (finest_level > 0) );
117  if (l_moving_terrain) AMREX_ALWAYS_ASSERT(l_use_terrain);
118 
119  const bool l_anelastic = solverChoice.anelastic[level];
120 
121  const bool l_use_KE = ( tc.use_tke );
122  const bool l_need_SmnSmn = ( tc.les_type == LESType::Deardorff ||
123  tc.rans_type == RANSType::kEqn );
124  const bool l_advect_KE = ( tc.use_tke && tc.advect_tke );
125  const bool l_use_diff = ((dc.molec_diff_type != MolecDiffType::None) ||
126  (tc.les_type != LESType::None) ||
127  (tc.rans_type != RANSType::None) ||
128  (tc.pbl_type != PBLType::None) );
129  const bool l_use_turb = tc.use_kturb;
130  const bool l_rotate = (solverChoice.use_rotate_surface_flux);
131  const bool l_do_scalar = (solverChoice.transport_scalar);
132  const bool l_use_eb = (solverChoice.terrain_type == TerrainType::EB);
133 
134  amrex::ignore_unused(m_r2d);
135 
136  const Box& domain = geom.Domain();
137 
138  bool l_apply_surface_layer_fluxes_in_diffusion = (SurfLayer != nullptr);
139 #ifdef ERF_USE_EAMXX_SHOC
140  if (tc.uses_eamxx_shoc()) {
141  l_apply_surface_layer_fluxes_in_diffusion = false;
142  }
143 #endif
144  if (tc.uses_native_shoc()) {
145  AMREX_ALWAYS_ASSERT(native_shoc_lev != nullptr);
146  l_apply_surface_layer_fluxes_in_diffusion =
147  l_apply_surface_layer_fluxes_in_diffusion &&
148  native_shoc_lev->uses_host_diffusion();
149  }
150 
151  const GpuArray<Real, AMREX_SPACEDIM> dxInv = geom.InvCellSizeArray();
152  const Real* dx = geom.CellSize();
153 
154  // *************************************************************************
155  // Set gravity as a vector
156  // *************************************************************************
157  const Array<Real,AMREX_SPACEDIM> grav{zero, zero, -solverChoice.gravity};
158  const GpuArray<Real,AMREX_SPACEDIM> grav_gpu{grav[0], grav[1], grav[2]};
159 
160  // *************************************************************************
161  // Pre-computed quantities
162  // *************************************************************************
163  int nvars = S_data[IntVars::cons].nComp();
164  const BoxArray& ba = S_data[IntVars::cons].boxArray();
165  const DistributionMapping& dm = S_data[IntVars::cons].DistributionMap();
166  const bool use_physical_chamber_wall_flux =
167  cloud_chamber_config != nullptr && cloud_chamber_base_state != nullptr &&
168  cloud_chamber_config->physical_initialization;
169  const erf_wall_thermodynamics::Boundary chamber_walls =
170  use_physical_chamber_wall_flux ? cloud_chamber_config->wall_boundary() :
172 
173  std::unique_ptr<MultiFab> dflux_x;
174  std::unique_ptr<MultiFab> dflux_y;
175  std::unique_ptr<MultiFab> dflux_z;
176 
177  if (l_use_diff) {
178  IntVect ng(0,0,1);
179  // The physical chamber needs one persistent component for each moist
180  // state even when budgets are disabled: qv and qc are corrected and
181  // retained independently. All other configurations retain ERF's
182  // established one-component reusable diffusion storage.
183  const int n_flux_components = use_physical_chamber_wall_flux ?
184  std::max(1, n_qstate) : 1;
185  dflux_x = std::make_unique<MultiFab>(convert(ba,IntVect(1,0,0)), dm, n_flux_components, ng);
186  dflux_y = std::make_unique<MultiFab>(convert(ba,IntVect(0,1,0)), dm, n_flux_components, ng);
187  dflux_z = std::make_unique<MultiFab>(convert(ba,IntVect(0,0,1)), dm, n_flux_components, 0);
188  // Every physical wall override reads the old face flux before
189  // replacing it; make that read deterministic regardless of budget
190  // diagnostics.
191  if (use_physical_chamber_wall_flux) {
192  dflux_x->setVal(0.0);
193  dflux_y->setVal(0.0);
194  dflux_z->setVal(0.0);
195  }
196  } else {
197  dflux_x = nullptr;
198  dflux_y = nullptr;
199  dflux_z = nullptr;
200  }
201 
202  // Valid vars
203  Vector<int> is_valid_slow_var; is_valid_slow_var.resize(RhoQ1_comp+1,0);
204  if (l_use_KE) { is_valid_slow_var[ RhoKE_comp] = 1; }
205  if (l_do_scalar) { is_valid_slow_var[RhoScalar_comp] = 1; }
206  if (solverChoice.moisture_type != MoistureType::None) {
207  is_valid_slow_var[RhoQ1_comp] = 1;
208  }
209 
210  // *************************************************************************
211  // Calculate cell-centered eddy viscosity & diffusivities
212  //
213  // Notes -- we fill all the data in ghost cells before calling this so
214  // that we can fill the eddy viscosity in the ghost regions and
215  // not have to call a boundary filler on this data itself
216  //
217  // LES - updates both horizontal and vertical eddy viscosityS_tmp components
218  // PBL - only updates vertical eddy viscosity components so horizontal
219  // components come from the LES model or are left as zero.
220  // *************************************************************************
221 
222  // EB Anelastic: Copy projected momentum with ghost-cell synchronization
223  if (l_anelastic && l_use_eb) {
224  avg_xmom.ParallelCopy(S_data[IntVars::xmom], 0, 0, 1, 0, 1, geom.periodicity());
225  avg_ymom.ParallelCopy(S_data[IntVars::ymom], 0, 0, 1, 0, 1, geom.periodicity());
226  avg_zmom.ParallelCopy(S_data[IntVars::zmom], 0, 0, 1, 0, 1, geom.periodicity());
227  }
228 
229  // *************************************************************************
230  // Define updates and fluxes in the current RK stage
231  // *************************************************************************
232 #ifdef _OPENMP
233 #pragma omp parallel if (Gpu::notInLaunchRegion())
234 #endif
235  {
236  std::array<FArrayBox,AMREX_SPACEDIM> flux;
237 
238  int start_comp;
239  int num_comp;
240 
241  // Cell-centered masks for EB (used for flux interpolation)
242  iMultiFab physbnd_mask;
243  bool already_on_centroids = false;
244  if (l_use_eb) {
245  physbnd_mask.define(S_data[IntVars::cons].boxArray(), S_data[IntVars::cons].DistributionMap(), 1, 1);
246  physbnd_mask.BuildMask(geom.Domain(), geom.periodicity(), 1, 1, 0, 1);
247  }
248 
249  for (MFIter mfi(S_data[IntVars::cons],TilingIfNotGPU()); mfi.isValid(); ++mfi) {
250 
251  Box tbx = mfi.tilebox();
252 
253  // *************************************************************************
254  // Define flux arrays for use in advection
255  // *************************************************************************
256  for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
257  if (!l_use_eb) {
258  flux[dir].resize(surroundingNodes(tbx,dir),nvars,The_Async_Arena());
259  } else {
260  flux[dir].resize(surroundingNodes(tbx,dir).grow(1),nvars,The_Async_Arena());
261  }
262  flux[dir].setVal<RunOn::Device>(0);
263  }
264  const GpuArray<const Array4<Real>, AMREX_SPACEDIM>
265  flx_arr{{AMREX_D_DECL(flux[0].array(), flux[1].array(), flux[2].array())}};
266 
267  // *************************************************************************
268  // Define Array4's
269  // *************************************************************************
270  const Array4<const Real> & old_cons = S_old[IntVars::cons].array(mfi);
271  const Array4< Real> & cell_rhs = S_rhs[IntVars::cons].array(mfi);
272 
273  const Array4< Real> & new_cons = S_new[IntVars::cons].array(mfi);
274  const Array4< Real> & new_xmom = S_new[IntVars::xmom].array(mfi);
275  const Array4< Real> & new_ymom = S_new[IntVars::ymom].array(mfi);
276  const Array4< Real> & new_zmom = S_new[IntVars::zmom].array(mfi);
277 
278  const Array4< Real> & cur_cons = S_data[IntVars::cons].array(mfi);
279  const Array4<const Real> & cur_prim = S_prim.array(mfi);
280  const Array4< Real> & cur_xmom = S_data[IntVars::xmom].array(mfi);
281  const Array4< Real> & cur_ymom = S_data[IntVars::ymom].array(mfi);
282  const Array4< Real> & cur_zmom = S_data[IntVars::zmom].array(mfi);
283 
284  Array4<Real> avg_xmom_arr = avg_xmom.array(mfi);
285  Array4<Real> avg_ymom_arr = avg_ymom.array(mfi);
286  Array4<Real> avg_zmom_arr = avg_zmom.array(mfi);
287 
288  const Array4<const Real> & u = xvel.array(mfi);
289  const Array4<const Real> & v = yvel.array(mfi);
290 
291  const Array4<const Real>& z_nd = z_phys_nd->const_array(mfi);
292  const Array4<const Real>& z_cc = z_phys_cc->const_array(mfi);
293  const Array4<const Real>& detJ_new_arr = l_moving_terrain ? detJ_new->const_array(mfi) : Array4<const Real>{};
294 
295  const Array4<const Real>& t_blank_arr = (terrain_blank) ? terrain_blank->const_array(mfi) :
296  Array4<const Real>{};
297 
298  // Map factors
299  const Array4<const Real>& mf_mx = mapfac[MapFacType::m_x]->const_array(mfi);
300  const Array4<const Real>& mf_ux = mapfac[MapFacType::u_x]->const_array(mfi);
301  const Array4<const Real>& mf_vx = mapfac[MapFacType::v_x]->const_array(mfi);
302  const Array4<const Real>& mf_my = mapfac[MapFacType::m_y]->const_array(mfi);
303  const Array4<const Real>& mf_uy = mapfac[MapFacType::u_y]->const_array(mfi);
304  const Array4<const Real>& mf_vy = mapfac[MapFacType::v_y]->const_array(mfi);
305 
306  // SmnSmn for KE src with Deardorff or k-eqn RANS
307  const Array4<const Real>& SmnSmn_a = l_need_SmnSmn ? SmnSmn->const_array(mfi) : Array4<const Real>{};
308 
309  // **************************************************************************
310  // Here we fill the "current" data with "new" data because that is the result of the previous RK stage
311  // **************************************************************************
312  int nsv = S_old[IntVars::cons].nComp() - 2;
313  const GpuArray<int, IntVars::NumTypes> scomp_slow = { 2,0,0,0};
314  const GpuArray<int, IntVars::NumTypes> ncomp_slow = {nsv,0,0,0};
315 
316  // **************************************************************************
317  // Note that here we do copy only the "slow" variables, not (rho) or (rho theta)
318  // **************************************************************************
319  ParallelFor(tbx, ncomp_slow[IntVars::cons],
320  [=] AMREX_GPU_DEVICE (int i, int j, int k, int nn) {
321  const int n = scomp_slow[IntVars::cons] + nn;
322  cur_cons(i,j,k,n) = new_cons(i,j,k,n);
323  });
324 
325  // Non-EB Anelastic: Per-tile copy of projected momentum (EB done above)
326  if (l_anelastic && !l_use_eb) {
327  Box tbx_inc = mfi.nodaltilebox(0);
328  Box tby_inc = mfi.nodaltilebox(1);
329  Box tbz_inc = mfi.nodaltilebox(2);
330 
331  ParallelFor(tbx_inc, tby_inc, tbz_inc,
332  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
333  avg_xmom_arr(i,j,k) = cur_xmom(i,j,k);
334  },
335  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
336  avg_ymom_arr(i,j,k) = cur_ymom(i,j,k);
337  },
338  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
339  avg_zmom_arr(i,j,k) = cur_zmom(i,j,k);
340  });
341  }
342 
343  // **************************************************************************
344  // Define updates in the RHS of continuity, temperature, and scalar equations
345  // **************************************************************************
346  bool l_eb_terrain_cc = false; // EB terrain on cell-centered grid
347  Array4<const int> mask_arr{};
348  Array4<const EBCellFlag> cfg_arr{};
349  Array4<const Real> ax_arr{};
350  Array4<const Real> ay_arr{};
351  Array4<const Real> az_arr{};
352  Array4<const Real> fcx_arr{};
353  Array4<const Real> fcy_arr{};
354  Array4<const Real> fcz_arr{};
355  Array4<const Real> detJ_arr{};
356  Array4<const Real> barea_arr{};
357  Array4<const Real> bcent_arr{};
358 
359  if (l_use_eb) {
360  EBCellFlagFab const& cfg = ebfact.getMultiEBCellFlagFab()[mfi];
361  cfg_arr = cfg.const_array();
362  if (cfg.getType(tbx) == FabType::singlevalued) {
363  l_eb_terrain_cc = true;
364  ax_arr = ebfact.getAreaFrac()[0]->const_array(mfi);
365  ay_arr = ebfact.getAreaFrac()[1]->const_array(mfi);
366  az_arr = ebfact.getAreaFrac()[2]->const_array(mfi);
367  fcx_arr = ebfact.getFaceCent()[0]->const_array(mfi);
368  fcy_arr = ebfact.getFaceCent()[1]->const_array(mfi);
369  fcz_arr = ebfact.getFaceCent()[2]->const_array(mfi);
370  detJ_arr = ebfact.getVolFrac().const_array(mfi);
371  mask_arr = physbnd_mask.const_array(mfi);
372  barea_arr = ebfact.getBndryArea().const_array(mfi);
373  bcent_arr = ebfact.getBndryCent().const_array(mfi);
374  } else {
375  ax_arr = ax->const_array(mfi);
376  ay_arr = ay->const_array(mfi);
377  az_arr = az->const_array(mfi);
378  detJ_arr = detJ->const_array(mfi);
379  }
380  } else {
381  ax_arr = ax->const_array(mfi);
382  ay_arr = ay->const_array(mfi);
383  az_arr = az->const_array(mfi);
384  detJ_arr = detJ->const_array(mfi);
385  }
386 
387  AdvType horiz_adv_type, vert_adv_type;
388  Real horiz_upw_frac, vert_upw_frac;
389 
390  Array4<Real> diffflux_x, diffflux_y, diffflux_z;
391  Array4<Real> hfx_x, hfx_y, hfx_z, diss;
392  Array4<Real> q1fx_x, q1fx_y, q1fx_z, q2fx_z;
393  Array4<Real> hfx_EB{};
394 
395  if (l_use_diff) {
396  diffflux_x = dflux_x->array(mfi);
397  diffflux_y = dflux_y->array(mfi);
398  diffflux_z = dflux_z->array(mfi);
399 
400  hfx_x = Hfx1->array(mfi);
401  hfx_y = Hfx2->array(mfi);
402  hfx_z = Hfx3->array(mfi);
403  diss = Diss->array(mfi);
404 
405  if (Q1fx1) q1fx_x = Q1fx1->array(mfi);
406  if (Q1fx2) q1fx_y = Q1fx2->array(mfi);
407  if (Q1fx3) q1fx_z = Q1fx3->array(mfi);
408  if (Q2fx3) q2fx_z = Q2fx3->array(mfi);
409  }
410 
411  if (l_use_diff && l_use_turb) {
413  eddyDiffs != nullptr,
414  "erf_slow_rhs_post: active turbulence requires non-null eddyDiffs");
415  }
416  const Array4<const Real>& mu_turb =
417  l_use_turb ? eddyDiffs->const_array(mfi) : Array4<const Real>{};
418 
419  //
420  // Note that we either advect and diffuse all or none of the moisture variables
421  //
422  for (int ivar(RhoKE_comp); ivar<= RhoQ1_comp; ++ivar)
423  {
424 
425  if (is_valid_slow_var[ivar])
426  {
427  start_comp = ivar;
428  num_comp = 1;
429 
430  if (ivar == RhoQ1_comp) {
431  horiz_adv_type = ac.moistscal_horiz_adv_type;
432  vert_adv_type = ac.moistscal_vert_adv_type;
433  horiz_upw_frac = ac.moistscal_horiz_upw_frac;
434  vert_upw_frac = ac.moistscal_vert_upw_frac;
435 
436  if (ac.use_efficient_advection){
437  horiz_adv_type = EfficientAdvType(nrk,ac.moistscal_horiz_adv_type);
438  vert_adv_type = EfficientAdvType(nrk,ac.moistscal_vert_adv_type);
439  }
440 
441  num_comp = n_qstate;
442 
443  } else {
444  horiz_adv_type = ac.dryscal_horiz_adv_type;
445  vert_adv_type = ac.dryscal_vert_adv_type;
446  horiz_upw_frac = ac.dryscal_horiz_upw_frac;
447  vert_upw_frac = ac.dryscal_vert_upw_frac;
448 
449  if (ac.use_efficient_advection){
450  horiz_adv_type = EfficientAdvType(nrk,ac.dryscal_horiz_adv_type);
451  vert_adv_type = EfficientAdvType(nrk,ac.dryscal_vert_adv_type);
452  }
453 
454  if (ivar == RhoScalar_comp) {
455  num_comp = NSCALARS;
456  }
457  }
458 
459  if (( ivar != RhoKE_comp ) ||
460  ((ivar == RhoKE_comp) && l_advect_KE))
461  {
462  if (!l_eb_terrain_cc){
463  AdvectionSrcForScalars(tbx, start_comp, num_comp,
464  avg_xmom_arr, avg_ymom_arr, avg_zmom_arr,
465  cur_prim, cell_rhs,
466  detJ_arr, dxInv, mf_mx, mf_my,
467  horiz_adv_type, vert_adv_type,
468  horiz_upw_frac, vert_upw_frac,
469  flx_arr, domain, bc_ptr_h);
470  } else {
471  EBAdvectionSrcForScalars(tbx, start_comp, num_comp,
472  avg_xmom_arr, avg_ymom_arr, avg_zmom_arr,
473  cur_prim, cell_rhs,
474  mask_arr, cfg_arr, ax_arr, ay_arr, az_arr,
475  fcx_arr, fcy_arr, fcz_arr,
476  detJ_arr, dxInv, mf_mx, mf_my,
477  horiz_adv_type, vert_adv_type,
478  horiz_upw_frac, vert_upw_frac,
479  flx_arr, domain, bc_ptr_h,
480  already_on_centroids);
481  }
482  }
483 
484  if (l_use_diff)
485  {
486  // Allow for implicit moisture diffusion
488  if ( (ivar == RhoKE_comp && solverChoice.implicit_ke_diffusion ) ||
489  (ivar == RhoQ1_comp && solverChoice.implicit_moisture_diffusion) ) {
490  l_vert_implicit_fac = solverChoice.vert_implicit_fac[level][nrk];
491  }
492 
493  const Array4<const Real> tm_arr = t_mean_mf ? t_mean_mf->const_array(mfi) : Array4<const Real>{};
494 
495  // Only the physical chamber needs separate qv/qc calls:
496  // its wall correction must be applied to distinct flux
497  // components. Generic moisture models retain the
498  // established multi-component diffusion call.
499  const bool componentwise_moisture =
500  use_physical_chamber_wall_flux && ivar == RhoQ1_comp;
501  const int n_diff_calls = componentwise_moisture ? n_qstate : 1;
502  for (int qstate = 0; qstate < n_diff_calls; ++qstate) {
503  const int state_comp = componentwise_moisture ?
504  RhoQ1_comp + qstate : start_comp;
505  const int diffusion_start = state_comp;
506  const int diffusion_num = componentwise_moisture ? 1 : num_comp;
507  const int flux_comp = componentwise_moisture ? qstate : 0;
508  AMREX_ALWAYS_ASSERT(state_comp >= 0 && state_comp < nvars);
509  AMREX_ALWAYS_ASSERT(flux_comp < dflux_x->nComp());
510  AMREX_ALWAYS_ASSERT(flux_comp < dflux_y->nComp());
511  AMREX_ALWAYS_ASSERT(flux_comp < dflux_z->nComp());
512  const Array4<Real> diffusion_x = dflux_x->array(mfi, flux_comp);
513  const Array4<Real> diffusion_y = dflux_y->array(mfi, flux_comp);
514  const Array4<Real> diffusion_z = dflux_z->array(mfi, flux_comp);
515 
516  if (solverChoice.mesh_type == MeshType::StretchedDz) {
517  DiffusionSrcForState_S(tbx, domain, diffusion_start, diffusion_num, u, v,
518  new_cons, cur_prim, cell_rhs,
519  diffusion_x, diffusion_y, diffusion_z,
520  stretched_dz_d, dxInv, SmnSmn_a,
521  mf_mx, mf_ux, mf_vx,
522  mf_my, mf_uy, mf_vy,
523  hfx_z, q1fx_z, q2fx_z, diss,
524  mu_turb, solverChoice, level,
525  tm_arr, grav_gpu, bc_ptr_d, l_apply_surface_layer_fluxes_in_diffusion, l_vert_implicit_fac);
526  } else if (l_use_terrain) {
527  DiffusionSrcForState_T(tbx, domain, diffusion_start, diffusion_num, l_rotate, u, v,
528  new_cons, cur_prim, cell_rhs,
529  diffusion_x, diffusion_y, diffusion_z,
530  z_nd, z_cc, ax_arr, ay_arr, az_arr,
531  detJ_arr, dxInv, SmnSmn_a,
532  mf_mx, mf_ux, mf_vx,
533  mf_my, mf_uy, mf_vy,
534  hfx_x, hfx_y, hfx_z, q1fx_x, q1fx_y, q1fx_z,q2fx_z, diss,
535  mu_turb, solverChoice, level,
536  tm_arr, grav_gpu, bc_ptr_d, l_apply_surface_layer_fluxes_in_diffusion, l_vert_implicit_fac);
537  } else if (l_use_eb) {
538  DiffusionSrcForState_EB(tbx, domain, diffusion_start, diffusion_num, u, v,
539  new_cons, cur_prim, cell_rhs,
540  diffusion_x, diffusion_y, diffusion_z,
541  cfg_arr, ax_arr, ay_arr, az_arr, detJ_arr,
542  barea_arr, bcent_arr,
543  dx, dxInv,
544  hfx_z, q1fx_z, q2fx_z, hfx_EB,
545  mu_turb, solverChoice, level,
546  bc_ptr_d, l_apply_surface_layer_fluxes_in_diffusion);
547  } else {
548  DiffusionSrcForState_N(tbx, domain, diffusion_start, diffusion_num, u, v,
549  new_cons, cur_prim, cell_rhs,
550  diffusion_x, diffusion_y, diffusion_z, dxInv, SmnSmn_a,
551  mf_mx, mf_ux, mf_vx,
552  mf_my, mf_uy, mf_vy,
553  hfx_z, q1fx_z, q2fx_z, diss,
554  mu_turb, solverChoice, level,
555  tm_arr, grav_gpu, bc_ptr_d, l_apply_surface_layer_fluxes_in_diffusion, l_vert_implicit_fac);
556  }
557  if (use_physical_chamber_wall_flux) {
558  // Apply the physical wall correction immediately to
559  // the flux component just computed. This keeps the
560  // q-state diffusion path identical with budgets on
561  // and off and guarantees no stale flux is consumed.
562  // The diffusion views are component-shifted; the
563  // wall helper receives the unshifted views and the
564  // explicit flux component index.
566  tbx, domain, state_comp, flux_comp, new_cons, cur_prim,
567  cloud_chamber_base_state->const_array(mfi), cell_rhs,
568  diffflux_x, diffflux_y, diffflux_z, dxInv,
569  chamber_walls, dc.alpha_T, dc.alpha_C,
570  solverChoice.rdOcp);
571  }
572  }
573  } // use_diff
574 
575 
576  } // valid slow var
577  } // loop ivar
578 
579 #ifdef ERF_USE_EAMXX_SHOC
580  if (tc.uses_eamxx_shoc() && eamxx_shoc_lev) {
581  eamxx_shoc_lev->add_slow_tend(mfi,tbx,cell_rhs);
582  }
583 #endif
584  // This updates just the "slow" conserved variables
585  {
586  BL_PROFILE("rhs_post_8");
587 
589 
590  auto const& src_arr = source.const_array(mfi);
591 
592  for (int ivar(RhoKE_comp); ivar<= RhoQ1_comp; ++ivar)
593  {
594  if (is_valid_slow_var[ivar])
595  {
596  start_comp = ivar;
597  num_comp = 1;
598  if (ivar == RhoQ1_comp) {
599  num_comp = nvars - RhoQ1_comp;
600  } else if (ivar == RhoScalar_comp) {
601  num_comp = NSCALARS;
602  }
603 
604  if (l_moving_terrain)
605  {
606  ParallelFor(tbx, num_comp,
607  [=] AMREX_GPU_DEVICE (int i, int j, int k, int nn) noexcept {
608  const int n = start_comp + nn;
609  cell_rhs(i,j,k,n) += src_arr(i,j,k,n);
610  Real temp_val = detJ_arr(i,j,k) * old_cons(i,j,k,n) + dt * detJ_arr(i,j,k) * cell_rhs(i,j,k,n);
611  cur_cons(i,j,k,n) = temp_val / detJ_new_arr(i,j,k);
612  if (ivar == RhoKE_comp) {
613  cur_cons(i,j,k,n) = amrex::max(cur_cons(i,j,k,n), eps);
614  }
615  });
616 
617  } else if (l_anelastic && (nrk == 1)) { // not moving and ( (anelastic) and second RK stage) )
618 
619  ParallelFor(tbx, num_comp,
620  [=] AMREX_GPU_DEVICE (int i, int j, int k, int nn) noexcept {
621  const int n = start_comp + nn;
622  cell_rhs(i,j,k,n) += src_arr(i,j,k,n);
623 
624  // Re-construct the cell_rhs used in the first RK stage
625  Real dt_times_old_cell_rhs = cur_cons(i,j,k,n) - old_cons(i,j,k,n);
626 
627  // Add the time-averaged RHS to the old state
628  cur_cons(i,j,k,n) = old_cons(i,j,k,n) + myhalf * (dt_times_old_cell_rhs + dt * cell_rhs(i,j,k,n));
629 
630  if (ivar == RhoKE_comp) {
631  cur_cons(i,j,k,n) = amrex::max(cur_cons(i,j,k,n), eps);
632  } else if (ivar >= RhoQ1_comp) {
633  cur_cons(i,j,k,n) = amrex::max(cur_cons(i,j,k,n), amrex::Real(0));
634  }
635  });
636 
637  } else { // not moving and ( (not anelastic) or (first RK stage) )
638 
639  ParallelFor(tbx, num_comp,
640  [=] AMREX_GPU_DEVICE (int i, int j, int k, int nn) noexcept {
641  const int n = start_comp + nn;
642  cell_rhs(i,j,k,n) += src_arr(i,j,k,n);
643  cur_cons(i,j,k,n) = old_cons(i,j,k,n) + dt * cell_rhs(i,j,k,n);
644  if (ivar == RhoKE_comp) {
645  cur_cons(i,j,k,n) = amrex::max(cur_cons(i,j,k,n), eps);
646  } else if (ivar >= RhoQ1_comp) {
647  cur_cons(i,j,k,n) = amrex::max(cur_cons(i,j,k,n), amrex::Real(0));
648  }
649  });
650 
651  } // moving, anelastic or neither?
652 
653  } // is_valid
654  } // ivar
655  } // profile
656 
657  {
658  BL_PROFILE("rhs_post_9");
659  // This updates all the conserved variables (not just the "slow" ones)
660  int num_comp_all = S_data[IntVars::cons].nComp();
661  ParallelFor(tbx, num_comp_all,
662  [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) noexcept {
663  new_cons(i,j,k,n) = cur_cons(i,j,k,n);
664  });
665  } // end profile
666 
667  Box xtbx = mfi.nodaltilebox(0);
668  Box ytbx = mfi.nodaltilebox(1);
669  Box ztbx = mfi.nodaltilebox(2);
670 
671  {
672  BL_PROFILE("rhs_post_10()");
673  if (l_anelastic && terrain_blank) { // explicitly set fully immersed cells to have 0 velocities for anelastic (unstable for fully compressible).
674  ParallelFor(xtbx, ytbx, ztbx,
675  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
676  Real t_blank = myhalf * (t_blank_arr(i, j, k ) + t_blank_arr(i-1, j, k ));
677  if (t_blank == one) {
678  new_xmom(i,j,k) = zero;
679  } else {
680  new_xmom(i,j,k) = cur_xmom(i,j,k);
681  }
682  },
683  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
684  Real t_blank = myhalf* (t_blank_arr(i, j, k ) + t_blank_arr(i, j-1, k ));
685  if (t_blank == one) {
686  new_ymom(i,j,k) = zero;
687  } else {
688  new_ymom(i,j,k) = cur_ymom(i,j,k);
689  }
690  },
691  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
692  Real t_blank = myhalf * (t_blank_arr(i, j, k ) + t_blank_arr(i, j, k-1));
693  if (t_blank == one) {
694  new_zmom(i,j,k) = zero;
695  } else {
696  new_zmom(i,j,k) = cur_zmom(i,j,k);
697  }
698  });
699  ParallelFor(tbx,
700  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
701  Real t_blank = t_blank_arr(i, j, k );
702  if (t_blank == one) { // don't update rho and theta for fully immersed cells
703  new_cons(i, j, k, Rho_comp) = old_cons(i, j, k, Rho_comp);
704  new_cons(i, j, k, RhoTheta_comp) = old_cons(i, j, k, RhoTheta_comp);
705  }
706  });
707  } else {
708  ParallelFor(xtbx, ytbx, ztbx,
709  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
710  new_xmom(i,j,k) = cur_xmom(i,j,k);
711  },
712  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
713  new_ymom(i,j,k) = cur_ymom(i,j,k);
714  },
715  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
716  new_zmom(i,j,k) = cur_zmom(i,j,k);
717  });
718  }
719  } // end profile
720 
721  {
722  BL_PROFILE("rhs_post_10");
723  // We only add to the flux registers in the final RK step
724  if (l_reflux) {
725  int strt_comp_reflux = RhoTheta_comp + 1;
726  int num_comp_reflux = nvars - strt_comp_reflux;
727  if (level < finest_level) {
728  fr_as_crse->CrseAdd(mfi,
729  {{AMREX_D_DECL(&(flux[0]), &(flux[1]), &(flux[2]))}},
730  dx, dt, strt_comp_reflux, strt_comp_reflux, num_comp_reflux, RunOn::Device);
731  }
732  if (level > 0) {
733  fr_as_fine->FineAdd(mfi,
734  {{AMREX_D_DECL(&(flux[0]), &(flux[1]), &(flux[2]))}},
735  dx, dt, strt_comp_reflux, strt_comp_reflux, num_comp_reflux, RunOn::Device);
736  }
737 
738  // This is necessary here so we don't go on to the next FArrayBox without
739  // having finished copying the fluxes into the FluxRegisters (since the fluxes
740  // are stored in temporary FArrayBox's)
741  Gpu::streamSynchronize();
742 
743  } // two-way coupling
744  } // end profile
745  } // mfi
746  } // OMP
747  if (cloud_budget && l_use_diff && n_qstate > 0) {
748  for (int qstate = 0; qstate < n_qstate; ++qstate) {
749  MultiFab qflux_x(*dflux_x, make_alias, qstate, 1);
750  MultiFab qflux_y(*dflux_y, make_alias, qstate, 1);
751  MultiFab qflux_z(*dflux_z, make_alias, qstate, 1);
752  cloud_budget->capture_stage(
754  nrk, static_cast<Real>(dt_d), qflux_x, qflux_y, qflux_z, geom);
755  }
756  }
757 }
void AdvectionSrcForScalars(const amrex::Box &bx, const int icomp, const int ncomp, const amrex::Array4< const amrex::Real > &avg_xmom, const amrex::Array4< const amrex::Real > &avg_ymom, const amrex::Array4< const amrex::Real > &avg_zmom, const amrex::Array4< const amrex::Real > &cell_prim, const amrex::Array4< amrex::Real > &src, const amrex::Array4< const amrex::Real > &vf_arr, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_mx, const amrex::Array4< const amrex::Real > &mf_my, const AdvType horiz_adv_type, const AdvType vert_adv_type, const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac, const amrex::GpuArray< const amrex::Array4< amrex::Real >, AMREX_SPACEDIM > &flx_arr, const amrex::Box &domain, const amrex::BCRec *bc_ptr_h)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE AdvType EfficientAdvType(int nrk, AdvType adv_type)
Definition: ERF_Advection.H:282
constexpr amrex::Real one
Definition: ERF_Constants.H:9
constexpr amrex::Real zero
Definition: ERF_Constants.H:8
constexpr amrex::Real myhalf
Definition: ERF_Constants.H:13
@ nvars
Definition: ERF_DataStruct.H:152
@ v_x
Definition: ERF_DataStruct.H:27
@ u_y
Definition: ERF_DataStruct.H:28
@ v_y
Definition: ERF_DataStruct.H:28
@ m_y
Definition: ERF_DataStruct.H:28
@ u_x
Definition: ERF_DataStruct.H:27
@ m_x
Definition: ERF_DataStruct.H:27
void DiffusionSrcForState_S(const amrex::Box &bx, const amrex::Box &domain, int start_comp, int num_comp, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &cell_data, const amrex::Array4< const amrex::Real > &cell_prim, const amrex::Array4< amrex::Real > &cell_rhs, const amrex::Array4< amrex::Real > &xflux, const amrex::Array4< amrex::Real > &yflux, const amrex::Array4< amrex::Real > &zflux, const amrex::Gpu::DeviceVector< amrex::Real > &stretched_dz_d, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dxInv, const amrex::Array4< const amrex::Real > &SmnSmn_a, const amrex::Array4< const amrex::Real > &mf_mx, const amrex::Array4< const amrex::Real > &mf_ux, const amrex::Array4< const amrex::Real > &mf_vx, const amrex::Array4< const amrex::Real > &mf_my, const amrex::Array4< const amrex::Real > &mf_uy, const amrex::Array4< const amrex::Real > &mf_vy, amrex::Array4< amrex::Real > &hfx_z, amrex::Array4< amrex::Real > &qfx1_z, amrex::Array4< amrex::Real > &qfx2_z, amrex::Array4< amrex::Real > &diss, const amrex::Array4< const amrex::Real > &mu_turb, const SolverChoice &solverChoice, const int level, const amrex::Array4< const amrex::Real > &tm_arr, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > grav_gpu, const amrex::BCRec *bc_ptr, const bool use_SurfLayer, const amrex::Real implicit_fac)
Add state diffusion source terms on a vertically stretched grid.
void DiffusionSrcForState_T(const amrex::Box &bx, const amrex::Box &domain, int start_comp, int num_comp, const bool &rotate, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &cell_data, const amrex::Array4< const amrex::Real > &cell_prim, const amrex::Array4< amrex::Real > &cell_rhs, const amrex::Array4< amrex::Real > &xflux, const amrex::Array4< amrex::Real > &yflux, const amrex::Array4< amrex::Real > &zflux, const amrex::Array4< const amrex::Real > &z_nd, const amrex::Array4< const amrex::Real > &z_cc, const amrex::Array4< const amrex::Real > &ax, const amrex::Array4< const amrex::Real > &ay, const amrex::Array4< const amrex::Real > &az, const amrex::Array4< const amrex::Real > &detJ, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &dxInv, const amrex::Array4< const amrex::Real > &SmnSmn_a, const amrex::Array4< const amrex::Real > &mf_mx, const amrex::Array4< const amrex::Real > &mf_ux, const amrex::Array4< const amrex::Real > &mf_vx, const amrex::Array4< const amrex::Real > &mf_my, const amrex::Array4< const amrex::Real > &mf_uy, const amrex::Array4< const amrex::Real > &mf_vy, amrex::Array4< amrex::Real > &hfx_x, amrex::Array4< amrex::Real > &hfx_y, amrex::Array4< amrex::Real > &hfx_z, amrex::Array4< amrex::Real > &qfx1_x, amrex::Array4< amrex::Real > &qfx1_y, amrex::Array4< amrex::Real > &qfx1_z, amrex::Array4< amrex::Real > &qfx2_z, amrex::Array4< amrex::Real > &diss, const amrex::Array4< const amrex::Real > &mu_turb, const SolverChoice &solverChoice, const int level, const amrex::Array4< const amrex::Real > &tm_arr, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > grav_gpu, const amrex::BCRec *bc_ptr, const bool use_SurfLayer, const amrex::Real implicit_fac)
Add state diffusion source terms on terrain-following coordinates.
void DiffusionSrcForState_N(const amrex::Box &bx, const amrex::Box &domain, int start_comp, int num_comp, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &cell_data, const amrex::Array4< const amrex::Real > &cell_prim, const amrex::Array4< amrex::Real > &cell_rhs, const amrex::Array4< amrex::Real > &xflux, const amrex::Array4< amrex::Real > &yflux, const amrex::Array4< amrex::Real > &zflux, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &SmnSmn_a, const amrex::Array4< const amrex::Real > &mf_mx, const amrex::Array4< const amrex::Real > &mf_ux, const amrex::Array4< const amrex::Real > &mf_vx, const amrex::Array4< const amrex::Real > &mf_my, const amrex::Array4< const amrex::Real > &mf_uy, const amrex::Array4< const amrex::Real > &mf_vy, amrex::Array4< amrex::Real > &hfx_z, amrex::Array4< amrex::Real > &qfx1_z, amrex::Array4< amrex::Real > &qfx2_z, amrex::Array4< amrex::Real > &diss, const amrex::Array4< const amrex::Real > &mu_turb, const SolverChoice &solverChoice, const int level, const amrex::Array4< const amrex::Real > &tm_arr, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > grav_gpu, const amrex::BCRec *bc_ptr, const bool use_SurfLayer, const amrex::Real implicit_fac)
Add state diffusion source terms on a uniform grid without terrain.
void DiffusionSrcForState_EB(const amrex::Box &bx, const amrex::Box &domain, int start_comp, int num_comp, const amrex::Array4< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &cell_data, const amrex::Array4< const amrex::Real > &cell_prim, const amrex::Array4< amrex::Real > &cell_rhs, const amrex::Array4< amrex::Real > &xflux, const amrex::Array4< amrex::Real > &yflux, const amrex::Array4< amrex::Real > &zflux, const amrex::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 > &detJ, const amrex::Array4< const amrex::Real > &barea_arr, const amrex::Array4< const amrex::Real > &bcent_arr, const amrex::Real *dx_arr, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, amrex::Array4< amrex::Real > &hfx_z, amrex::Array4< amrex::Real > &qfx1_z, amrex::Array4< amrex::Real > &qfx2_z, amrex::Array4< amrex::Real > &hfx_EB, const amrex::Array4< const amrex::Real > &mu_turb, const SolverChoice &solverChoice, const int level, const amrex::BCRec *bc_ptr, const bool use_SurfLayer)
Add state diffusion source terms for embedded-boundary cells.
void EBAdvectionSrcForScalars(const amrex::Box &bx, const int icomp, const int ncomp, const amrex::Array4< const amrex::Real > &avg_xmom, const amrex::Array4< const amrex::Real > &avg_ymom, const amrex::Array4< const amrex::Real > &avg_zmom, const amrex::Array4< const amrex::Real > &cell_prim, const amrex::Array4< amrex::Real > &src, const amrex::Array4< const int > &mask_arr, const amrex::Array4< const amrex::EBCellFlag > &cfg_arr, const amrex::Array4< const amrex::Real > &ax_arr, const amrex::Array4< const amrex::Real > &ay_arr, const amrex::Array4< const amrex::Real > &az_arr, const amrex::Array4< const amrex::Real > &fcx_arr, const amrex::Array4< const amrex::Real > &fcy_arr, const amrex::Array4< const amrex::Real > &fcz_arr, const amrex::Array4< const amrex::Real > &vf_arr, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &mf_mx, const amrex::Array4< const amrex::Real > &mf_my, const AdvType horiz_adv_type, const AdvType vert_adv_type, const amrex::Real horiz_upw_frac, const amrex::Real vert_upw_frac, const amrex::GpuArray< const amrex::Array4< amrex::Real >, AMREX_SPACEDIM > &flx_arr, const amrex::Box &domain, const amrex::BCRec *bc_ptr_h, bool already_on_centroids)
Compute EB advection tendency for scalars other than density.
const Real l_vert_implicit_fac
Definition: ERF_ImplicitPost.H:6
#define RhoScalar_comp
Definition: ERF_IndexDefines.H:40
#define Rho_comp
Definition: ERF_IndexDefines.H:36
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:37
#define NSCALARS
Definition: ERF_IndexDefines.H:16
#define RhoQ1_comp
Definition: ERF_IndexDefines.H:42
AdvType
Definition: ERF_IndexDefines.H:261
#define RhoKE_comp
Definition: ERF_IndexDefines.H:38
amrex::GpuArray< Real, AMREX_SPACEDIM > dxInv
Definition: ERF_InitCustomPertVels_ParticleTests.H:17
const Real dx
Definition: ERF_InitCustomPert_ABL.H:23
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(m_cloud_chamber_config.active, "Cloud Chamber: initializer reached without a parsed configuration")
ParallelFor(fab_box, [=] AMREX_GPU_DEVICE(int i, int j, int k) { qrcuten_arr(i, j, k)=Real(0);qscuten_arr(i, j, k)=Real(0);qicuten_arr(i, j, k)=Real(0);})
amrex::Real Real
Definition: ERF_ShocInterface.H:19
void capture_stage(int scalar, int nrk, amrex::Real dt, const amrex::MultiFab &xflux, const amrex::MultiFab &yflux, const amrex::MultiFab &zflux, const amrex::Geometry &geom, int flux_comp=0)
Definition: ERF_CloudChamberBudget.H:56
@ RhoQv
Definition: ERF_CloudChamberBudget.H:30
@ RhoQc
Definition: ERF_CloudChamberBudget.H:30
bool uses_host_diffusion() const
Definition: ERF_ShocDriver.cpp:930
@ ymom
Definition: ERF_IndexDefines.H:196
@ cons
Definition: ERF_IndexDefines.H:194
@ zmom
Definition: ERF_IndexDefines.H:197
@ xmom
Definition: ERF_IndexDefines.H:195
@ ng
Definition: ERF_Morrison.H:49
@ xvel
Definition: ERF_IndexDefines.H:177
@ yvel
Definition: ERF_IndexDefines.H:178
void apply(const amrex::Box &bx, const amrex::Box &domain, const int quantity, const int flux_comp, const amrex::Array4< const amrex::Real > &state, const amrex::Array4< const amrex::Real > &prim, const amrex::Array4< const amrex::Real > &base_state, const amrex::Array4< amrex::Real > &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 > &dx_inv, const erf_wall_thermodynamics::Boundary &walls, const amrex::Real alpha_T, const amrex::Real alpha_C, const amrex::Real rdOcp)
Definition: ERF_ResolvedWallFlux.H:112
amrex::GpuArray< Face, 2 *AMREX_SPACEDIM > Boundary
Definition: ERF_WallThermodynamics.H:34
real(c_double), parameter epsilon
Definition: ERF_module_model_constants.F90:12
real(c_double), private ac
Definition: ERF_module_mp_morr_two_moment.F90:181
Definition: ERF_AdvStruct.H:19
Definition: ERF_DiffStruct.H:22
MolecDiffType molec_diff_type
Selected molecular transport model.
Definition: ERF_DiffStruct.H:94
amrex::Real alpha_C
Kinematic scalar diffusivity [m2/s].
Definition: ERF_DiffStruct.H:98
amrex::Real alpha_T
Kinematic temperature diffusivity [m2/s].
Definition: ERF_DiffStruct.H:97
amrex::Vector< TurbChoice > turbChoice
Turbulence options for each AMR level.
Definition: ERF_DataStruct.H:1393
amrex::Real gravity
Effective gravitational acceleration.
Definition: ERF_DataStruct.H:1475
bool implicit_moisture_diffusion
Whether implicit vertical moisture diffusion is included.
Definition: ERF_DataStruct.H:1420
MoistureType moisture_type
Moisture or microphysics model.
Definition: ERF_DataStruct.H:1604
CouplingType coupling_type
Multilevel coupling strategy.
Definition: ERF_DataStruct.H:1603
bool use_rotate_surface_flux
Whether MOST surface fluxes are rotated with terrain.
Definition: ERF_DataStruct.H:1505
bool implicit_ke_diffusion
Whether implicit vertical TKE diffusion is included.
Definition: ERF_DataStruct.H:1421
amrex::Real rdOcp
Ratio of dry-air gas constant to c_p.
Definition: ERF_DataStruct.H:1477
static MeshType mesh_type
Vertical mesh representation.
Definition: ERF_DataStruct.H:1377
AdvChoice advChoice
Advection-related options.
Definition: ERF_DataStruct.H:1389
amrex::Vector< int > anelastic
Per-level flag selecting anelastic dynamics.
Definition: ERF_DataStruct.H:1399
amrex::Vector< amrex::Vector< amrex::Real > > vert_implicit_fac
Per-level, per-stage implicit vertical diffusion factors.
Definition: ERF_DataStruct.H:1416
bool transport_scalar
Whether the passive scalar component is transported.
Definition: ERF_DataStruct.H:1512
static TerrainType terrain_type
Terrain or immersed-boundary representation.
Definition: ERF_DataStruct.H:1368
DiffChoice diffChoice
Diffusion-related options.
Definition: ERF_DataStruct.H:1390
Definition: ERF_TurbStruct.H:114
bool advect_tke
Whether TKE/QKE is advected.
Definition: ERF_TurbStruct.H:729
bool use_tke
Whether any TKE or QKE closure is active.
Definition: ERF_TurbStruct.H:666
RANSType rans_type
Selected RANS closure.
Definition: ERF_TurbStruct.H:599
bool uses_eamxx_shoc() const noexcept
Query whether this level uses the EAMxx SHOC PBL scheme.
Definition: ERF_TurbStruct.H:610
bool uses_native_shoc() const noexcept
Query whether this level uses the native SHOC PBL scheme.
Definition: ERF_TurbStruct.H:619
LESType les_type
Selected LES closure.
Definition: ERF_TurbStruct.H:557
bool use_kturb
Whether any turbulence model is active.
Definition: ERF_TurbStruct.H:660
PBLType pbl_type
Selected PBL closure.
Definition: ERF_TurbStruct.H:604
erf_wall_thermodynamics::Boundary wall_boundary() const noexcept
Definition: ERF_CloudChamber.H:52
bool physical_initialization
Definition: ERF_CloudChamber.H:38
Here is the call graph for this function: