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