ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_PBLModels.H File Reference
#include <ERF_Thetav.H>
Include dependency graph for ERF_PBLModels.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

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< ABLMost > &most, bool use_moisture, int level, const amrex::BCRec *bc_ptr, bool, const std::unique_ptr< amrex::MultiFab > &z_phys_nd, const int RhoQv_comp, const int RhoQr_comp)
 
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< ABLMost > &most, bool use_moisture, int level, const amrex::BCRec *bc_ptr, bool, const std::unique_ptr< amrex::MultiFab > &z_phys_nd)
 
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 amrex::Real &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 int RhoQv_comp, const int RhoQr_comp, const bool use_most=true)
 
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::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Box &domain, amrex::Real pbl_mynn_B1_l, const amrex::Real theta_mean, const int RhoQv_comp, const int RhoQr_comp, 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 bool use_most=false, const amrex::Real met_h_zeta=1.0)
 

Function Documentation

◆ ComputeDiffusivityMYNN25()

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< ABLMost > &  most,
bool  use_moisture,
int  level,
const amrex::BCRec *  bc_ptr,
bool  ,
const std::unique_ptr< amrex::MultiFab > &  z_phys_nd,
const int  RhoQv_comp,
const int  RhoQr_comp 
)

Compute eddy diffusivities of momentum (eddy viscosity) and heat using the Mellor-Yamada-Nakanishi-Niino Level 2.5 PBL scheme

Parameters
[in]xvelVelocity in x-dir
[in]yvelVelocity in y-dir
[in]cons_inCell center conserved quantities
[out]eddyViscosityHolds turbulent viscosity
[in]geomProblem geometry
[in]turbChoiceContainer with turbulence parameters
[in]mostPointer to Monin-Obukhov class if instantiated
[in]use_moistureIf we have microphysics enabled
[in]levelCurrent level
[in]bc_ptrPointer to array with boundary condition info
[in]vert_onlyOnly compute vertical eddy diffusivities
[in]z_phys_ndPhysical location of grid nodes, if terrain (or grid stretching) is enabled

◆ ComputeDiffusivityYSU()

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< ABLMost > &  most,
bool  use_moisture,
int  level,
const amrex::BCRec *  bc_ptr,
bool  ,
const std::unique_ptr< amrex::MultiFab > &  z_phys_nd 
)

Compute eddy diffusivities of momentum (eddy viscosity) and heat using the Yonsei University PBL scheme

Parameters
[in]xvelVelocity in x-dir
[in]yvelVelocity in y-dir
[in]cons_inCell center conserved quantities
[out]eddyViscosityHolds turbulent viscosity
[in]geomProblem geometry
[in]turbChoiceContainer with turbulence parameters
[in]mostPointer to Monin-Obukhov class if instantiated
[in]use_moistureIf we have microphysics enabled
[in]levelCurrent level
[in]bc_ptrPointer to array with boundary condition info
[in]vert_onlyOnly compute vertical eddy diffusivities
[in]z_phys_ndPhysical location of grid nodes, if terrain (or grid stretching) is enabled

◆ ComputeQKESourceTerms()

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::GpuArray< amrex::Real, AMREX_SPACEDIM > &  cellSizeInv,
const amrex::Box &  domain,
amrex::Real  pbl_mynn_B1_l,
const amrex::Real  theta_mean,
const int  RhoQv_comp,
const int  RhoQr_comp,
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 bool  use_most = false,
const amrex::Real  met_h_zeta = 1.0 
)

Function for computing the QKE source terms (NN09, Eqn. 5).

Parameters
[in]uvelocity in x-dir
[in]vvelocity in y-dir
[in]cell_dataconserved cell center vars
[in]cell_primprimitive cell center vars
[in]K_turbturbulent viscosity
[in]cellSizeInvinverse cell size array
[in]domainbox of the whole domain
[in]pbl_mynn_B1_la parameter
[in]theta_meanaverage theta
177 {
178  // Compute some relevant derivatives
179  amrex::Real dthetadz, dudz, dvdz;
180  amrex::Real source_term = 0.0;
181 
182  amrex::Real dz_inv = cellSizeInv[2];
183  int izmin = domain.smallEnd(2);
184  int izmax = domain.bigEnd(2);
185 
186  // NOTE: With MOST, the ghost cells are filled AFTER k_turb is computed
187  // so that the non-explicit pathway works. Therefore, at this
188  // point we DO have valid ghost cells from MOST. We are passing
189  // the MOST flag to use one-sided diffs here to be consistent with
190  // the explicit pathway.
191 
193  uvel, vvel, cell_data, izmin, izmax, dz_inv/met_h_zeta,
194  c_ext_dir_on_zlo, c_ext_dir_on_zhi,
195  u_ext_dir_on_zlo, u_ext_dir_on_zhi,
196  v_ext_dir_on_zlo, v_ext_dir_on_zhi,
197  dthetadz, dudz, dvdz,
198  RhoQv_comp, RhoQr_comp, use_most);
199 
200  // Note: Transport terms due to turbulence and pressure are included when
201  // DiffusionSrcForState_* is called from ERF_slow_rhs_post.
202 
203  // Shear Production
204  source_term += K_turb(i,j,k,EddyDiff::Mom_v) * (dudz*dudz + dvdz*dvdz);
205 
206  // Buoyancy Production
207  source_term -= (CONST_GRAV/theta_mean)*K_turb(i,j,k,EddyDiff::Theta_v)*dthetadz;
208 
209  // Dissipation
210  amrex::Real qke = 2.0 * cell_prim(i,j,k,PrimKE_comp);
211  if (std::abs(qke) > 0.0) {
212  source_term -= cell_data(i,j,k,Rho_comp) * std::pow(qke,1.5) /
213  (pbl_mynn_B1_l * K_turb(i,j,k,EddyDiff::Turb_lengthscale));
214  }
215 
216  return source_term;
217 }
constexpr amrex::Real CONST_GRAV
Definition: ERF_Constants.H:21
#define Rho_comp
Definition: ERF_IndexDefines.H:36
#define PrimKE_comp
Definition: ERF_IndexDefines.H:51
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 amrex::Real &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 int RhoQv_comp, const int RhoQr_comp, const bool use_most=true)
Definition: ERF_PBLModels.H:80
@ Theta_v
Definition: ERF_IndexDefines.H:157
@ Turb_lengthscale
Definition: ERF_IndexDefines.H:161
@ Mom_v
Definition: ERF_IndexDefines.H:156

Referenced by DiffusionSrcForState_N(), and DiffusionSrcForState_T().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ComputeVerticalDerivativesPBL()

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 amrex::Real &  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 int  RhoQv_comp,
const int  RhoQr_comp,
const bool  use_most = true 
)

Function for computing vertical derivatives for use in PBL model

Parameters
[in]uvelocity in x-dir
[in]vvelocity in y-dir
[in]cell_dataconserved cell center vars
99 {
100  if ( k==izmax && c_ext_dir_on_zhi ) {
101  dthetadz = (1.0/3.0)*( -Thetav(i,j,k-1,cell_data,RhoQv_comp,RhoQr_comp)
102  - 3.0 * Thetav(i,j,k ,cell_data,RhoQv_comp,RhoQr_comp)
103  + 4.0 * Thetav(i,j,k+1,cell_data,RhoQv_comp,RhoQr_comp) )*dz_inv;
104  } else if ( k==izmin && c_ext_dir_on_zlo ) {
105  dthetadz = (1.0/3.0)*( Thetav(i,j,k+1,cell_data,RhoQv_comp,RhoQr_comp)
106  + 3.0 * Thetav(i,j,k ,cell_data,RhoQv_comp,RhoQr_comp)
107  - 4.0 * Thetav(i,j,k-1,cell_data,RhoQv_comp,RhoQr_comp) )*dz_inv;
108  } else if ( k==izmin && use_most ) {
109  dthetadz = ( Thetav(i,j,k+1,cell_data,RhoQv_comp,RhoQr_comp)
110  - Thetav(i,j,k ,cell_data,RhoQv_comp,RhoQr_comp) )*dz_inv;
111  } else {
112  dthetadz = 0.5*( Thetav(i,j,k+1,cell_data,RhoQv_comp,RhoQr_comp)
113  - Thetav(i,j,k-1,cell_data,RhoQv_comp,RhoQr_comp) )*dz_inv;
114  }
115 
116  if ( k==izmax && u_ext_dir_on_zhi ) {
117  dudz = (1.0/6.0)*( (-uvel(i ,j,k-1) - 3.0 * uvel(i ,j,k ) + 4.0 * uvel(i ,j,k+1))
118  + (-uvel(i+1,j,k-1) - 3.0 * uvel(i+1,j,k ) + 4.0 * uvel(i+1,j,k+1)) )*dz_inv;
119  } else if ( k==izmin && u_ext_dir_on_zlo ) {
120  dudz = (1.0/6.0)*( (uvel(i ,j,k+1) + 3.0 * uvel(i ,j,k ) - 4.0 * uvel(i ,j,k-1))
121  + (uvel(i+1,j,k+1) + 3.0 * uvel(i+1,j,k ) - 4.0 * uvel(i+1,j,k-1)) )*dz_inv;
122  } else if ( k==izmin && use_most ) {
123  dudz = 0.50*( uvel(i,j,k+1) - uvel(i,j,k ) + uvel(i+1,j,k+1) - uvel(i+1,j,k ) )*dz_inv;
124  } else {
125  dudz = 0.25*( uvel(i,j,k+1) - uvel(i,j,k-1) + uvel(i+1,j,k+1) - uvel(i+1,j,k-1) )*dz_inv;
126  }
127 
128  if ( k==izmax && v_ext_dir_on_zhi ) {
129  dvdz = (1.0/6.0)*( (-vvel(i,j ,k-1) - 3.0 * vvel(i,j ,k ) + 4.0 * vvel(i,j ,k+1))
130  + (-vvel(i,j+1,k-1) - 3.0 * vvel(i,j+1,k ) + 4.0 * vvel(i,j+1,k+1)) )*dz_inv;
131  } else if ( k==izmin && v_ext_dir_on_zlo ) {
132  dvdz = (1.0/6.0)*( (vvel(i,j ,k+1) + 3.0 * vvel(i,j ,k ) - 4.0 * vvel(i,j ,k-1))
133  + (vvel(i,j+1,k+1) + 3.0 * vvel(i,j+1,k ) - 4.0 * vvel(i,j+1,k-1)) )*dz_inv;
134  } else if ( k==izmin && use_most ) {
135  dvdz = 0.50*( vvel(i,j,k+1) - vvel(i,j,k ) + vvel(i,j+1,k+1) - vvel(i,j+1,k ) )*dz_inv;
136  } else {
137  dvdz = 0.25*( vvel(i,j,k+1) - vvel(i,j,k-1) + vvel(i,j+1,k+1) - vvel(i,j+1,k-1) )*dz_inv;
138  }
139 }
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Thetav(int i, int j, int k, const amrex::Array4< const amrex::Real > &cell_data, const int RhoQv_comp, const int RhoQr_comp)
Definition: ERF_Thetav.H:10

Referenced by ComputeDiffusivityMYNN25(), ComputeDiffusivityYSU(), and ComputeQKESourceTerms().

Here is the call graph for this function:
Here is the caller graph for this function: