ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_PBLModels.H
Go to the documentation of this file.
1 #ifndef ERF_PBLMODELS_H_
2 #define ERF_PBLMODELS_H_
3 
4 #include <functional>
5 #include <limits>
6 #include <memory>
7 
8 #include <AMReX_MultiFab.H>
9 #include <AMReX_Periodicity.H>
10 #include "ERF_Constants.H"
11 #include "ERF_DataStruct.H"
12 #include "ERF_MOSTUtils.H"
13 
14 /**
15  * Compute eddy diffusivities of momentum (eddy viscosity) and heat using the
16  * Mellor-Yamada-Janjić (MYJ) boundary layer scheme.
17  * Reference: Janjić, Z. I., 1994: The Step-Mountain Eta Coordinate Model:
18  * Further Developments of the Convection, Viscous Sublayer, and Turbulence
19  * Closure Schemes. Monthly Weather Review, 122, 927–945.
20  * https://doi.org/10.1175/1520-0493(1994)122<0927:TSMECM>2.0.CO;2
21  *
22  * @param[in] xvel Velocity in x-dir
23  * @param[in] yvel Velocity in y-dir
24  * @param[in] cons_in Cell center conserved quantities
25  * @param[out] eddyViscosity Holds turbulent viscosity
26  * @param[in] geom Problem geometry
27  * @param[in] turbChoice Container with turbulence parameters
28  * @param[in] SurfLayer Pointer to Monin-Obukhov class if instantiated
29  * @param[in] use_moisture If we have microphysics enabled
30  * @param[in] level Current level
31  * @param[in] bc_ptr Pointer to array with boundary condition info
32  * @param[in] vert_only Only compute vertical eddy diffusivities
33  * @param[in] z_phys_nd Physical location of grid nodes, if terrain (or grid stretching) is enabled
34  * @param[in] z_sfc_nd Nodal heights of the bottom of the domain
35  * @param[in] z_phys_cc Physical location of cell centers
36  */
37 void
39  const amrex::MultiFab& xvel,
40  const amrex::MultiFab& yvel,
41  amrex::MultiFab& cons_in,
42  amrex::MultiFab& eddyViscosity,
43  const amrex::Geometry& geom,
44  const TurbChoice& turbChoice,
45  std::unique_ptr<SurfaceLayer>& SurfLayer,
46  bool use_terrain_fitted_coords,
47  bool use_moisture,
48  int level,
49  const amrex::BCRec* bc_ptr,
50  bool /*vert_only*/,
51  const std::unique_ptr<amrex::MultiFab>& z_phys_nd,
52  const std::unique_ptr<amrex::MultiFab>& z_sfc_nd,
53  const std::unique_ptr<amrex::MultiFab>& z_phys_cc,
54  const MoistureComponentIndices& moisture_indices);
55 
56 /**
57  * Compute eddy diffusivities of momentum (eddy viscosity) and heat using the
58  * Mellor-Yamada-Nakanishi-Niino Level amrex::Real(2.5) PBL scheme
59  *
60  * @param[in] xvel Velocity in x-dir
61  * @param[in] yvel Velocity in y-dir
62  * @param[in] cons_in Cell center conserved quantities
63  * @param[out] eddyViscosity Holds turbulent viscosity
64  * @param[in] geom Problem geometry
65  * @param[in] turbChoice Container with turbulence parameters
66  * @param[in] SurfLayer Pointer to Monin-Obukhov class if instantiated
67  * @param[in] use_moisture If we have microphysics enabled
68  * @param[in] level Current level
69  * @param[in] bc_ptr Pointer to array with boundary condition info
70  * @param[in] vert_only Only compute vertical eddy diffusivities
71  * @param[in] z_phys_nd Physical location of grid nodes, if terrain (or grid stretching) is enabled
72  * @param[in] z_sfc_nd Nodal heights of the bottom of the domain
73  * @param[in] z_phys_cc Physical location of cell centers
74  */
75 void
76 ComputeDiffusivityMYNN25 (const amrex::MultiFab& xvel,
77  const amrex::MultiFab& yvel,
78  const amrex::MultiFab& cons_in,
79  amrex::MultiFab& eddyViscosity,
80  const amrex::Geometry& geom,
81  const TurbChoice& turbChoice,
82  std::unique_ptr<SurfaceLayer>& SurfLayer,
83  bool use_terrain_fitted_coords,
84  bool use_moisture,
85  int level,
86  const amrex::BCRec* bc_ptr,
87  bool /*vert_only*/,
88  const std::unique_ptr<amrex::MultiFab>& z_phys_nd,
89  const std::unique_ptr<amrex::MultiFab>& z_sfc_nd,
90  const std::unique_ptr<amrex::MultiFab>& z_phys_cc,
91  const MoistureComponentIndices& moisture_indices);
92 
93 /**
94  * Compute eddy diffusivities of momentum (eddy viscosity) and heat using the
95  * Mellor-Yamada-Nakanishi-Niino Level amrex::Real(2.5) PBL scheme
96  *
97  * @param[in] xvel Velocity in x-dir
98  * @param[in] yvel Velocity in y-dir
99  * @param[in] cons_in Cell center conserved quantities
100  * @param[out] eddyViscosity Holds turbulent viscosity
101  * @param[in] geom Problem geometry
102  * @param[in] turbChoice Container with turbulence parameters
103  * @param[in] SurfLayer Pointer to Monin-Obukhov class if instantiated
104  * @param[in] use_moisture If we have microphysics enabled
105  * @param[in] level Current level
106  * @param[in] bc_ptr Pointer to array with boundary condition info
107  * @param[in] vert_only Only compute vertical eddy diffusivities
108  * @param[in] z_phys_nd Physical location of grid nodes, if terrain (or grid stretching) is enabled
109  * @param[in] z_sfc_nd Nodal heights of the bottom of the domain
110  * @param[in] z_phys_cc Physical location of cell centers
111  */
112 void
113 ComputeDiffusivityMYNNEDMF (const amrex::MultiFab& xvel,
114  const amrex::MultiFab& yvel,
115  const amrex::MultiFab& cons_in,
116  amrex::MultiFab& eddyViscosity,
117  const amrex::Geometry& geom,
118  const TurbChoice& turbChoice,
119  std::unique_ptr<SurfaceLayer>& SurfLayer,
120  bool use_terrain_fitted_coords,
121  bool use_moisture,
122  int level,
123  const amrex::BCRec* bc_ptr,
124  bool /*vert_only*/,
125  const std::unique_ptr<amrex::MultiFab>& z_phys_nd,
126  const std::unique_ptr<amrex::MultiFab>& z_sfc_nd,
127  const std::unique_ptr<amrex::MultiFab>& z_phys_cc,
128  const MoistureComponentIndices& moisture_indices);
129 
130 /**
131  * Compute eddy diffusivities of momentum (eddy viscosity) and heat using the
132  * Medium Range Forecast (MRF) boundary layer scheme based on Hong and Pan (1996).
133  * Reference: Hong, S. Y., and H.-L. Pan, 1996: Nonlocal Boundary Layer Vertical
134  * Diffusion in a Medium-Range Forecast Model. Monthly Weather Review, 124,
135  * 2322-2339. https://doi.org/10.1175/1520-0493(1996)124<2322:NBLVDI>2.0.CO;2
136  *
137  * @param[in] xvel Velocity in x-dir
138  * @param[in] yvel Velocity in y-dir
139  * @param[in] cons_in Cell center conserved quantities
140  * @param[out] eddyViscosity Holds turbulent viscosity
141  * @param[in] geom Problem geometry
142  * @param[in] turbChoice Container with turbulence parameters
143  * @param[in] SurfLayer Pointer to Monin-Obukhov class if instantiated
144  * @param[in] use_moisture If we have microphysics enabled
145  * @param[in] level Current level
146  * @param[in] bc_ptr Pointer to array with boundary condition info
147  * @param[in] vert_only Only compute vertical eddy diffusivities
148  * @param[in] z_phys_nd Physical location of grid nodes, if terrain (or grid stretching) is enabled
149  * @param[in] z_sfc_nd Nodal heights of the bottom of the domain
150  * @param[in] z_phys_cc Physical location of cell centers
151  * @param[in] terrain_blank Immersed solid fraction, or null
152  * @param[in] Q_fire_atm Lagged fire heat flux [W/m2] for the w* boost (erf.pbl_mrf_fire_thermal_excess), or null
153  * @param[in] mf_m Map factors m_x and m_y at cell centers, for the physical cell size of the
154  * scale-aware blending, or null (unit map factors)
155  */
156 void
157 ComputeDiffusivityMRF (const amrex::MultiFab& xvel,
158  const amrex::MultiFab& yvel,
159  const amrex::MultiFab& cons_in,
160  amrex::MultiFab& eddyViscosity,
161  const amrex::Geometry& geom,
162  const TurbChoice& turbChoice,
163  std::unique_ptr<SurfaceLayer>& SurfLayer,
164  bool use_terrain_fitted_coords,
165  bool use_moisture,
166  int level,
167  const amrex::BCRec* bc_ptr,
168  bool /*vert_only*/,
169  const std::unique_ptr<amrex::MultiFab>& z_phys_nd,
170  const std::unique_ptr<amrex::MultiFab>& z_sfc_nd,
171  const std::unique_ptr<amrex::MultiFab>& z_phys_cc,
172  const MoistureComponentIndices& moisture_indices,
173  const amrex::MultiFab* terrain_blank = nullptr,
174  const amrex::MultiFab* Q_fire_atm = nullptr,
175  amrex::GpuArray<const amrex::MultiFab*, 2> mf_m = {{nullptr, nullptr}});
176 
177 /**
178  * Compute eddy diffusivities of momentum (eddy viscosity) and heat using the
179  * WRF Yonsei University (YSU) PBL scheme.
180  *
181  * Based on:
182  * Hong, Noh & Dudhia (2006), MWR, https://doi.org/10.1175/MWR3199.1
183  * Hong (2010), QJRMS, https://doi.org/10.1002/qj.665
184  *
185  * Features: three-pass bulk-Richardson PBLH diagnosis, nonlocal
186  * countergradient fluxes, explicit entrainment at PBL top, and
187  * grid-adaptive Richardson-number mixing in free atmosphere.
188  *
189  * @param[in] xvel x-direction velocity
190  * @param[in] yvel y-direction velocity
191  * @param[in] cons_in cell-center conserved quantities
192  * @param[out] eddyViscosity turbulent eddy viscosity
193  * @param[in] geom problem geometry
194  * @param[in] turbChoice turbulence parameter container
195  * @param[in] SurfLayer Monin-Obukhov surface layer object
196  * @param[in] use_terrain_fitted_coords flag for terrain coordinates
197  * @param[in] use_moisture flag for moisture active
198  * @param[in] level AMR level
199  * @param[in] bc_ptr boundary condition array
200  * @param[in] vert_only compute vertical diffusivity only
201  * @param[in] z_phys_nd physical node heights (terrain)
202  * @param[in] z_sfc_nd Nodal heights of the bottom of the domain
203  * @param[in] z_phys_cc physical cell-center heights
204  * @param[in] moisture_indices component index mapping for moisture variables
205  * @param[in] qheating_rates radiation heating rates (SW, LW components); optional
206  */
207 void
208 ComputeDiffusivityYSU (const amrex::MultiFab& xvel,
209  const amrex::MultiFab& yvel,
210  const amrex::MultiFab& cons_in,
211  amrex::MultiFab& eddyViscosity,
212  const amrex::Geometry& geom,
213  const TurbChoice& turbChoice,
214  std::unique_ptr<SurfaceLayer>& SurfLayer,
215  bool use_terrain_fitted_coords,
216  bool use_moisture,
217  int level,
218  const amrex::BCRec* bc_ptr,
219  bool /*vert_only*/,
220  const std::unique_ptr<amrex::MultiFab>& z_phys_nd,
221  const std::unique_ptr<amrex::MultiFab>& z_sfc_nd,
222  const std::unique_ptr<amrex::MultiFab>& z_phys_cc,
223  const MoistureComponentIndices& moisture_indices,
224  const amrex::MultiFab* qheating_rates = nullptr,
225  const amrex::MultiFab* terrain_blank = nullptr);
226 
227 /**
228  * Function for computing vertical derivatives for use in PBL model
229  *
230  * @param[in] u velocity in x-dir
231  * @param[in] v velocity in y-dir
232  * @param[in] cell_data conserved cell center vars
233  */
235 {
236  // Each value is the inverse physical distance between the two samples
237  // used by its corresponding derivative stencil.
238  amrex::Real interior;
239  amrex::Real dirichlet_lo;
240  amrex::Real dirichlet_hi;
241 };
242 
243 /**
244  * Compute vertical derivatives of potential temperature and velocity for PBL models.
245  *
246  * @param i x-index
247  * @param j y-index
248  * @param k z-index
249  * @param[in] uvel x-velocity
250  * @param[in] vvel y-velocity
251  * @param[in] cell_data conserved cell-center variables
252  * @param[in] izmin lower z-index limit
253  * @param[in] izmax upper z-index limit
254  * @param[in] dz_inv inverse physical distance spacings
255  * @param[in] c_ext_dir_on_zlo Dirichlet condition on z-low face for cell data
256  * @param[in] c_ext_dir_on_zhi Dirichlet condition on z-high face for cell data
257  * @param[in] u_ext_dir_on_zlo Dirichlet condition on z-low face for u-velocity
258  * @param[in] u_ext_dir_on_zhi Dirichlet condition on z-high face for u-velocity
259  * @param[in] v_ext_dir_on_zlo Dirichlet condition on z-low face for v-velocity
260  * @param[in] v_ext_dir_on_zhi Dirichlet condition on z-high face for v-velocity
261  * @param[out] dthetadz computed vertical derivative of potential temperature
262  * @param[out] dudz computed vertical derivative of x-velocity
263  * @param[out] dvdz computed vertical derivative of y-velocity
264  * @param[in] moisture_indices moisture variable component indices
265  */
266 /**
267  * Thermodynamic variable whose vertical gradient the PBL schemes use for
268  * buoyancy, selected by erf.thermal_stratification.
269  *
270  * @param[in] strat stratification variable to return
271  */
272 AMREX_GPU_DEVICE
273 AMREX_FORCE_INLINE
274 amrex::Real
275 GetPBLStratVar (int i, int j, int k,
276  const StratType strat,
277  const amrex::Array4<const amrex::Real>& cell_data,
278  const MoistureComponentIndices& moisture_indices)
279 {
280  if (strat == StratType::theta) {
281  return cell_data(i,j,k,RhoTheta_comp) / cell_data(i,j,k,Rho_comp);
282  } else if (strat == StratType::thetal) {
283  return GetThetal(i,j,k,cell_data,moisture_indices);
284  }
285  return GetThetav(i,j,k,cell_data,moisture_indices);
286 }
287 
288 AMREX_GPU_DEVICE
289 AMREX_FORCE_INLINE
290 void
291 ComputeVerticalDerivativesPBL (int i, int j, int k,
292  const amrex::Array4<const amrex::Real>& uvel,
293  const amrex::Array4<const amrex::Real>& vvel,
294  const amrex::Array4<const amrex::Real>& cell_data,
295  const int izmin,
296  const int izmax,
297  const PBLDerivativeDzInv& dz_inv,
298  const bool c_ext_dir_on_zlo,
299  const bool c_ext_dir_on_zhi,
300  const bool u_ext_dir_on_zlo,
301  const bool u_ext_dir_on_zhi,
302  const bool v_ext_dir_on_zlo,
303  const bool v_ext_dir_on_zhi,
304  amrex::Real& dthetadz,
305  amrex::Real& dudz,
306  amrex::Real& dvdz,
307  const MoistureComponentIndices& moisture_indices,
308  const StratType strat = StratType::thetav)
309 {
310  // ext_dir ghost values hold the value at the physical boundary, which is
311  // half a ghost-center spacing from the adjacent cell center. Use a
312  // two-point, first-order boundary-to-center difference with inverse
313  // distance 2/dz.
314  if ( k==izmax && c_ext_dir_on_zhi ) {
315  dthetadz = ( GetPBLStratVar(i,j,k+1,strat,cell_data,moisture_indices)
316  -GetPBLStratVar(i,j,k ,strat,cell_data,moisture_indices) )*dz_inv.dirichlet_hi;
317  } else if ( k==izmin && c_ext_dir_on_zlo ) {
318  dthetadz = ( GetPBLStratVar(i,j,k ,strat,cell_data,moisture_indices)
319  -GetPBLStratVar(i,j,k-1,strat,cell_data,moisture_indices) )*dz_inv.dirichlet_lo;
320  } else {
321  dthetadz = ( GetPBLStratVar(i,j,k+1,strat,cell_data,moisture_indices)
322  -GetPBLStratVar(i,j,k-1,strat,cell_data,moisture_indices) )*dz_inv.interior;
323  }
324 
325  if ( k==izmax && u_ext_dir_on_zhi ) {
326  dudz = myhalf*( uvel(i ,j,k+1) - uvel(i ,j,k)
327  +uvel(i+1,j,k+1) - uvel(i+1,j,k) )*dz_inv.dirichlet_hi;
328  } else if ( k==izmin && u_ext_dir_on_zlo ) {
329  dudz = myhalf*( uvel(i ,j,k) - uvel(i ,j,k-1)
330  +uvel(i+1,j,k) - uvel(i+1,j,k-1) )*dz_inv.dirichlet_lo;
331  } else {
332  dudz = myhalf*( uvel(i ,j,k+1) - uvel(i ,j,k-1)
333  +uvel(i+1,j,k+1) - uvel(i+1,j,k-1) )*dz_inv.interior;
334  }
335 
336  if ( k==izmax && v_ext_dir_on_zhi ) {
337  dvdz = myhalf*( vvel(i,j ,k+1) - vvel(i,j ,k)
338  +vvel(i,j+1,k+1) - vvel(i,j+1,k) )*dz_inv.dirichlet_hi;
339  } else if ( k==izmin && v_ext_dir_on_zlo ) {
340  dvdz = myhalf*( vvel(i,j ,k) - vvel(i,j ,k-1)
341  +vvel(i,j+1,k) - vvel(i,j+1,k-1) )*dz_inv.dirichlet_lo;
342  } else {
343  dvdz = myhalf*( vvel(i,j ,k+1) - vvel(i,j ,k-1)
344  +vvel(i,j+1,k+1) - vvel(i,j+1,k-1) )*dz_inv.interior;
345  }
346 }
347 
348 /**
349  * Monin-Obukhov quantities needed to rebuild the vertical gradients in the first
350  * cell above a surface-layer boundary.
351  */
353 {
354  amrex::Real u_star {zero}; ///< friction velocity
355  amrex::Real tstar_v {zero}; ///< virtual temperature scale
356  amrex::Real zval {zero}; ///< height of the cell center above the surface
357  amrex::Real zeta {zero}; ///< stability coordinate z/L
358  similarity_funs sfuns{}; ///< the surface layer's similarity functions (most.stable_functions)
359 };
360 
361 /**
362  * Virtual temperature scale, thetav_* = theta_*(1 + epsv qv) + epsv theta q_*.
363  * The surface virtual heat flux is <w'thetav'> = -u_* thetav_*.
364  *
365  * @param[in] t_star temperature scale
366  * @param[in] q_star moisture scale
367  * @param[in] theta potential temperature
368  * @param[in] qv water vapor mixing ratio
369  * @param[in] use_moisture whether the moisture term is active
370  */
371 AMREX_GPU_DEVICE
372 AMREX_FORCE_INLINE
373 amrex::Real
374 ComputeVirtualTStarPBL (amrex::Real t_star,
375  amrex::Real q_star,
376  amrex::Real theta,
377  amrex::Real qv,
378  bool use_moisture)
379 {
380  amrex::Real tstar_v = t_star * (one + epsv*qv);
381  if (use_moisture) { tstar_v += epsv * theta * q_star; }
382  return tstar_v;
383 }
384 
385 /**
386  * Overwrite the vertical gradients in the first cell above the surface with the
387  * MOST profile gradients,
388  * |dU/dz| = u_* phi_m(zeta) / (kappa z)
389  * dthetav/dz = thetav_* phi_h(zeta) / (kappa z)
390  *
391  * With zlo.type = surface_layer the state carries foextrap and the velocities
392  * hoextrap at the lower boundary, so the centered stencil in
393  * ComputeVerticalDerivativesPBL reads ghost values that hold no surface
394  * information there: the potential-temperature gradient comes out half the
395  * one-sided value and the velocity gradient has no dependence on the friction
396  * velocity at all (ERF #4037). The MOST profile used here is the one the surface
397  * stress and heat flux were themselves derived from.
398  *
399  * Every PBL scheme that consumes these gradients uses only the shear magnitude
400  * dudz^2 + dvdz^2, so that magnitude is carried in dudz and dvdz is left at zero
401  * rather than being split by wind direction.
402  *
403  * @param[in] sl Monin-Obukhov inputs for this column
404  * @param[out] dthetadz vertical derivative of virtual potential temperature
405  * @param[out] dudz vertical derivative of x-velocity (carries the shear magnitude)
406  * @param[out] dvdz vertical derivative of y-velocity (set to zero)
407  */
408 AMREX_GPU_DEVICE
409 AMREX_FORCE_INLINE
410 void
412  amrex::Real& dthetadz,
413  amrex::Real& dudz,
414  amrex::Real& dvdz)
415 {
416  const similarity_funs& sfuns = sl.sfuns;
417  const amrex::Real inv_kappa_z = one / (KAPPA * sl.zval);
418  dudz = sl.u_star * sfuns.calc_phi_m(sl.zeta) * inv_kappa_z;
419  dvdz = zero;
420  dthetadz = sl.tstar_v * sfuns.calc_phi_h(sl.zeta) * inv_kappa_z;
421 }
422 
423 /**
424  * Function for computing the QKE source terms (NN09, Eqn. 5).
425  *
426  * @param[in] u velocity in x-dir
427  * @param[in] v velocity in y-dir
428  * @param[in] cell_data conserved cell center vars
429  * @param[in] cell_prim primitive cell center vars
430  * @param[in] K_turb turbulent viscosity
431  * @param[in] domain box of the whole domain
432  * @param[in] dz_inv inverse spacings for interior and Dirichlet-boundary differences
433  * @param[in] pbl_mynn_B1_l a parameter
434  * @param[in] theta_mean average theta
435  * @param[in] moisture_indices moisture variable component indices
436  * @param[in] tau13 rho<u'w'> on z-faces; the surface-layer stress at the zlo face
437  * @param[in] tau23 rho<v'w'> on z-faces; the surface-layer stress at the zlo face
438  * @param[in] hfx_z rho<w'theta'> on z-faces; the surface-layer heat flux at the zlo face
439  * @param[in] qfx1_z rho<w'qv'> on z-faces; the surface-layer moisture flux at the zlo face
440  * @param[in] surface_layer_on_zlo a SurfaceLayer supplies the fluxes through the zlo face
441  * @param[in] sfuns similarity functions of the surface layer on the zlo face (most.stable_functions)
442  */
443 AMREX_GPU_DEVICE
444 AMREX_FORCE_INLINE
445 amrex::Real
446 ComputeQKESourceTerms (int i, int j, int k,
447  const amrex::Array4<const amrex::Real>& uvel,
448  const amrex::Array4<const amrex::Real>& vvel,
449  const amrex::Array4<const amrex::Real>& cell_data,
450  const amrex::Array4<const amrex::Real>& cell_prim,
451  const amrex::Array4<const amrex::Real>& K_turb,
452  const amrex::Box& domain,
453  const PBLDerivativeDzInv dz_inv,
454  amrex::Real pbl_mynn_B1_l,
455  const amrex::Real theta_mean,
456  const MoistureComponentIndices& moisture_indices,
457  bool c_ext_dir_on_zlo,
458  bool c_ext_dir_on_zhi,
459  bool u_ext_dir_on_zlo,
460  bool u_ext_dir_on_zhi,
461  bool v_ext_dir_on_zlo,
462  bool v_ext_dir_on_zhi,
463  const amrex::Array4<const amrex::Real>& tau13,
464  const amrex::Array4<const amrex::Real>& tau23,
465  const amrex::Array4<const amrex::Real>& hfx_z,
466  const amrex::Array4<const amrex::Real>& qfx1_z,
467  bool surface_layer_on_zlo,
468  const similarity_funs& sfuns)
469 {
470  amrex::Real source_term = zero;
471 
472  int izmin = domain.smallEnd(2);
473  int izmax = domain.bigEnd(2);
474 
475  const amrex::Real rho = cell_data(i,j,k,Rho_comp);
476 
477  // Notes:
478  // - We transport TKE = myhalf*QKE rather than QKE, so the RHS terms do not
479  // have a factor of two.
480  // - Transport terms due to turbulence and pressure are included when
481  // DiffusionSrcForState_* is called from ERF_slow_rhs_post.
482  // - Eddy diffusivities are updated at the beginning of each time step only.
483 
484  const bool use_surface_fluxes = ( surface_layer_on_zlo && (k == izmin) &&
485  tau13 && tau23 && hfx_z );
486 
487  if (use_surface_fluxes)
488  {
489  // The first cell center lies inside the unresolved surface layer. With
490  // zlo.type = surface_layer the state carries foextrap and the velocities
491  // hoextrap at the lower boundary, so the stencil used below reads ghost
492  // values that hold no surface information: the resolved gradients there
493  // are not a discretization of anything (ERF #4037). Build the production
494  // terms from the fluxes the model actually carries instead:
495  //
496  // tau13, tau23 = rho<u'w'>, rho<v'w'> (z-faces, staggered in x,y)
497  // hfx_z, qfx1_z = rho<w'theta'>, rho<w'qv'> (z-faces)
498  //
499  // Two different heights are wanted here, so the two are kept apart:
500  // - u_*, thetav_* and L are surface-layer parameters and have no
501  // cell-centered counterpart, so they come from the zlo face alone;
502  // - the production terms belong at the cell center, so their flux
503  // factors average the two z-faces bounding this cell.
504  // Only the profile shape, phi(zeta_1)/(kappa z_1), ties the two together.
505 
506  const amrex::Real theta = cell_data(i,j,k,RhoTheta_comp) / rho;
507  const amrex::Real qv = (moisture_indices.qv >= 0) ?
508  cell_data(i,j,k,moisture_indices.qv) / rho : zero;
509 
510  // ---- Surface-layer parameters, on the zlo face ----
511 
512  // |tau|/rho = u_*^2
513  const amrex::Real t13_s = myhalf * ( tau13(i,j,k) + tau13(i+1,j,k) );
514  const amrex::Real t23_s = myhalf * ( tau23(i,j,k) + tau23(i,j+1,k) );
515  const amrex::Real tau_s = std::sqrt(t13_s*t13_s + t23_s*t23_s);
516  const amrex::Real ustar2 = tau_s / rho;
517  const amrex::Real ustar = std::sqrt(ustar2);
518 
519  // Surface virtual heat flux rho<w'theta_v'> (Stull Eqn. 4.4.5d)
520  amrex::Real hfxv_s = hfx_z(i,j,k) * (one + epsv*qv);
521  if (qfx1_z) { hfxv_s += epsv * theta * qfx1_z(i,j,k); }
522 
523  // Height of this cell center above the surface. dz_inv.dirichlet_lo is by
524  // construction the inverse of the boundary-to-first-center distance, so it
525  // carries the right height for uniform, stretched and terrain-fitted grids.
526  const amrex::Real z1 = one / dz_inv.dirichlet_lo;
527 
528  // Obukhov length, from the surface fluxes. A vanishing stress (a building
529  // face, say) leaves the shear production zero whatever zeta is, so the
530  // neutral value is the safe one to carry into phi_m there.
531  const amrex::Real thetav = theta * (one + epsv*qv);
532  const amrex::Real eps = std::numeric_limits<amrex::Real>::epsilon();
533  amrex::Real zeta = zero;
534  if (std::abs(hfxv_s) > eps && ustar > eps) {
535  const amrex::Real l_obukhov = -( thetav * rho * ustar2 * ustar )
536  / ( KAPPA * CONST_GRAV * hfxv_s );
537  zeta = z1 / l_obukhov;
538  }
539 
540  // phi_m, the companion of the psi_m that SurfaceLayer uses (sfuns: most.stable_functions)
541  const amrex::Real phi_m = sfuns.calc_phi_m(zeta);
542 
543  // ---- Production terms, at the cell center ----
544 
545  // Cell-centered stress: average the two z-faces bounding this cell
546  const amrex::Real t13_c = fourth * ( tau13(i,j,k ) + tau13(i+1,j,k )
547  + tau13(i,j,k+1) + tau13(i+1,j,k+1) );
548  const amrex::Real t23_c = fourth * ( tau23(i,j ,k) + tau23(i,j ,k+1)
549  + tau23(i,j+1,k) + tau23(i,j+1,k+1) );
550 
551  // Cell-centered virtual heat flux. Both faces are from this stage: the
552  // QKE sources are added after RhoQ1 is diffused (see AddTurbKESources).
553  amrex::Real hfxv_c = myhalf * ( hfx_z(i,j,k) + hfx_z(i,j,k+1) ) * (one + epsv*qv);
554  if (qfx1_z) {
555  hfxv_c += epsv * theta * myhalf * ( qfx1_z(i,j,k) + qfx1_z(i,j,k+1) );
556  }
557 
558  // Shear production, -<u'w'> dU/dz - <v'w'> dV/dz. MOST sets the direction
559  // of the mean shear anti-parallel to the surface stress and its magnitude
560  // to u_* phi_m/(kappa z_1), so the dot product is the cell-centered stress
561  // projected onto the surface stress. This reduces to |tau| u_* phi_m /
562  // (kappa z_1) when the stress does not turn across the cell.
563  if (tau_s > eps) {
564  const amrex::Real tau_proj = (t13_c*t13_s + t23_c*t23_s) / tau_s;
565  source_term += std::max(tau_proj,amrex::Real(0.)) * ustar * phi_m / (KAPPA * z1);
566  }
567 
568  // Buoyancy production, which needs no gradient at all
569  source_term += (CONST_GRAV/theta_mean) * hfxv_c;
570  }
571  else
572  {
573  // Compute some relevant derivatives
574  amrex::Real dthetadz, dudz, dvdz;
576  uvel, vvel, cell_data, izmin, izmax, dz_inv,
577  c_ext_dir_on_zlo, c_ext_dir_on_zhi,
578  u_ext_dir_on_zlo, u_ext_dir_on_zhi,
579  v_ext_dir_on_zlo, v_ext_dir_on_zhi,
580  dthetadz, dudz, dvdz,
581  moisture_indices);
582 
583  // Second-order turbulent fluxes, e.g.:
584  // -<uw> = L q SM dU/dz (NN09, Eqn. 18)
585  // = Kmv/rho dU/dz
586 
587  // Shear Production
588  source_term += K_turb(i,j,k,EddyDiff::Mom_v) * (dudz*dudz + dvdz*dvdz);
589 
590  // Buoyancy Production
591  source_term -= (CONST_GRAV/theta_mean)*K_turb(i,j,k,EddyDiff::Theta_v)*dthetadz;
592  }
593 
594  // Dissipation (NN09, Eqn. 12)
595  amrex::Real qke = two * cell_prim(i,j,k,PrimKE_comp);
596  if (std::abs(qke) > zero) {
597  source_term -= rho * std::pow(qke,amrex::Real(1.5)) /
598  (pbl_mynn_B1_l * K_turb(i,j,k,EddyDiff::Turb_lengthscale));
599  }
600 
601  return source_term;
602 }
603 
604 /**
605  * @brief Functor for inverse vertical spacings with constant grid spacing.
606  */
608 {
609  amrex::Real value;
610 
611  /**
612  * Return inverse vertical spacings for constant grid spacing.
613  * @return PBLDerivativeDzInv inverse spacing values
614  */
615  AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
616  PBLDerivativeDzInv operator() (int, int, int) const noexcept
617  {
618  return {myhalf*value, two*value, two*value};
619  }
620 };
621 
622 /**
623  * @brief Functor for inverse vertical spacings for stretched grids using a spacing array.
624  */
626 {
627  const amrex::Real* dz;
628  int klo;
629  int khi;
630 
631  /**
632  * Return inverse vertical spacings for stretched grids.
633  * @param k z-index
634  * @return PBLDerivativeDzInv inverse spacing values
635  */
636  AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
637  PBLDerivativeDzInv operator() (int, int, int k) const noexcept
638  {
639  // Adjacent cell centers are separated by half the sum of their widths.
640  const amrex::Real dz_lo = dz[(k > klo) ? k-1 : k];
641  const amrex::Real dz_hi = dz[(k < khi) ? k+1 : k];
642  return {two / (dz_lo + two*dz[k] + dz_hi),
643  two / dz[k],
644  two / dz[k]};
645  }
646 };
647 
648 /**
649  * @brief Functor for inverse vertical spacings for terrain-following grids using cell-center heights.
650  */
652 {
653  amrex::Array4<const amrex::Real> z_cc;
654 
655  /**
656  * Return inverse vertical spacings for terrain-following grids.
657  * @param i x-index
658  * @param j y-index
659  * @param k z-index
660  * @return PBLDerivativeDzInv inverse spacing values
661  */
662  AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
663  PBLDerivativeDzInv operator() (int i, int j, int k) const noexcept
664  {
665  return {one / (z_cc(i,j,k+1) - z_cc(i,j,k-1)),
666  two / (z_cc(i,j,k ) - z_cc(i,j,k-1)),
667  two / (z_cc(i,j,k+1) - z_cc(i,j,k ))};
668  }
669 };
670 
671 /**
672  * @brief Apply spatial smoothing to PBLH field using 5-point stencil.
673  *
674  * Applies a simple 5-point spatial averaging to reduce grid-to-grid noise in
675  * the diagnosed PBLH field. This is standard post-processing practice for
676  * discrete Rib-crossing detection as described in Seibert et al. (2000):
677  * "Review and intercomparison of operational methods for the determination of
678  * the mixing height", Atmospheric Environment, 34, 1001-1027.
679  *
680  * Stencil: PBLH_smooth(i,j) = w * PBLH(i,j) + (1-w)/4 * [PBLH(i+-1,j) + PBLH(i,j+-1)]
681  *
682  * The stencil reads one column outside the region it writes, so the result on a
683  * cell depends on columns that a single tile -- or a single box -- does not own.
684  * The caller therefore names the region it wants smoothed (xybx_valid, normally
685  * the planar tile box) inside a work array carrying `passes` columns of halo
686  * around it, filled from the same inputs. Pass p writes the region grown by
687  * passes-1-p and reads the one grown by passes-p, so each pass consumes one
688  * column of halo and the last lands exactly on xybx_valid. Every read stays
689  * inside the array, and the result does not depend on how the domain is divided
690  * into boxes or tiles.
691  *
692  * At a non-periodic domain edge there is no column to read, so the stencil reuses
693  * the cell's own value (reflective/Neumann). Across a periodic edge the halo holds
694  * the wrapped columns and is read directly, which is why the periodicity has to be
695  * passed in: clamping there would fold an edge into a domain that has none.
696  *
697  * @param[in,out] pblh_fab FArrayBox holding the 2D PBLH field (component 0),
698  * sized to contain xybx_valid grown by `passes` in x and y
699  * @param[in] xybx_valid Region to smooth (x,y indices only)
700  * @param[in] weight Center cell weight in stencil (must be in [0,1])
701  * @param[in] passes Number of smoothing iterations
702  * @param[in] domain Domain box, for the reflective edge condition
703  * @param[in] periodicity Domain periodicity, so periodic edges read the halo
704  */
705 inline void
706 ApplyPBLHSmoothing (amrex::FArrayBox& pblh_fab,
707  const amrex::Box& xybx_valid,
708  const amrex::Real weight,
709  const int passes,
710  const amrex::Box& domain,
711  const amrex::Periodicity& periodicity)
712 {
713  if (passes <= 0) { return; }
714 
715  // The caller must supply the halo the passes will consume; see the note above.
717  pblh_fab.box().contains(amrex::grow(xybx_valid, amrex::IntVect(passes,passes,0))),
718  "ApplyPBLHSmoothing: the PBLH work array needs `passes` columns of halo "
719  "around the region being smoothed");
720 
721  // Use a temporary to hold intermediate results
722  amrex::FArrayBox pblh_temp(pblh_fab.box(), 1, amrex::The_Async_Arena());
723  auto pblh = pblh_fab.array();
724  auto pblh_tmp = pblh_temp.array();
725 
726  const auto& dom_lo = amrex::lbound(domain);
727  const auto& dom_hi = amrex::ubound(domain);
728 
729  const bool per_x = periodicity.isPeriodic(0);
730  const bool per_y = periodicity.isPeriodic(1);
731 
732  const amrex::Real wt_side = (one - weight) / four; // Weight for each of 4 neighbors
733 
734  // Apply smoothing passes
735  for (int pass = 0; pass < passes; ++pass) {
736  const int halo = passes - 1 - pass;
737  const amrex::Box bx = amrex::grow(xybx_valid, amrex::IntVect(halo,halo,0));
738 
739  amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int) noexcept
740  {
741  // Reflective (Neumann) at a non-periodic domain edge: reuse the cell's
742  // own value. Everywhere else -- including across a periodic edge, where
743  // the halo holds the wrapped column -- read the neighbor.
744  const int i_xlo = (per_x || i > dom_lo.x) ? (i - 1) : i;
745  const int i_xhi = (per_x || i < dom_hi.x) ? (i + 1) : i;
746  const int j_ylo = (per_y || j > dom_lo.y) ? (j - 1) : j;
747  const int j_yhi = (per_y || j < dom_hi.y) ? (j + 1) : j;
748 
749  // 5-point stencil
750  pblh_tmp(i, j, 0) = weight * pblh(i, j, 0)
751  + wt_side * (pblh(i_xlo, j, 0) + pblh(i_xhi, j, 0) +
752  pblh(i, j_ylo, 0) + pblh(i, j_yhi, 0));
753  });
754 
755  // Copy back only what this pass computed: outside bx the array still holds
756  // the previous pass, which no later pass reads.
757  pblh_fab.copy<amrex::RunOn::Device>(pblh_temp, bx, 0, bx, 0, 1);
758  }
759 }
760 
761 
762 /**
763  * Copy of a field read by the PBLH passes, widened to `ng` horizontal ghost cells.
764  *
765  * With erf.pblh_smoothing_passes = n the PBLH passes read their inputs n columns outside
766  * the tile (see ApplyPBLHSmoothing), but some of those inputs carry fewer ghost cells: the
767  * surface-layer fields have one on the bottom surface. The PBL schemes read such fields
768  * from a copy made here instead.
769  *
770  * The valid cells and the field's own ghost cells are copied unchanged, so a run that
771  * needs no more halo than the field has gives the same answer as reading the field
772  * itself. `fill` then fills the new ghost cells that a box of the level covers, inside
773  * the domain or across a periodic edge, the same way the field's owner fills its own
774  * (for a surface-layer field, SurfaceLayer::fill_planar_boundary). Ghost cells no box
775  * covers -- outside a non-periodic domain edge, or next to a coarser level -- take the
776  * value of the nearest cell of the field's original halo. The smoothing never reads a
777  * column outside a non-periodic edge; next to a coarser level this is a zeroth-order
778  * extrapolation of the surface scales, while the state there is the interpolated one.
779  *
780  * @param[in] src Field to widen
781  * @param[in] ng Ghost cells wanted in x and y; z keeps those of src
782  * @param[in] fill Callable taking the widened MultiFab& and filling its ghost cells
783  * from the valid cells of the other boxes of the level
784  *
785  * `fill` is a std::function, not a template parameter: nvcc does not accept the device
786  * lambda below inside a function template instantiated with a lambda local to the caller.
787  */
788 inline std::unique_ptr<amrex::MultiFab>
789 WidenForPBLH (const amrex::MultiFab& src, const int ng,
790  const std::function<void(amrex::MultiFab&)>& fill)
791 {
792  const amrex::IntVect ng_src = src.nGrowVect();
793  const amrex::IntVect ng_dst(ng, ng, ng_src[2]);
794  const int ncomp = src.nComp();
795 
796  // A value no field holds, marking the cells nothing below fills
797  constexpr amrex::Real unset = std::numeric_limits<amrex::Real>::max();
798 
799  auto dst = std::make_unique<amrex::MultiFab>(src.boxArray(), src.DistributionMap(),
800  ncomp, ng_dst);
801  dst->setVal(unset);
802  amrex::MultiFab::Copy(*dst, src, 0, 0, ncomp, ng_src);
803  fill(*dst);
804 
805  for (amrex::MFIter mfi(*dst); mfi.isValid(); ++mfi) {
806  // The cells holding src's own data; never written below, so they can be read
807  const amrex::Box have = amrex::grow(mfi.validbox(), ng_src);
808  const auto lo = amrex::lbound(have);
809  const auto hi = amrex::ubound(have);
810  auto a = dst->array(mfi);
811  amrex::ParallelFor(mfi.fabbox(), [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
812  {
813  if (have.contains(i, j, k)) { return; }
814  const int ic = amrex::min(amrex::max(i, lo.x), hi.x);
815  const int jc = amrex::min(amrex::max(j, lo.y), hi.y);
816  for (int n = 0; n < ncomp; ++n) {
817  if (a(i, j, k, n) == unset) { a(i, j, k, n) = a(ic, jc, k, n); }
818  }
819  });
820  }
821  return dst;
822 }
823 
824 #endif
constexpr amrex::Real epsv
Definition: ERF_Constants.H:56
constexpr amrex::Real KAPPA
Definition: ERF_Constants.H:71
constexpr amrex::Real CONST_GRAV
Definition: ERF_Constants.H:72
@ tau23
Definition: ERF_DataStruct.H:51
@ tau13
Definition: ERF_DataStruct.H:51
#define Rho_comp
Definition: ERF_IndexDefines.H:61
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:62
#define PrimKE_comp
Definition: ERF_IndexDefines.H:92
const bool use_moisture
Definition: ERF_InitCustomPert_ABL.H:127
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(axis >=0 &&axis< AMREX_SPACEDIM, "prob.axis must be 0, 1 or 2")
for(int i=0;i< m_num_species;i++)
Definition: ERF_InitCustomPert_MultiSpeciesBubble.H:52
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real GetThetav(const int &i, const int &j, const int &k, const amrex::Array4< amrex::Real const > &cell_data, const MoistureComponentIndices &moisture_indices)
Definition: ERF_MoistUtils.H:93
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real GetThetal(const int &i, const int &j, const int &k, const amrex::Array4< amrex::Real const > &cell_data, const MoistureComponentIndices &moisture_indices)
Definition: ERF_MoistUtils.H:127
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 four
Definition: ERF_NumericalConstants.H:40
constexpr amrex::Real two
Definition: ERF_NumericalConstants.H:38
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:37
constexpr amrex::Real fourth
Definition: ERF_NumericalConstants.H:42
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:36
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:41
std::unique_ptr< amrex::MultiFab > WidenForPBLH(const amrex::MultiFab &src, const int ng, const std::function< void(amrex::MultiFab &)> &fill)
Definition: ERF_PBLModels.H:789
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real GetPBLStratVar(int i, int j, int k, const StratType strat, const amrex::Array4< const amrex::Real > &cell_data, const MoistureComponentIndices &moisture_indices)
Definition: ERF_PBLModels.H:275
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void ComputeVerticalDerivativesPBL(int i, int j, int k, const amrex::Array4< const amrex::Real > &uvel, const amrex::Array4< const amrex::Real > &vvel, const amrex::Array4< const amrex::Real > &cell_data, const int izmin, const int izmax, const PBLDerivativeDzInv &dz_inv, const bool c_ext_dir_on_zlo, const bool c_ext_dir_on_zhi, const bool u_ext_dir_on_zlo, const bool u_ext_dir_on_zhi, const bool v_ext_dir_on_zlo, const bool v_ext_dir_on_zhi, amrex::Real &dthetadz, amrex::Real &dudz, amrex::Real &dvdz, const MoistureComponentIndices &moisture_indices, const StratType strat=StratType::thetav)
Definition: ERF_PBLModels.H:291
void ComputeDiffusivityMYNN25(const amrex::MultiFab &xvel, const amrex::MultiFab &yvel, const amrex::MultiFab &cons_in, amrex::MultiFab &eddyViscosity, const amrex::Geometry &geom, const TurbChoice &turbChoice, std::unique_ptr< SurfaceLayer > &SurfLayer, bool use_terrain_fitted_coords, bool use_moisture, int level, const amrex::BCRec *bc_ptr, bool, const std::unique_ptr< amrex::MultiFab > &z_phys_nd, const std::unique_ptr< amrex::MultiFab > &z_sfc_nd, const std::unique_ptr< amrex::MultiFab > &z_phys_cc, const MoistureComponentIndices &moisture_indices)
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real ComputeQKESourceTerms(int i, int j, int k, const amrex::Array4< const amrex::Real > &uvel, const amrex::Array4< const amrex::Real > &vvel, const amrex::Array4< const amrex::Real > &cell_data, const amrex::Array4< const amrex::Real > &cell_prim, const amrex::Array4< const amrex::Real > &K_turb, const amrex::Box &domain, const PBLDerivativeDzInv dz_inv, amrex::Real pbl_mynn_B1_l, const amrex::Real theta_mean, const MoistureComponentIndices &moisture_indices, bool c_ext_dir_on_zlo, bool c_ext_dir_on_zhi, bool u_ext_dir_on_zlo, bool u_ext_dir_on_zhi, bool v_ext_dir_on_zlo, bool v_ext_dir_on_zhi, const amrex::Array4< const amrex::Real > &tau13, const amrex::Array4< const amrex::Real > &tau23, const amrex::Array4< const amrex::Real > &hfx_z, const amrex::Array4< const amrex::Real > &qfx1_z, bool surface_layer_on_zlo, const similarity_funs &sfuns)
Definition: ERF_PBLModels.H:446
void ComputeDiffusivityYSU(const amrex::MultiFab &xvel, const amrex::MultiFab &yvel, const amrex::MultiFab &cons_in, amrex::MultiFab &eddyViscosity, const amrex::Geometry &geom, const TurbChoice &turbChoice, std::unique_ptr< SurfaceLayer > &SurfLayer, bool use_terrain_fitted_coords, bool use_moisture, int level, const amrex::BCRec *bc_ptr, bool, const std::unique_ptr< amrex::MultiFab > &z_phys_nd, const std::unique_ptr< amrex::MultiFab > &z_sfc_nd, const std::unique_ptr< amrex::MultiFab > &z_phys_cc, const MoistureComponentIndices &moisture_indices, const amrex::MultiFab *qheating_rates=nullptr, const amrex::MultiFab *terrain_blank=nullptr)
void ComputeDiffusivityMRF(const amrex::MultiFab &xvel, const amrex::MultiFab &yvel, const amrex::MultiFab &cons_in, amrex::MultiFab &eddyViscosity, const amrex::Geometry &geom, const TurbChoice &turbChoice, std::unique_ptr< SurfaceLayer > &SurfLayer, bool use_terrain_fitted_coords, bool use_moisture, int level, const amrex::BCRec *bc_ptr, bool, const std::unique_ptr< amrex::MultiFab > &z_phys_nd, const std::unique_ptr< amrex::MultiFab > &z_sfc_nd, const std::unique_ptr< amrex::MultiFab > &z_phys_cc, const MoistureComponentIndices &moisture_indices, const amrex::MultiFab *terrain_blank=nullptr, const amrex::MultiFab *Q_fire_atm=nullptr, amrex::GpuArray< const amrex::MultiFab *, 2 > mf_m={{nullptr, nullptr}})
void ApplyPBLHSmoothing(amrex::FArrayBox &pblh_fab, const amrex::Box &xybx_valid, const amrex::Real weight, const int passes, const amrex::Box &domain, const amrex::Periodicity &periodicity)
Apply spatial smoothing to PBLH field using 5-point stencil.
Definition: ERF_PBLModels.H:706
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void ApplySurfaceLayerGradientsPBL(const PBLSurfaceLayerGradient &sl, amrex::Real &dthetadz, amrex::Real &dudz, amrex::Real &dvdz)
Definition: ERF_PBLModels.H:411
void ComputeDiffusivityMYJ(double dt, const amrex::MultiFab &xvel, const amrex::MultiFab &yvel, amrex::MultiFab &cons_in, amrex::MultiFab &eddyViscosity, const amrex::Geometry &geom, const TurbChoice &turbChoice, std::unique_ptr< SurfaceLayer > &SurfLayer, bool use_terrain_fitted_coords, bool use_moisture, int level, const amrex::BCRec *bc_ptr, bool, const std::unique_ptr< amrex::MultiFab > &z_phys_nd, const std::unique_ptr< amrex::MultiFab > &z_sfc_nd, const std::unique_ptr< amrex::MultiFab > &z_phys_cc, const MoistureComponentIndices &moisture_indices)
void ComputeDiffusivityMYNNEDMF(const amrex::MultiFab &xvel, const amrex::MultiFab &yvel, const amrex::MultiFab &cons_in, amrex::MultiFab &eddyViscosity, const amrex::Geometry &geom, const TurbChoice &turbChoice, std::unique_ptr< SurfaceLayer > &SurfLayer, bool use_terrain_fitted_coords, bool use_moisture, int level, const amrex::BCRec *bc_ptr, bool, const std::unique_ptr< amrex::MultiFab > &z_phys_nd, const std::unique_ptr< amrex::MultiFab > &z_sfc_nd, const std::unique_ptr< amrex::MultiFab > &z_phys_cc, const MoistureComponentIndices &moisture_indices)
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real ComputeVirtualTStarPBL(amrex::Real t_star, amrex::Real q_star, amrex::Real theta, amrex::Real qv, bool use_moisture)
Definition: ERF_PBLModels.H:374
@ Theta_v
Definition: ERF_IndexDefines.H:267
@ Turb_lengthscale
Definition: ERF_IndexDefines.H:271
@ Mom_v
Definition: ERF_IndexDefines.H:266
@ ustar
Definition: ERF_SLM.H:30
@ rho
Definition: ERF_Kessler.H:25
@ theta
Definition: ERF_Kessler.H:26
@ qv
Definition: ERF_Kessler.H:31
@ ng
Definition: ERF_Morrison.H:51
@ xvel
Definition: ERF_IndexDefines.H:232
@ yvel
Definition: ERF_IndexDefines.H:233
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real eps()
Definition: ERF_ShocMoments.cpp:19
real(c_double), parameter epsilon
Definition: ERF_module_model_constants.F90:12
void fill(MultiFab &dst, int temperature_comp, int mixing_ratio_comp, int source_comp, const Sources &sources, Real missing_value)
Definition: ERF_NearSurfaceDiagnostics.cpp:42
The moisture data carried by the active microphysics scheme.
Definition: ERF_DataStruct.H:279
int qv
water vapor
Definition: ERF_DataStruct.H:290
Functor for inverse vertical spacings with constant grid spacing.
Definition: ERF_PBLModels.H:608
amrex::Real value
Definition: ERF_PBLModels.H:609
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE PBLDerivativeDzInv operator()(int, int, int) const noexcept
Definition: ERF_PBLModels.H:616
Functor for inverse vertical spacings for stretched grids using a spacing array.
Definition: ERF_PBLModels.H:626
const amrex::Real * dz
Definition: ERF_PBLModels.H:627
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE PBLDerivativeDzInv operator()(int, int, int k) const noexcept
Definition: ERF_PBLModels.H:637
int klo
Definition: ERF_PBLModels.H:628
int khi
Definition: ERF_PBLModels.H:629
Functor for inverse vertical spacings for terrain-following grids using cell-center heights.
Definition: ERF_PBLModels.H:652
amrex::Array4< const amrex::Real > z_cc
Definition: ERF_PBLModels.H:653
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE PBLDerivativeDzInv operator()(int i, int j, int k) const noexcept
Definition: ERF_PBLModels.H:663
Definition: ERF_PBLModels.H:235
amrex::Real dirichlet_hi
Definition: ERF_PBLModels.H:240
amrex::Real interior
Definition: ERF_PBLModels.H:238
amrex::Real dirichlet_lo
Definition: ERF_PBLModels.H:239
Definition: ERF_PBLModels.H:353
amrex::Real tstar_v
virtual temperature scale
Definition: ERF_PBLModels.H:355
amrex::Real zeta
stability coordinate z/L
Definition: ERF_PBLModels.H:357
similarity_funs sfuns
the surface layer's similarity functions (most.stable_functions)
Definition: ERF_PBLModels.H:358
amrex::Real u_star
friction velocity
Definition: ERF_PBLModels.H:354
amrex::Real zval
height of the cell center above the surface
Definition: ERF_PBLModels.H:356
Definition: ERF_TurbStruct.H:129
Definition: ERF_MOSTUtils.H:84
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real calc_phi_h(amrex::Real zeta) const
Definition: ERF_MOSTUtils.H:219
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real calc_phi_m(amrex::Real zeta) const
Definition: ERF_MOSTUtils.H:199