ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_SlowRhsPost.cpp File Reference
Include dependency graph for ERF_SlowRhsPost.cpp:

Functions

void erf_slow_rhs_post (int level, int finest_level, int nrk, double step_old_time, double input_time, double target_time, 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 Array< const MultiFab *, AMREX_SPACEDIM > &upw_dir, const MultiFab &xvel, const MultiFab &yvel, const MultiFab &zvel, 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, MultiFab *Tau13, MultiFab *Tau23, const Geometry geom, const SolverChoice &solverChoice, const Vector< 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, const iMultiFab &physbnd_mask, 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, erf_auxiliary::AuxiliaryInertTracer *auxiliary_inert_tracer, erf_sbm::SBMStateManager *sbm_state_manager, erf_sbm::SBMTransport *sbm_transport, const MultiFab *ib_wall_face33, const MultiFab *ib_wall_ktarget, const MultiFab *ib_wall_qfx, const erf_sbm::SBMAMRStageParent *sbm_parent_stage)
 

Function Documentation

◆ erf_slow_rhs_post()

void erf_slow_rhs_post ( int  level,
int  finest_level,
int  nrk,
double  step_old_time,
double  input_time,
double  target_time,
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 Array< const MultiFab *, AMREX_SPACEDIM > &  upw_dir,
const MultiFab &  xvel,
const MultiFab &  yvel,
const MultiFab &  zvel,
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,
MultiFab *  Tau13,
MultiFab *  Tau23,
const Geometry  geom,
const SolverChoice &  solverChoice,
const Vector< 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,
const iMultiFab &  physbnd_mask,
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,
erf_auxiliary::AuxiliaryInertTracer *  auxiliary_inert_tracer,
erf_sbm::SBMStateManager *  sbm_state_manager,
erf_sbm::SBMTransport *  sbm_transport,
const MultiFab *  ib_wall_face33,
const MultiFab *  ib_wall_ktarget,
const MultiFab *  ib_wall_qfx,
const erf_sbm::SBMAMRStageParent *  sbm_parent_stage 
)

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]upw_dirupwind direction used by erf_slow_rhs_pre in this stage, on a pseudo-incompressible level (nullptr otherwise: the mass flux picks it)
[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]Tau13rho<u'w'>, carrying the surface-layer stress on the zlo face
[in]Tau23rho<v'w'>, carrying the surface-layer stress on the zlo face
[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]physbnd_maskEB only: mask of the physical-boundary ghost cells of the cell-centered variables
[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
146 {
147  BL_PROFILE_REGION("erf_slow_rhs_post()");
148 
149  Real dt = static_cast<Real>(dt_d);
150 
151  const bool sbm_active = solverChoice.moisture_type == MoistureType::SBM;
152 
153  const BCRec* bc_ptr_d = domain_bcs_type_d.data();
154  const BCRec* bc_ptr_h = domain_bcs_type_h.data();
155 
156  AdvChoice ac = solverChoice.advChoice;
157  DiffChoice dc = solverChoice.diffChoice;
158  TurbChoice tc = solverChoice.turbChoice[level];
159 
160  const MultiFab* t_mean_mf = nullptr;
161  if (SurfLayer[Orientation(Direction::z, Orientation::low)]) { t_mean_mf = SurfLayer[Orientation(Direction::z, Orientation::low)]->get_mac_avg(level,3); }
162 
163  const bool l_use_terrain = (solverChoice.mesh_type != MeshType::ConstantDz);
164  const bool l_moving_terrain = (solverChoice.terrain_type == TerrainType::MovingFittedMesh);
165  if (l_moving_terrain) AMREX_ALWAYS_ASSERT(l_use_terrain);
166 
167  const bool l_anelastic = solverChoice.compressibility_type[level] != CompressibilityType::FullyCompressible;
168  const bool l_anelastic_rk2 = (solverChoice.timestepping_type[level] == TimesteppingType::RK2);
169 
170  // Add to the flux registers only in the stages whose fluxes the step's update applies,
171  // weighted as in that update (RefluxStageWeight)
172  const bool l_reflux = IsRefluxStage(solverChoice, level, finest_level, nrk);
173  const Real l_reflux_dt = RefluxStageWeight(solverChoice, level, finest_level, nrk) * dt;
174 
175  const bool l_use_KE = ( tc.use_tke );
176  const bool l_need_SmnSmn = ( tc.les_type == LESType::Deardorff ||
177  tc.rans_type == RANSType::kEqn );
178  // k-eqn RANS with a Dirichlet wall value: SurfaceLayer::update_fluxes
179  // writes AL01 Eq. 16 into the first cell of S_old at the start of the
180  // step; keep that value through every RK stage.
181  const bool l_dirichlet_k = ( tc.rans_type == RANSType::kEqn && tc.dirichlet_k &&
182  (SurfLayer[Orientation(Direction::z, Orientation::low)] != nullptr) );
183  // Implicit TKE dissipation: eps = c * (rho k)_new with c = diss_old / (rho k)_old,
184  // i.e. Cmu0^3 sqrt(k_old) / L; the source skips the explicit sink and the
185  // update divides by (1 + dt c).
186  const bool l_implicit_diss = ( tc.use_keqn && tc.implicit_tke_dissipation );
187  const bool l_advect_KE = ( tc.use_tke && tc.advect_tke );
188  const bool l_use_diff = ((dc.molec_diff_type != MolecDiffType::None) ||
189  (tc.les_type != LESType::None) ||
190  (tc.rans_type != RANSType::None) ||
191  (tc.pbl_type != PBLType::None) );
192  const bool l_use_turb = tc.use_kturb;
193  const bool l_rotate = (solverChoice.use_rotate_surface_flux);
194  const bool l_do_scalar = (solverChoice.transport_scalar);
195  const bool l_use_eb = (solverChoice.terrain_type == TerrainType::EB);
196 
197  auto any_SurfLayer = [&SurfLayer_ = SurfLayer]() -> bool {
198  for (auto it = SurfLayer_.begin(); it != SurfLayer_.end(); it++)
199  {
200  if (*it != nullptr) { return true; }
201  }
202  return false;
203  };
204 
205  amrex::ignore_unused(m_r2d);
206 
207  const Box& domain = geom.Domain();
208 
209  bool l_apply_surface_layer_fluxes_in_diffusion = any_SurfLayer();
210  if (tc.uses_native_shoc()) {
211  AMREX_ALWAYS_ASSERT(native_shoc_lev != nullptr);
212  l_apply_surface_layer_fluxes_in_diffusion = false;
213  }
214 
215  const GpuArray<Real, AMREX_SPACEDIM> dxInv = geom.InvCellSizeArray();
216  const Real* dx = geom.CellSize();
217 
218  // *************************************************************************
219  // Set gravity as a vector
220  // *************************************************************************
221  const Array<Real,AMREX_SPACEDIM> grav{zero, zero, -solverChoice.gravity};
222  const GpuArray<Real,AMREX_SPACEDIM> grav_gpu{grav[0], grav[1], grav[2]};
223 
224  // *************************************************************************
225  // Pre-computed quantities
226  // *************************************************************************
227  int nvars = S_data[IntVars::cons].nComp();
228 
229  // The Q layout includes particle projections; only host-owned runs are transported.
230  const int n_qstate_total = nvars - RhoQ1_comp;
231 
232  const BoxArray& ba = S_data[IntVars::cons].boxArray();
233  const DistributionMapping& dm = S_data[IntVars::cons].DistributionMap();
234  const bool use_physical_chamber_wall_flux =
235  cloud_chamber_config != nullptr && cloud_chamber_base_state != nullptr &&
236  cloud_chamber_config->physical_initialization;
237  const erf_wall_thermodynamics::Boundary chamber_walls =
238  use_physical_chamber_wall_flux ? cloud_chamber_config->transport_boundary() :
240  const auto chamber_bands = use_physical_chamber_wall_flux ? cloud_chamber_config->temperature_band_views() :
242 
243  std::unique_ptr<MultiFab> dflux_x;
244  std::unique_ptr<MultiFab> dflux_y;
245  std::unique_ptr<MultiFab> dflux_z;
246 
247  if (l_use_diff) {
248  IntVect ng(0,0,1);
249  // The physical chamber needs one persistent component for each moist
250  // state even when budgets are disabled: qv and qc are corrected and
251  // retained independently. All other configurations retain ERF's
252  // established one-component reusable diffusion storage.
253  const int n_flux_components = use_physical_chamber_wall_flux ?
254  std::max(1, n_qstate_total) : 1;
255  dflux_x = std::make_unique<MultiFab>(convert(ba,IntVect(1,0,0)), dm, n_flux_components, ng);
256  dflux_y = std::make_unique<MultiFab>(convert(ba,IntVect(0,1,0)), dm, n_flux_components, ng);
257  dflux_z = std::make_unique<MultiFab>(convert(ba,IntVect(0,0,1)), dm, n_flux_components, 0);
258  // Every physical wall override reads the old face flux before
259  // replacing it; make that read deterministic regardless of budget
260  // diagnostics.
261  if (use_physical_chamber_wall_flux) {
262  dflux_x->setVal(0.0);
263  dflux_y->setVal(0.0);
264  dflux_z->setVal(0.0);
265  }
266  } else {
267  dflux_x = nullptr;
268  dflux_y = nullptr;
269  dflux_z = nullptr;
270  }
271 
272  // Valid vars
273  Vector<int> is_valid_slow_var; is_valid_slow_var.resize(RhoQ1_comp+1,0);
274  if (l_use_KE) { is_valid_slow_var[ RhoKE_comp] = 1; }
275  if (l_do_scalar) { is_valid_slow_var[RhoScalar_comp] = 1; }
276  if (solverChoice.moisture_type != MoistureType::None) {
277  is_valid_slow_var[RhoQ1_comp] = 1;
278  }
279 
280  // *************************************************************************
281  // Calculate cell-centered eddy viscosity & diffusivities
282  //
283  // Notes -- we fill all the data in ghost cells before calling this so
284  // that we can fill the eddy viscosity in the ghost regions and
285  // not have to call a boundary filler on this data itself
286  //
287  // LES - updates both horizontal and vertical eddy viscosityS_tmp components
288  // PBL - only updates vertical eddy viscosity components so horizontal
289  // components come from the LES model or are left as zero.
290  // *************************************************************************
291 
292  // Anelastic and pseudo-incompressible: the slow scalars are advected with the momenta (EB)AdvectionSrcForRho set in
293  // erf_slow_rhs_pre from the start of this stage (ax rho_u / mf_uy, ay rho_v / mf_vx,
294  // az Omega / (mf_mx mf_my); with EB the area fractions are applied to the fluxes instead),
295  // the same faces that advect theta. These momenta are already projected, by the previous
296  // stage or step.
297 
298  // M2 proof consumer: run after the stage carrier is final and before the
299  // caller copies S_data over S_new, preserving the predictor density view.
300  if (auxiliary_inert_tracer != nullptr) {
301  const auto method = auxiliary_host_integrator(solverChoice, level);
302  auxiliary_inert_tracer->advance_stage(
303  level, method, nrk, step_old_time, input_time, target_time, dt_d,
304  S_old[IntVars::cons], S_new[IntVars::cons], S_data[IntVars::cons],
305  avg_xmom, avg_ymom, avg_zmom, solverChoice.advChoice, geom);
306  }
307 
308  // M3 advances the authoritative spectrum after the host carrier has been
309  // finalized and before the caller commits this stage's S_data into S_new.
310  // The compact qc/qr lanes are refreshed as a projection of the accepted
311  // spectrum at the same semantic target time.
312  if (sbm_active) {
313  AMREX_ALWAYS_ASSERT(sbm_state_manager != nullptr && sbm_transport != nullptr);
314  if (solverChoice.sbm_test_donor_cfl_fault) {
315  // Force an outgoing-demand violation at the production donor CFL gate.
316  avg_xmom.setVal(Real(1.0e8));
317  }
318  const auto method = auxiliary_host_integrator(solverChoice, level);
319  const MultiFab& stage_cons_anchor = S_old[IntVars::cons];
320  const MultiFab& stage_cons_input = S_new[IntVars::cons];
321  MultiFab& stage_cons_target = S_data[IntVars::cons];
322  erf_sbm::SBMStageMixingInputs sbm_mixing_inputs;
323  const erf_sbm::SBMStageMixingInputs* sbm_mixing = nullptr;
324  if (sbm_transport->mixes_particles()) {
325  sbm_mixing_inputs = erf_sbm::make_stage_mixing_inputs(
326  *sbm_transport, eddyDiffs, mapfac, ax.get(), ay.get(),
327  stretched_dz_d.data(), z_phys_nd.get(), z_phys_cc.get());
328  sbm_mixing = &sbm_mixing_inputs;
329  }
330  sbm_transport->advance_stage_from_host(
331  level, method, nrk, step_old_time, input_time, target_time, dt_d,
332  *sbm_state_manager, stage_cons_anchor, stage_cons_input,
333  stage_cons_target, avg_xmom, avg_ymom, avg_zmom, geom,
334  solverChoice.moisture_indices.qc, solverChoice.moisture_indices.qr,
335  sbm_parent_stage, sbm_mixing);
336  }
337 
338  // *************************************************************************
339  // Define updates and fluxes in the current RK stage
340  // *************************************************************************
341 #ifdef _OPENMP
342 #pragma omp parallel if (Gpu::notInLaunchRegion())
343 #endif
344  {
345  std::array<FArrayBox,AMREX_SPACEDIM> flux;
346 
347  int start_comp;
348  int num_comp;
349 
350  bool already_on_centroids = false;
351 
352  // NOTE: this loop must NOT be tiled. It both reads and writes S_new[cons]:
353  // - the diffusion and PBL source routines below read new_cons with stencils
354  // that reach outside the box they are given (AddTurbKESources, for instance,
355  // forms a vertical theta_v gradient from k-1 and k+1);
356  // - "rhs_post_9" near the end of the loop writes new_cons = cur_cons over tbx.
357  //
358  // The better fix is to split this into two passes -- all the reads, then all the
359  // writes -- which would let tiling come back. Until then, do not restore
360  // TilingIfNotGPU() here without also moving the new_cons writes out.
361  for (MFIter mfi(S_data[IntVars::cons],false); mfi.isValid(); ++mfi)
362  {
363  Box tbx = mfi.tilebox();
364 
365  // *************************************************************************
366  // Define flux arrays for use in advection
367  // *************************************************************************
368  for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
369  if (!l_use_eb) {
370  flux[dir].resize(surroundingNodes(tbx,dir),nvars,The_Async_Arena());
371  } else {
372  flux[dir].resize(surroundingNodes(tbx,dir).grow(1),nvars,The_Async_Arena());
373  }
374  flux[dir].setVal<RunOn::Device>(0);
375  }
376  const GpuArray<const Array4<Real>, AMREX_SPACEDIM>
377  flx_arr{{AMREX_D_DECL(flux[0].array(), flux[1].array(), flux[2].array())}};
378 
379  // In the stage whose fluxes are refluxed, the diffusion adds its face fluxes to flux[]
380  // too, so that the flux registers see the diffusive as well as the advective transport
381  // (EB diffusion does not do this). Nothing is counted twice: flux[] holds the faces of
382  // tbx alone and is zeroed above for each box, and the registers take each coarse/fine
383  // face once, from the box holding the cell on its coarse side (CrseAdd) or on its fine
384  // side (FineAdd), tiled or not.
385  const ScalarDiffusionRefluxViews* l_reflux_diffusion = (l_reflux && !l_use_eb) ? &flx_arr : nullptr;
386 
387  // *************************************************************************
388  // Define Array4's
389  // *************************************************************************
390  const Array4<const Real> & old_cons = S_old[IntVars::cons].array(mfi);
391  const Array4< Real> & cell_rhs = S_rhs[IntVars::cons].array(mfi);
392 
393  const Array4< Real> & new_cons = S_new[IntVars::cons].array(mfi);
394  const Array4< Real> & new_xmom = S_new[IntVars::xmom].array(mfi);
395  const Array4< Real> & new_ymom = S_new[IntVars::ymom].array(mfi);
396  const Array4< Real> & new_zmom = S_new[IntVars::zmom].array(mfi);
397 
398  const Array4< Real> & cur_cons = S_data[IntVars::cons].array(mfi);
399  const Array4<const Real> & cur_prim = S_prim.array(mfi);
400  const Array4< Real> & cur_xmom = S_data[IntVars::xmom].array(mfi);
401  const Array4< Real> & cur_ymom = S_data[IntVars::ymom].array(mfi);
402  const Array4< Real> & cur_zmom = S_data[IntVars::zmom].array(mfi);
403 
404  Array4<Real> avg_xmom_arr = avg_xmom.array(mfi);
405  Array4<Real> avg_ymom_arr = avg_ymom.array(mfi);
406  Array4<Real> avg_zmom_arr = avg_zmom.array(mfi);
407  // Pseudo-incompressible: the upwind side is the one the projection picked
408  const Array4<const Real> upw_x_arr = upw_dir[0] ? upw_dir[0]->const_array(mfi) : avg_xmom.const_array(mfi);
409  const Array4<const Real> upw_y_arr = upw_dir[1] ? upw_dir[1]->const_array(mfi) : avg_ymom.const_array(mfi);
410  const Array4<const Real> upw_z_arr = upw_dir[2] ? upw_dir[2]->const_array(mfi) : avg_zmom.const_array(mfi);
411 
412  const Array4<const Real> & u = xvel.array(mfi);
413  const Array4<const Real> & v = yvel.array(mfi);
414  const Array4<const Real> & w = zvel.array(mfi);
415 
416  const Array4<const Real>& z_nd = z_phys_nd->const_array(mfi);
417  const Array4<const Real>& z_cc = z_phys_cc->const_array(mfi);
418  const Array4<const Real>& detJ_new_arr = l_moving_terrain ? detJ_new->const_array(mfi) : Array4<const Real>{};
419 
420  const Array4<const Real>& t_blank_arr = (terrain_blank) ? terrain_blank->const_array(mfi) :
421  Array4<const Real>{};
422  const Array4<const Real>& t_blank_xface_arr = (terrain_blank_xface) ? terrain_blank_xface->const_array(mfi) :
423  Array4<const Real>{};
424  const Array4<const Real>& t_blank_yface_arr = (terrain_blank_yface) ? terrain_blank_yface->const_array(mfi) :
425  Array4<const Real>{};
426  const Array4<const Real>& t_blank_zface_arr = (terrain_blank_zface) ? terrain_blank_zface->const_array(mfi) :
427  Array4<const Real>{};
428 
429  // Map factors
430  const Array4<const Real>& mf_mx = mapfac[MapFacType::m_x]->const_array(mfi);
431  const Array4<const Real>& mf_ux = mapfac[MapFacType::u_x]->const_array(mfi);
432  const Array4<const Real>& mf_vx = mapfac[MapFacType::v_x]->const_array(mfi);
433  const Array4<const Real>& mf_my = mapfac[MapFacType::m_y]->const_array(mfi);
434  const Array4<const Real>& mf_uy = mapfac[MapFacType::u_y]->const_array(mfi);
435  const Array4<const Real>& mf_vy = mapfac[MapFacType::v_y]->const_array(mfi);
436 
437  // SmnSmn for KE src with Deardorff or k-eqn RANS
438  const Array4<const Real>& SmnSmn_a = l_need_SmnSmn ? SmnSmn->const_array(mfi) : Array4<const Real>{};
439 
440  // **************************************************************************
441  // Here we fill the "current" data with "new" data because that is the result of the previous RK stage
442  // **************************************************************************
443  int nsv = S_old[IntVars::cons].nComp() - 2;
444  const GpuArray<int, IntVars::NumTypes> scomp_slow = { 2,0,0,0};
445  const GpuArray<int, IntVars::NumTypes> ncomp_slow = {nsv,0,0,0};
446  const bool copy_sbm_active = sbm_active;
447  const int copy_sbm_qc = solverChoice.moisture_indices.qc;
448  const int copy_sbm_qr = solverChoice.moisture_indices.qr;
449 
450  // **************************************************************************
451  // Note that here we do copy only the "slow" variables, not (rho) or (rho theta)
452  // **************************************************************************
453  ParallelFor(tbx, ncomp_slow[IntVars::cons],
454  [=] AMREX_GPU_DEVICE (int i, int j, int k, int nn) {
455  const int n = scomp_slow[IntVars::cons] + nn;
457  cur_cons, new_cons, i, j, k, n, copy_sbm_active,
458  copy_sbm_qc, copy_sbm_qr);
459  });
460 
461  // **************************************************************************
462  // Define updates in the RHS of continuity, temperature, and scalar equations
463  // **************************************************************************
464  bool l_eb_terrain_cc = false; // EB terrain on cell-centered grid
465  Array4<const int> mask_arr{};
466  Array4<const EBCellFlag> cfg_arr{};
467  Array4<const Real> ax_arr{};
468  Array4<const Real> ay_arr{};
469  Array4<const Real> az_arr{};
470  Array4<const Real> fcx_arr{};
471  Array4<const Real> fcy_arr{};
472  Array4<const Real> fcz_arr{};
473  Array4<const Real> detJ_arr{};
474  Array4<const Real> barea_arr{};
475  Array4<const Real> bcent_arr{};
476 
477  if (l_use_eb) {
478  EBFArrayBoxFactory const& ebfact_cc = *(ebfact.get_const_factory());
479  EBCellFlagFab const& cfg = ebfact_cc.getMultiEBCellFlagFab()[mfi];
480  cfg_arr = cfg.const_array();
481  if (cfg.getType(tbx) == FabType::singlevalued) {
482  l_eb_terrain_cc = true;
483  ax_arr = ebfact_cc.getAreaFrac()[0]->const_array(mfi);
484  ay_arr = ebfact_cc.getAreaFrac()[1]->const_array(mfi);
485  az_arr = ebfact_cc.getAreaFrac()[2]->const_array(mfi);
486  fcx_arr = ebfact_cc.getFaceCent()[0]->const_array(mfi);
487  fcy_arr = ebfact_cc.getFaceCent()[1]->const_array(mfi);
488  fcz_arr = ebfact_cc.getFaceCent()[2]->const_array(mfi);
489  detJ_arr = ebfact_cc.getVolFrac().const_array(mfi);
490  mask_arr = physbnd_mask.const_array(mfi);
491  barea_arr = ebfact_cc.getBndryArea().const_array(mfi);
492  bcent_arr = ebfact_cc.getBndryCent().const_array(mfi);
493  } else {
494  ax_arr = ax->const_array(mfi);
495  ay_arr = ay->const_array(mfi);
496  az_arr = az->const_array(mfi);
497  detJ_arr = detJ->const_array(mfi);
498  }
499  } else {
500  ax_arr = ax->const_array(mfi);
501  ay_arr = ay->const_array(mfi);
502  az_arr = az->const_array(mfi);
503  detJ_arr = detJ->const_array(mfi);
504  }
505 
506  AdvType horiz_adv_type, vert_adv_type;
507  Real horiz_upw_frac, vert_upw_frac;
508 
509  Array4<Real> diffflux_x, diffflux_y, diffflux_z;
510  Array4<Real> hfx_x, hfx_y, hfx_z, diss;
511  Array4<Real> q1fx_x, q1fx_y, q1fx_z, q2fx_z;
512  Array4<Real> hfx_EB{};
513 
514  // The surface-layer stresses on the zlo face, consumed by the MYNN QKE
515  // source at k = klo (see ERF_TurbKESources.H)
516  Array4<const Real> tau13, tau23;
517 
518  if (l_use_diff) {
519  if (Tau13) { tau13 = Tau13->const_array(mfi); }
520  if (Tau23) { tau23 = Tau23->const_array(mfi); }
521  diffflux_x = dflux_x->array(mfi);
522  diffflux_y = dflux_y->array(mfi);
523  diffflux_z = dflux_z->array(mfi);
524 
525  hfx_x = Hfx1->array(mfi);
526  hfx_y = Hfx2->array(mfi);
527  hfx_z = Hfx3->array(mfi);
528  diss = Diss->array(mfi);
529 
530  if (Q1fx1) q1fx_x = Q1fx1->array(mfi);
531  if (Q1fx2) q1fx_y = Q1fx2->array(mfi);
532  if (Q1fx3) q1fx_z = Q1fx3->array(mfi);
533  if (Q2fx3) q2fx_z = Q2fx3->array(mfi);
534  }
535 
536  if (l_use_diff && l_use_turb) {
538  eddyDiffs != nullptr,
539  "erf_slow_rhs_post: active turbulence requires non-null eddyDiffs");
540  }
541  const Array4<const Real>& mu_turb =
542  l_use_turb ? eddyDiffs->const_array(mfi) : Array4<const Real>{};
543 
544  for (int ivar(RhoKE_comp); ivar<= RhoQ1_comp; ++ivar)
545  {
546 
547  if (is_valid_slow_var[ivar])
548  {
549  start_comp = ivar;
550  num_comp = 1;
551 
552  if (ivar == RhoQ1_comp) {
553  horiz_adv_type = ac.moistscal_horiz_adv_type;
554  vert_adv_type = ac.moistscal_vert_adv_type;
555  horiz_upw_frac = ac.moistscal_horiz_upw_frac;
556  vert_upw_frac = ac.moistscal_vert_upw_frac;
557 
558  if (ac.use_efficient_advection){
559  horiz_adv_type = EfficientAdvType(nrk,ac.moistscal_horiz_adv_type);
560  vert_adv_type = EfficientAdvType(nrk,ac.moistscal_vert_adv_type);
561  }
562 
563  num_comp = n_qstate_total;
564  if (sbm_active) {
565  // Keep vapor on the normal path. The test fault widens
566  // the actual range so the ownership guard is exercised
567  // before native advection can write projected liquid.
568  num_comp = solverChoice.sbm_test_native_qc_write_fault ? 2 : 1;
569  }
570 
571  } else {
572  horiz_adv_type = ac.dryscal_horiz_adv_type;
573  vert_adv_type = ac.dryscal_vert_adv_type;
574  horiz_upw_frac = ac.dryscal_horiz_upw_frac;
575  vert_upw_frac = ac.dryscal_vert_upw_frac;
576 
577  if (ac.use_efficient_advection){
578  horiz_adv_type = EfficientAdvType(nrk,ac.dryscal_horiz_adv_type);
579  vert_adv_type = EfficientAdvType(nrk,ac.dryscal_vert_adv_type);
580  }
581 
582  if (ivar == RhoScalar_comp) {
583  num_comp = NSCALARS;
584  }
585  }
586 
587  const int group_end = start_comp + num_comp;
588  for (int run_start = start_comp; run_start < group_end; ) {
589  if (!dc.host_transports(run_start)) {
590  const int diagnostic_comp = run_start;
591  ParallelFor(tbx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
592  cell_rhs(i,j,k,diagnostic_comp) = zero;
593  });
594  ++run_start;
595  continue;
596  }
597  start_comp = run_start;
598  num_comp = 1;
599  while (start_comp + num_comp < group_end &&
600  dc.host_transports(start_comp + num_comp)) {
601  ++num_comp;
602  }
603  run_start += num_comp;
604 
605  if (( ivar != RhoKE_comp ) ||
606  ((ivar == RhoKE_comp) && l_advect_KE))
607  {
608  if (!l_eb_terrain_cc){
609  if (sbm_active && ivar == RhoQ1_comp) {
611  true, start_comp, num_comp, erf_sbm::HostWritePath::Advection);
612  }
613  AdvectionSrcForScalars(tbx, start_comp, num_comp,
614  avg_xmom_arr, avg_ymom_arr, avg_zmom_arr,
615  upw_x_arr, upw_y_arr, upw_z_arr,
616  cur_prim, cell_rhs,
617  detJ_arr, dxInv, mf_mx, mf_my,
618  horiz_adv_type, vert_adv_type,
619  horiz_upw_frac, vert_upw_frac,
620  flx_arr, domain, bc_ptr_h);
621  } else {
622  if (sbm_active && ivar == RhoQ1_comp) {
624  true, start_comp, num_comp, erf_sbm::HostWritePath::Advection);
625  }
626  EBAdvectionSrcForScalars(tbx, start_comp, num_comp,
627  avg_xmom_arr, avg_ymom_arr, avg_zmom_arr,
628  cur_prim, cell_rhs,
629  mask_arr, cfg_arr, ax_arr, ay_arr, az_arr,
630  fcx_arr, fcy_arr, fcz_arr,
631  detJ_arr, dxInv, mf_mx, mf_my,
632  horiz_adv_type, vert_adv_type,
633  horiz_upw_frac, vert_upw_frac,
634  flx_arr, domain, bc_ptr_h,
635  already_on_centroids);
636  }
637  }
638 
639  if (l_use_diff)
640  {
641  // Allow for implicit moisture diffusion
642  Real l_vert_implicit_fac = zero;
643  if ( (ivar == RhoKE_comp && solverChoice.implicit_ke_diffusion ) ||
644  (ivar == RhoQ1_comp && solverChoice.implicit_moisture_diffusion) ) {
645  l_vert_implicit_fac = solverChoice.vert_implicit_fac[level][nrk];
646  }
647 
648  // Only the physical chamber needs separate qv/qc calls:
649  // its wall correction must be applied to distinct flux
650  // components. Generic moisture models retain the
651  // established multi-component diffusion call.
652  const bool componentwise_moisture =
653  use_physical_chamber_wall_flux && ivar == RhoQ1_comp;
654  const int n_diff_calls = componentwise_moisture ? n_qstate_total : 1;
655  for (int qstate = 0; qstate < n_diff_calls; ++qstate) {
656  const int state_comp = componentwise_moisture ?
657  RhoQ1_comp + qstate : start_comp;
658  const int diffusion_start = state_comp;
659  const int diffusion_num = componentwise_moisture ? 1 : num_comp;
661  sbm_active, diffusion_start, diffusion_num,
663  const int flux_comp = componentwise_moisture ? qstate : 0;
664  AMREX_ALWAYS_ASSERT(state_comp >= 0 && state_comp < nvars);
665  AMREX_ALWAYS_ASSERT(flux_comp < dflux_x->nComp());
666  AMREX_ALWAYS_ASSERT(flux_comp < dflux_y->nComp());
667  AMREX_ALWAYS_ASSERT(flux_comp < dflux_z->nComp());
668  const Array4<Real> diffusion_x = dflux_x->array(mfi, flux_comp);
669  const Array4<Real> diffusion_y = dflux_y->array(mfi, flux_comp);
670  const Array4<Real> diffusion_z = dflux_z->array(mfi, flux_comp);
671 
672  if (solverChoice.mesh_type == MeshType::StretchedDz) {
673  DiffusionSrcForState_S(tbx, domain, diffusion_start, diffusion_num, u, v,
674  new_cons, cur_prim, cell_rhs,
675  diffusion_x, diffusion_y, diffusion_z,
676  stretched_dz_d, dxInv,
677  mf_mx, mf_ux, mf_vx,
678  mf_my, mf_uy, mf_vy,
679  hfx_x, hfx_y, hfx_z, q1fx_x, q1fx_y, q1fx_z,q2fx_z,
680  mu_turb, solverChoice, level,
681  bc_ptr_d,
682  l_apply_surface_layer_fluxes_in_diffusion, SurfLayer, l_vert_implicit_fac,
683  l_reflux_diffusion);
684  } else if (l_use_terrain) {
685  DiffusionSrcForState_T(tbx, domain, diffusion_start, diffusion_num, l_rotate, u, v,
686  new_cons, cur_prim, cell_rhs,
687  diffusion_x, diffusion_y, diffusion_z,
688  z_nd, z_cc, ax_arr, ay_arr, az_arr,
689  detJ_arr, dxInv,
690  mf_mx, mf_ux, mf_vx,
691  mf_my, mf_uy, mf_vy,
692  hfx_x, hfx_y, hfx_z, q1fx_x, q1fx_y, q1fx_z,q2fx_z,
693  mu_turb, solverChoice, level,
694  bc_ptr_d, bc_ptr_h,
695  l_apply_surface_layer_fluxes_in_diffusion, SurfLayer, l_vert_implicit_fac,
696  l_reflux_diffusion);
697  } else if (l_use_eb) {
698  DiffusionSrcForState_EB(tbx, domain, diffusion_start, diffusion_num, u, v,
699  new_cons, cur_prim, cell_rhs,
700  diffusion_x, diffusion_y, diffusion_z,
701  cfg_arr, ax_arr, ay_arr, az_arr, detJ_arr,
702  barea_arr, bcent_arr,
703  dx, dxInv,
704  hfx_z, q1fx_z, q2fx_z, hfx_EB,
705  mu_turb, solverChoice, level,
706  bc_ptr_d, l_apply_surface_layer_fluxes_in_diffusion, SurfLayer);
707  } else {
708  DiffusionSrcForState_N(tbx, domain, diffusion_start, diffusion_num, u, v,
709  new_cons, cur_prim, cell_rhs,
710  diffusion_x, diffusion_y, diffusion_z, dxInv,
711  mf_mx, mf_ux, mf_vx,
712  mf_my, mf_uy, mf_vy,
713  hfx_x, hfx_y, hfx_z, q1fx_x, q1fx_y, q1fx_z, q2fx_z,
714  mu_turb, solverChoice, level,
715  bc_ptr_d,
716  l_apply_surface_layer_fluxes_in_diffusion, SurfLayer, l_vert_implicit_fac,
717  l_reflux_diffusion,
718  (ib_wall_face33) ? ib_wall_face33->const_array(mfi) : Array4<const Real>{},
719  Array4<const Real>{},
720  (ib_wall_qfx) ? ib_wall_qfx->const_array(mfi) : Array4<const Real>{});
721  }
722  if (use_physical_chamber_wall_flux) {
723  // Apply the physical wall correction immediately to
724  // the flux component just computed. This keeps the
725  // q-state diffusion path identical with budgets on
726  // and off and guarantees no stale flux is consumed.
727  // The diffusion views are component-shifted; the
728  // wall helper receives the unshifted views and the
729  // explicit flux component index.
731  tbx, domain, state_comp, flux_comp, new_cons, cur_prim,
732  cloud_chamber_base_state->const_array(mfi), u, v, w, cell_rhs,
733  diffflux_x, diffflux_y, diffflux_z, dxInv,
734  chamber_walls, dc.alpha_T, dc.alpha_C,
735  solverChoice.rdOcp, cloud_chamber_config->has_moisture, chamber_bands);
736  }
737  }
738  } // use_diff
739  } // host-transported run
740  } // valid slow var
741  } // loop ivar
742 
743  // **************************************************************************
744  // TKE / QKE production and dissipation. These consume the face fluxes of
745  // this stage's scalar diffusion (theta in erf_slow_rhs_pre, qv above), so
746  // they are added only once every scalar has been diffused.
747  // **************************************************************************
748  if (l_use_diff && is_valid_slow_var[RhoKE_comp])
749  {
750  const Array4<const Real> tm_arr = t_mean_mf ? t_mean_mf->const_array(mfi) : Array4<const Real>{};
751 
752  if (solverChoice.mesh_type == MeshType::StretchedDz) {
753  const PBLDerivativeDzInv_S pbl_dz_inv{stretched_dz_d.data(),
754  domain.smallEnd(2), domain.bigEnd(2)};
755  AddTurbKESources(tbx, domain, u, v, new_cons, cur_prim, cell_rhs,
756  SmnSmn_a, hfx_z, q1fx_z, diss, tau13, tau23, mu_turb,
757  solverChoice, level, tm_arr, grav_gpu, bc_ptr_d,
758  l_apply_surface_layer_fluxes_in_diffusion, SurfLayer, pbl_dz_inv);
759  } else if (l_use_terrain) {
760  const PBLDerivativeDzInv_T pbl_dz_inv{z_cc};
761  AddTurbKESources(tbx, domain, u, v, new_cons, cur_prim, cell_rhs,
762  SmnSmn_a, hfx_z, q1fx_z, diss, tau13, tau23, mu_turb,
763  solverChoice, level, tm_arr, grav_gpu, bc_ptr_d,
764  l_apply_surface_layer_fluxes_in_diffusion, SurfLayer, pbl_dz_inv);
765  } else if (!l_use_eb) {
766  const PBLDerivativeDzInv_N pbl_dz_inv{dxInv[2]};
767  AddTurbKESources(tbx, domain, u, v, new_cons, cur_prim, cell_rhs,
768  SmnSmn_a, hfx_z, q1fx_z, diss, tau13, tau23, mu_turb,
769  solverChoice, level, tm_arr, grav_gpu, bc_ptr_d,
770  l_apply_surface_layer_fluxes_in_diffusion, SurfLayer, pbl_dz_inv);
771  }
772  }
773 
774  // This updates just the "slow" conserved variables
775  {
776  BL_PROFILE("rhs_post_8");
777 
779 
780  auto const& src_arr = source.const_array(mfi);
781 
782  for (int ivar(RhoKE_comp); ivar<= RhoQ1_comp; ++ivar)
783  {
784  if (is_valid_slow_var[ivar])
785  {
786  start_comp = ivar;
787  num_comp = 1;
788  if (ivar == RhoQ1_comp) {
789  num_comp = n_qstate_total;
790  if (sbm_active) {
791  // The host update applies source terms (positivity
792  // clipping is applied afterward in ERF_ScalarLimitPost.H
793  // with the same restriction). Keep both projected liquid lanes out of
794  // that write path; they are refreshed from the spectrum
795  // after the no-op microphysics handoff.
796  num_comp = 1;
797  }
798  } else if (ivar == RhoScalar_comp) {
799  num_comp = NSCALARS;
800  }
801 
802  if (l_moving_terrain)
803  {
805  sbm_active, start_comp, num_comp, erf_sbm::HostWritePath::Positivity);
806  ParallelFor(tbx, num_comp,
807  [=] AMREX_GPU_DEVICE (int i, int j, int k, int nn) noexcept {
808  const int n = start_comp + nn;
809  if (!dc.host_transports(n)) { return; }
810  cell_rhs(i,j,k,n) += src_arr(i,j,k,n);
811  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);
812  cur_cons(i,j,k,n) = temp_val / detJ_new_arr(i,j,k);
813  if (ivar == RhoKE_comp && l_implicit_diss) {
814  cur_cons(i,j,k,n) /= (one + dt * diss(i,j,k) / amrex::max(old_cons(i,j,k,n), eps));
815  }
816  });
817 
818  } else if (l_anelastic && l_anelastic_rk2 && (nrk == 1)) { // not moving and ( (anelastic or pseudo-incompressible RK2) and second RK stage) )
819 
821  sbm_active, start_comp, num_comp, erf_sbm::HostWritePath::Positivity);
822  ParallelFor(tbx, num_comp,
823  [=] AMREX_GPU_DEVICE (int i, int j, int k, int nn) noexcept {
824  const int n = start_comp + nn;
825  if (!dc.host_transports(n)) { return; }
826  cell_rhs(i,j,k,n) += src_arr(i,j,k,n);
827 
828  // Re-construct the cell_rhs used in the first RK stage
829  Real dt_times_old_cell_rhs = cur_cons(i,j,k,n) - old_cons(i,j,k,n);
830 
831  // Add the time-averaged RHS to the old state
832  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));
833 
834  if (ivar == RhoKE_comp && l_implicit_diss) {
835  // stage 1 of the trapezoidal update: half the step is implicit
836  cur_cons(i,j,k,n) /= (one + myhalf * dt * diss(i,j,k) / amrex::max(old_cons(i,j,k,n), eps));
837  }
838  });
839 
840  } else { // not moving and ( (not anelastic / pseudo-incompressible RK2) or (first RK stage) )
841 
843  sbm_active, start_comp, num_comp, erf_sbm::HostWritePath::Positivity);
844  ParallelFor(tbx, num_comp,
845  [=] AMREX_GPU_DEVICE (int i, int j, int k, int nn) noexcept {
846  const int n = start_comp + nn;
847  if (!dc.host_transports(n)) { return; }
848  cell_rhs(i,j,k,n) += src_arr(i,j,k,n);
849  cur_cons(i,j,k,n) = old_cons(i,j,k,n) + dt * cell_rhs(i,j,k,n);
850  if (ivar == RhoKE_comp && l_implicit_diss) {
851  cur_cons(i,j,k,n) /= (one + dt * diss(i,j,k) / amrex::max(old_cons(i,j,k,n), eps));
852  }
853  });
854 
855  } // moving, anelastic / pseudo-incompressible RK2, or neither?
856 
857  } // is_valid
858  } // ivar
859 
860  // Fraction-stress immersed wall law with erf.if_wall_tke_time_factor = 1: hold the wall
861  // cell of each column at its wall value (ib_wall::wall_tke), as erf.dirichlet_k holds the
862  // first cell over flat ground. ib_wall_ktarget is -1 outside the wall cells.
863  if (ib_wall_ktarget && solverChoice.if_wall_tke_time_factor <= one && is_valid_slow_var[RhoKE_comp]) {
864  const Array4<const Real>& kt = ib_wall_ktarget->const_array(mfi);
865  ParallelFor(tbx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
866  if (kt(i,j,k) >= zero) {
867  cur_cons(i,j,k,RhoKE_comp) = cur_cons(i,j,k,Rho_comp) * kt(i,j,k);
868  }
869  });
870  }
871 
872  // Re-impose the Dirichlet wall value of k (first cell above the wall)
873  if (l_dirichlet_k && is_valid_slow_var[RhoKE_comp]) {
874  const int klo = domain.smallEnd(2);
875  if (tbx.smallEnd(2) <= klo && tbx.bigEnd(2) >= klo) {
876  ParallelFor(makeSlab(tbx,2,klo), [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
877  // Hold k, not rho*k. Eq. 16 defines the primitive wall value, and
878  // cur_cons(Rho_comp) has already been updated for this stage (and,
879  // with moving terrain, rescaled by detJ/detJ_new along with RhoKE),
880  // so copying the conserved variable straight across would let the
881  // wall value drift by the first-cell density change every step.
882  // Both states carry the same detJ convention, so the ratio is exact.
883  cur_cons(i,j,k,RhoKE_comp) = cur_cons(i,j,k,Rho_comp) *
884  ( old_cons(i,j,k,RhoKE_comp) / old_cons(i,j,k,Rho_comp) );
885  });
886  }
887  }
888  } // profile
889 
890  {
891  BL_PROFILE("rhs_post_9");
892  // This updates all the conserved variables (not just the "slow" ones)
893  int num_comp_all = S_data[IntVars::cons].nComp();
894  ParallelFor(tbx, num_comp_all,
895  [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) noexcept {
896  new_cons(i,j,k,n) = cur_cons(i,j,k,n);
897  });
898  } // end profile
899 
900  Box xtbx = mfi.nodaltilebox(0);
901  Box ytbx = mfi.nodaltilebox(1);
902  Box ztbx = mfi.nodaltilebox(2);
903 
904  {
905  BL_PROFILE("rhs_post_10()");
906  if (l_anelastic && terrain_blank) { // explicitly set fully immersed cells to have 0 velocities for anelastic and pseudo-incompressible (unstable for fully compressible).
907  // With erf.if_implicit_projection the drag of the solid is inside the projection, which
908  // already left these momenta divergence free; zeroing the faces between solid cells here
909  // would leave the surface faces unbalanced (a mass sink in the solid cells next to them,
910  // under a terrain surface or behind building walls and roofs).
911  const bool l_freeze_mom = !solverChoice.if_drag_in_projection(level);
912  ParallelFor(xtbx, ytbx, ztbx,
913  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
914  // Use face-centered terrain_blanking if available, otherwise average from cell centers
915  Real t_blank = (t_blank_xface_arr) ? t_blank_xface_arr(i, j, k) :
916  myhalf * (t_blank_arr(i, j, k) + t_blank_arr(i-1, j, k));
917  if (l_freeze_mom && t_blank == one) {
918  new_xmom(i,j,k) = zero;
919  } else {
920  new_xmom(i,j,k) = cur_xmom(i,j,k);
921  }
922  },
923  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
924  // Use face-centered terrain_blanking if available, otherwise average from cell centers
925  Real t_blank = (t_blank_yface_arr) ? t_blank_yface_arr(i, j, k) :
926  myhalf * (t_blank_arr(i, j, k) + t_blank_arr(i, j-1, k));
927  if (l_freeze_mom && t_blank == one) {
928  new_ymom(i,j,k) = zero;
929  } else {
930  new_ymom(i,j,k) = cur_ymom(i,j,k);
931  }
932  },
933  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
934  // Use face-centered terrain_blanking if available, otherwise average from cell centers
935  Real t_blank = (t_blank_zface_arr) ? t_blank_zface_arr(i, j, k) :
936  myhalf * (t_blank_arr(i, j, k) + t_blank_arr(i, j, k-1));
937  if (l_freeze_mom && t_blank == one) {
938  new_zmom(i,j,k) = zero;
939  } else {
940  new_zmom(i,j,k) = cur_zmom(i,j,k);
941  }
942  });
943  // With the fraction-stress wall law the microphysics species the host transports keep
944  // their value in the solid as rho and theta do (the wall face is closed to them; the
945  // lateral faces of a slope stay open to diffusion, as for theta). The implicit
946  // moisture solves of ERF_ImplicitPost.H run after this and hold them again.
947  const int l_ncomp = S_data[IntVars::cons].nComp();
948  const int l_q_lo = solverChoice.if_fraction_stress ? RhoQ1_comp : l_ncomp;
949  const DiffChoice l_diff_choice = solverChoice.diffChoice;
950  ParallelFor(tbx,
951  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
952  Real t_blank = t_blank_arr(i, j, k );
953  if (t_blank == one) { // don't update rho and theta for fully immersed cells
954  new_cons(i, j, k, Rho_comp) = old_cons(i, j, k, Rho_comp);
955  new_cons(i, j, k, RhoTheta_comp) = old_cons(i, j, k, RhoTheta_comp);
956  for (int n = l_q_lo; n < l_ncomp; ++n) {
958  new_cons(i, j, k, n) = old_cons(i, j, k, n);
959  }
960  }
961  }
962  });
963  } else {
964  ParallelFor(xtbx, ytbx, ztbx,
965  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
966  new_xmom(i,j,k) = cur_xmom(i,j,k);
967  },
968  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
969  new_ymom(i,j,k) = cur_ymom(i,j,k);
970  },
971  [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept {
972  new_zmom(i,j,k) = cur_zmom(i,j,k);
973  });
974  }
975  } // end profile
976 
977  {
978  BL_PROFILE("rhs_post_10");
979  // Only in the stages RefluxStageWeight weights
980  if (l_reflux) {
981  int strt_comp_reflux = RhoTheta_comp + 1;
982  int num_comp_reflux = nvars - strt_comp_reflux;
983  if (level < finest_level) {
984  fr_as_crse->CrseAdd(mfi,
985  {{AMREX_D_DECL(&(flux[0]), &(flux[1]), &(flux[2]))}},
986  dx, l_reflux_dt, strt_comp_reflux, strt_comp_reflux, num_comp_reflux, RunOn::Device);
987  }
988  if (level > 0) {
989  fr_as_fine->FineAdd(mfi,
990  {{AMREX_D_DECL(&(flux[0]), &(flux[1]), &(flux[2]))}},
991  dx, l_reflux_dt, strt_comp_reflux, strt_comp_reflux, num_comp_reflux, RunOn::Device);
992  }
993 
994  // This is necessary here so we don't go on to the next FArrayBox without
995  // having finished copying the fluxes into the FluxRegisters (since the fluxes
996  // are stored in temporary FArrayBox's)
997  Gpu::streamSynchronize();
998 
999  } // two-way coupling
1000  } // end profile
1001  } // mfi
1002  } // OMP
1003  if (cloud_budget && l_use_diff && n_qstate > 0) {
1004  bool use_trapezoidal = (!l_anelastic || l_anelastic_rk2);
1005  for (int qstate = 0; qstate < n_qstate; ++qstate) {
1006  MultiFab qflux_x(*dflux_x, make_alias, qstate, 1);
1007  MultiFab qflux_y(*dflux_y, make_alias, qstate, 1);
1008  MultiFab qflux_z(*dflux_z, make_alias, qstate, 1);
1009  cloud_budget->capture_stage(
1011  nrk, static_cast<Real>(dt_d), qflux_x, qflux_y, qflux_z, geom,
1012  0, use_trapezoidal);
1013  }
1014  }
1015 }
GpuArray< Real, AMREX_SPACEDIM > dx
Definition: ERF_ActuatorSpreading.cpp:131
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 > &upw_x, const amrex::Array4< const amrex::Real > &upw_y, const amrex::Array4< const amrex::Real > &upw_z, 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:491
@ tau23
Definition: ERF_DataStruct.H:51
@ tau13
Definition: ERF_DataStruct.H:51
@ nvars
Definition: ERF_DataStruct.H:235
@ v_x
Definition: ERF_DataStruct.H:40
@ u_y
Definition: ERF_DataStruct.H:41
@ v_y
Definition: ERF_DataStruct.H:41
@ m_y
Definition: ERF_DataStruct.H:41
@ u_x
Definition: ERF_DataStruct.H:40
@ m_x
Definition: ERF_DataStruct.H:40
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, const amrex::Vector< std::unique_ptr< SurfaceLayer >> &SurfLayer)
Add state diffusion source terms for embedded-boundary cells.
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 > &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, const amrex::Array4< const amrex::Real > &mu_turb, const SolverChoice &solverChoice, const int level, const amrex::BCRec *bc_ptr, const bool use_SurfLayer, const amrex::Vector< std::unique_ptr< SurfaceLayer >> &SurfLayer, const amrex::Real implicit_fac, const ScalarDiffusionRefluxViews *reflux_flx=nullptr)
Native adapter for regular scalar diffusion on a vertically stretched grid.
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 > &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, const amrex::Array4< const amrex::Real > &mu_turb, const SolverChoice &solverChoice, const int level, const amrex::BCRec *bc_ptr, const bool use_SurfLayer, const amrex::Vector< std::unique_ptr< SurfaceLayer >> &SurfLayer, const amrex::Real implicit_fac, const ScalarDiffusionRefluxViews *reflux_flx=nullptr, const amrex::Array4< const amrex::Real > &wall_face33=amrex::Array4< const amrex::Real >{}, const amrex::Array4< const amrex::Real > &wall_hfx=amrex::Array4< const amrex::Real >{}, const amrex::Array4< const amrex::Real > &wall_qfx=amrex::Array4< const amrex::Real >{})
Add regular-grid state diffusion on a uniform grid without terrain.
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 > &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, const amrex::Array4< const amrex::Real > &mu_turb, const SolverChoice &solverChoice, const int level, const amrex::BCRec *bc_ptr, const amrex::BCRec *bc_ptr_h, const bool use_SurfLayer, const amrex::Vector< std::unique_ptr< SurfaceLayer >> &SurfLayer, const amrex::Real implicit_fac, const ScalarDiffusionRefluxViews *reflux_flx=nullptr)
Native adapter for regular scalar diffusion on terrain-following coordinates.
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:65
#define Rho_comp
Definition: ERF_IndexDefines.H:61
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:62
#define NSCALARS
Definition: ERF_IndexDefines.H:34
#define RhoQ1_comp
Definition: ERF_IndexDefines.H:78
AdvType
Definition: ERF_IndexDefines.H:329
#define RhoKE_comp
Definition: ERF_IndexDefines.H:63
amrex::GpuArray< Real, AMREX_SPACEDIM > dxInv
Definition: ERF_InitCustomPertVels_ParticleTests.H:16
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(axis >=0 &&axis< AMREX_SPACEDIM, "prob.axis must be 0, 1 or 2")
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
const int klo
Definition: ERF_InitCustomPert_KE.H:9
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);})
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:37
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:36
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:41
amrex::GpuArray< const amrex::Array4< amrex::Real >, AMREX_SPACEDIM > ScalarDiffusionRefluxViews
Definition: ERF_ScalarDiffusion.H:1750
const DiffChoice l_diff_choice
Definition: ERF_ScalarLimitPost.H:17
const bool l_dirichlet_k
Definition: ERF_ScalarLimitPost.H:21
bool IsRefluxStage(const SolverChoice &solverChoice, int level, int finest_level, int nrk)
Definition: ERF_TI_slow_headers.H:91
amrex::Real RefluxStageWeight(const SolverChoice &solverChoice, int level, int finest_level, int nrk)
Definition: ERF_TI_slow_headers.H:78
void AddTurbKESources(const amrex::Box &bx, const amrex::Box &domain, 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< const amrex::Real > &SmnSmn_a, const amrex::Array4< const amrex::Real > &hfx_z, const amrex::Array4< const amrex::Real > &qfx1_z, const amrex::Array4< const amrex::Real > &diss, const amrex::Array4< const amrex::Real > &tau13, const amrex::Array4< const amrex::Real > &tau23, 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::Vector< std::unique_ptr< SurfaceLayer >> &SurfLayer, const PBLDerivativeDzInvFunctor &pbl_derivative_dz_inv)
Definition: ERF_TurbKESources.H:47
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, bool trapezoidal=true)
Definition: ERF_CloudChamberBudget.H:94
@ RhoQv
Definition: ERF_CloudChamberBudget.H:33
@ RhoQc
Definition: ERF_CloudChamberBudget.H:33
const std::unique_ptr< amrex::EBFArrayBoxFactory > & get_const_factory() const noexcept
Return the cell-centered EB factory.
Definition: ERF_EB.H:110
void advance_stage(int level, HostIntegrator method, int stage, double step_old_time, double input_time, double target_time, double host_stage_interval, const amrex::MultiFab &conserved_anchor, const amrex::MultiFab &conserved_input, const amrex::MultiFab &conserved_target, const amrex::MultiFab &avg_xmom, const amrex::MultiFab &avg_ymom, const amrex::MultiFab &avg_zmom, const AdvChoice &advection, const amrex::Geometry &geometry)
Definition: ERF_AuxiliaryInertTracer.cpp:136
void advance_stage_from_host(int level, erf_auxiliary::HostIntegrator method, int stage, double step_old_time, double input_time, double target_time, double host_stage_interval, SBMStateManager &state_manager, const amrex::MultiFab &S_old_cons, const amrex::MultiFab &S_new_cons, amrex::MultiFab &S_data_cons, const amrex::MultiFab &avg_xmom, const amrex::MultiFab &avg_ymom, const amrex::MultiFab &avg_zmom, const amrex::Geometry &geometry, int qc_component, int qr_component, const SBMAMRStageParent *parent=nullptr, const SBMStageMixingInputs *mixing=nullptr)
Definition: ERF_SBMTransport.cpp:2590
bool mixes_particles() const noexcept
Definition: ERF_SBMTransport.H:191
@ ymom
Definition: ERF_IndexDefines.H:251
@ cons
Definition: ERF_IndexDefines.H:249
@ zmom
Definition: ERF_IndexDefines.H:252
@ xmom
Definition: ERF_IndexDefines.H:250
@ None
Definition: ERF_LSM_Types.H:6
@ ng
Definition: ERF_Morrison.H:51
@ nn
Definition: ERF_WDM6.H:33
@ xvel
Definition: ERF_IndexDefines.H:232
@ zvel
Definition: ERF_IndexDefines.H:234
@ yvel
Definition: ERF_IndexDefines.H:233
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< const amrex::Real > &u, const amrex::Array4< const amrex::Real > &v, const amrex::Array4< const amrex::Real > &w, 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, const bool cloudy=false, const erf_wall_thermodynamics::SidewallBandViews &bands={})
Definition: ERF_CloudChamberWallFlux.H:1278
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real eps()
Definition: ERF_ShocMoments.cpp:19
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void copy_host_slow_component(const amrex::Array4< amrex::Real > &current, const amrex::Array4< const amrex::Real > &predictor, const int i, const int j, const int k, const int component, const bool sbm_active, const int qc_component, const int qr_component) noexcept
Definition: ERF_SBMStageOwnership.H:11
void require_host_write_range_allowed(const bool sbm_active, const int start_component, const int num_components, const HostWritePath path)
Definition: ERF_SBMOwnership.cpp:47
SBMStageMixingInputs make_stage_mixing_inputs(const SBMTransport &transport, const MultiFab *eddy_diffusivity, const amrex::Vector< std::unique_ptr< MultiFab >> &mapfac, const MultiFab *ax, const MultiFab *ay, const Real *stretched_dz, const MultiFab *z_nd, const MultiFab *z_cc)
Definition: ERF_SBMTransport.cpp:2461
amrex::GpuArray< TemperatureBandView, 4 > SidewallBandViews
Definition: ERF_WallThermodynamics.H:63
amrex::GpuArray< FaceWall, 2 *AMREX_SPACEDIM > Boundary
Definition: ERF_WallThermodynamics.H:133
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:25
MolecDiffType molec_diff_type
Selected molecular transport model.
Definition: ERF_DiffStruct.H:97
amrex::Real alpha_C
Kinematic scalar diffusivity [m2/s].
Definition: ERF_DiffStruct.H:101
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool host_transports(int n) const noexcept
Definition: ERF_DiffStruct.H:122
amrex::Real alpha_T
Kinematic temperature diffusivity [m2/s].
Definition: ERF_DiffStruct.H:100
int qr
rain
Definition: ERF_DataStruct.H:293
int qc
cloud liquid water
Definition: ERF_DataStruct.H:291
Functor for inverse vertical spacings with constant grid spacing.
Definition: ERF_PBLModels.H:608
Functor for inverse vertical spacings for stretched grids using a spacing array.
Definition: ERF_PBLModels.H:626
Functor for inverse vertical spacings for terrain-following grids using cell-center heights.
Definition: ERF_PBLModels.H:652
bool if_drag_in_projection(int lev) const noexcept
Definition: ERF_DataStruct.H:3223
amrex::Vector< TurbChoice > turbChoice
Turbulence options for each AMR level.
Definition: ERF_DataStruct.H:3020
amrex::Vector< TimesteppingType > timestepping_type
Per-level time integrator (RK3_ImplicitSubstep, RK3_NoSubstepping, RK2 or MidPoint).
Definition: ERF_DataStruct.H:3029
bool if_fraction_stress
erf.if_wall_form = fraction_stress: the wall stress of ERF_ImmersedWallCell.H in the wall cell of eac...
Definition: ERF_DataStruct.H:3126
amrex::Real gravity
Effective gravitational acceleration.
Definition: ERF_DataStruct.H:3148
bool implicit_moisture_diffusion
Whether implicit vertical moisture diffusion is included.
Definition: ERF_DataStruct.H:3062
MoistureType moisture_type
Moisture or microphysics model.
Definition: ERF_DataStruct.H:3433
bool sbm_test_native_qc_write_fault
Definition: ERF_DataStruct.H:3446
bool use_rotate_surface_flux
Whether MOST surface fluxes are rotated with terrain.
Definition: ERF_DataStruct.H:3196
bool implicit_ke_diffusion
Whether implicit vertical TKE diffusion is included.
Definition: ERF_DataStruct.H:3063
amrex::Real if_wall_tke_time_factor
1 (the default) pins the wall cell after every stage and in the implicit TKE solve; a larger value re...
Definition: ERF_DataStruct.H:3129
amrex::Real rdOcp
Ratio of dry-air gas constant to c_p.
Definition: ERF_DataStruct.H:3150
static MeshType mesh_type
Vertical mesh representation.
Definition: ERF_DataStruct.H:3004
AdvChoice advChoice
Advection-related options.
Definition: ERF_DataStruct.H:3016
amrex::Vector< CompressibilityType > compressibility_type
Per-level compressibility (FullyCompressible, Anelastic or PseudoIncompressible).
Definition: ERF_DataStruct.H:3028
amrex::Vector< amrex::Vector< amrex::Real > > vert_implicit_fac
Per-level, per-stage implicit vertical diffusion factors.
Definition: ERF_DataStruct.H:3058
bool transport_scalar
Whether the passive scalar component is transported.
Definition: ERF_DataStruct.H:3206
static TerrainType terrain_type
Terrain or immersed-boundary representation.
Definition: ERF_DataStruct.H:2989
bool sbm_test_donor_cfl_fault
Definition: ERF_DataStruct.H:3447
DiffChoice diffChoice
Diffusion-related options.
Definition: ERF_DataStruct.H:3017
MoistureComponentIndices moisture_indices
Index map of the moisture data carried by the active scheme: conserved-state components for the speci...
Definition: ERF_DataStruct.H:3504
Definition: ERF_TurbStruct.H:129
bool advect_tke
Whether TKE/QKE is advected.
Definition: ERF_TurbStruct.H:1146
bool implicit_tke_dissipation
Definition: ERF_TurbStruct.H:971
bool use_tke
Whether any TKE or QKE closure is active.
Definition: ERF_TurbStruct.H:1067
RANSType rans_type
Selected RANS closure.
Definition: ERF_TurbStruct.H:960
bool use_keqn
Whether a microscale TKE closure is active.
Definition: ERF_TurbStruct.H:1062
bool uses_native_shoc() const noexcept
Query whether this level uses the native SHOC PBL scheme.
Definition: ERF_TurbStruct.H:1009
bool dirichlet_k
Whether TKE uses Dirichlet boundary treatment.
Definition: ERF_TurbStruct.H:962
LESType les_type
Selected LES closure.
Definition: ERF_TurbStruct.H:909
bool use_kturb
Whether any turbulence model is active.
Definition: ERF_TurbStruct.H:1061
PBLType pbl_type
Selected PBL closure.
Definition: ERF_TurbStruct.H:1003
erf_wall_thermodynamics::SidewallBandViews temperature_band_views() const &noexcept
Definition: ERF_CloudChamber.H:65
const erf_wall_thermodynamics::Boundary & transport_boundary() const &
Definition: ERF_CloudChamber.H:59
bool has_moisture
Definition: ERF_CloudChamber.H:41
bool physical_initialization
Definition: ERF_CloudChamber.H:42
Definition: ERF_SBMTransport.H:98
Here is the call graph for this function: