1 #ifndef ERF_PBLMODELS_H_
2 #define ERF_PBLMODELS_H_
25 const amrex::MultiFab&
yvel,
26 const amrex::MultiFab& cons_in,
27 amrex::MultiFab& eddyViscosity,
28 const amrex::Geometry& geom,
30 std::unique_ptr<ABLMost>& most,
33 const amrex::BCRec* bc_ptr,
35 const std::unique_ptr<amrex::MultiFab>& z_phys_nd,
38 const int RhoQr_comp);
59 const amrex::MultiFab&
yvel,
60 const amrex::MultiFab& cons_in,
61 amrex::MultiFab& eddyViscosity,
62 const amrex::Geometry& geom,
64 std::unique_ptr<ABLMost>& most,
67 const amrex::BCRec* bc_ptr,
69 const std::unique_ptr<amrex::MultiFab>& z_phys_nd);
83 const amrex::Array4<const amrex::Real>& uvel,
84 const amrex::Array4<const amrex::Real>& vvel,
85 const amrex::Array4<const amrex::Real>& cell_data,
88 const amrex::Real& dz_inv,
89 const bool c_ext_dir_on_zlo,
90 const bool c_ext_dir_on_zhi,
91 const bool u_ext_dir_on_zlo,
92 const bool u_ext_dir_on_zhi,
93 const bool v_ext_dir_on_zlo,
94 const bool v_ext_dir_on_zhi,
95 amrex::Real& dthetadz,
100 const int RhoQr_comp,
101 const bool use_most=
true)
103 if ( k==izmax && c_ext_dir_on_zhi ) {
104 dthetadz = (1.0/3.0)*( -
Thetav(i,j,k-1,cell_data,RhoQv_comp,RhoQc_comp,RhoQr_comp)
105 - 3.0 *
Thetav(i,j,k ,cell_data,RhoQv_comp,RhoQc_comp,RhoQr_comp)
106 + 4.0 *
Thetav(i,j,k+1,cell_data,RhoQv_comp,RhoQc_comp,RhoQr_comp) )*dz_inv;
107 }
else if ( k==izmin && c_ext_dir_on_zlo ) {
108 dthetadz = (1.0/3.0)*(
Thetav(i,j,k+1,cell_data,RhoQv_comp,RhoQc_comp,RhoQr_comp)
109 + 3.0 *
Thetav(i,j,k ,cell_data,RhoQv_comp,RhoQc_comp,RhoQr_comp)
110 - 4.0 *
Thetav(i,j,k-1,cell_data,RhoQv_comp,RhoQc_comp,RhoQr_comp) )*dz_inv;
111 }
else if ( k==izmin && use_most ) {
112 dthetadz = (
Thetav(i,j,k+1,cell_data,RhoQv_comp,RhoQc_comp,RhoQr_comp)
113 -
Thetav(i,j,k ,cell_data,RhoQv_comp,RhoQc_comp,RhoQr_comp) )*dz_inv;
115 dthetadz = 0.5*(
Thetav(i,j,k+1,cell_data,RhoQv_comp,RhoQc_comp,RhoQr_comp)
116 -
Thetav(i,j,k-1,cell_data,RhoQv_comp,RhoQc_comp,RhoQr_comp) )*dz_inv;
119 if ( k==izmax && u_ext_dir_on_zhi ) {
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 && u_ext_dir_on_zlo ) {
123 dudz = (1.0/6.0)*( (uvel(i ,j,k+1) + 3.0 * uvel(i ,j,k ) - 4.0 * uvel(i ,j,k-1))
124 + (uvel(i+1,j,k+1) + 3.0 * uvel(i+1,j,k ) - 4.0 * uvel(i+1,j,k-1)) )*dz_inv;
125 }
else if ( k==izmin && use_most ) {
126 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;
128 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;
131 if ( k==izmax && v_ext_dir_on_zhi ) {
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 && v_ext_dir_on_zlo ) {
135 dvdz = (1.0/6.0)*( (vvel(i,j ,k+1) + 3.0 * vvel(i,j ,k ) - 4.0 * vvel(i,j ,k-1))
136 + (vvel(i,j+1,k+1) + 3.0 * vvel(i,j+1,k ) - 4.0 * vvel(i,j+1,k-1)) )*dz_inv;
137 }
else if ( k==izmin && use_most ) {
138 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;
140 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;
161 const amrex::Array4<const amrex::Real>& uvel,
162 const amrex::Array4<const amrex::Real>& vvel,
163 const amrex::Array4<const amrex::Real>& cell_data,
164 const amrex::Array4<const amrex::Real>& cell_prim,
165 const amrex::Array4<const amrex::Real>& K_turb,
166 const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM>& cellSizeInv,
167 const amrex::Box& domain,
168 amrex::Real pbl_mynn_B1_l,
169 const amrex::Real theta_mean,
170 const int RhoQv_comp,
171 const int RhoQc_comp,
172 const int RhoQr_comp,
173 bool c_ext_dir_on_zlo,
174 bool c_ext_dir_on_zhi,
175 bool u_ext_dir_on_zlo,
176 bool u_ext_dir_on_zhi,
177 bool v_ext_dir_on_zlo,
178 bool v_ext_dir_on_zhi,
179 const bool use_most=
false,
180 const amrex::Real met_h_zeta=1.0)
183 amrex::Real dthetadz, dudz, dvdz;
184 amrex::Real source_term = 0.0;
186 amrex::Real dz_inv = cellSizeInv[2];
187 int izmin = domain.smallEnd(2);
188 int izmax = domain.bigEnd(2);
197 uvel, vvel, cell_data, izmin, izmax, dz_inv/met_h_zeta,
198 c_ext_dir_on_zlo, c_ext_dir_on_zhi,
199 u_ext_dir_on_zlo, u_ext_dir_on_zhi,
200 v_ext_dir_on_zlo, v_ext_dir_on_zhi,
201 dthetadz, dudz, dvdz,
202 RhoQv_comp, RhoQc_comp, RhoQr_comp, use_most);
208 source_term += K_turb(i,j,k,
EddyDiff::Mom_v) * (dudz*dudz + dvdz*dvdz);
214 amrex::Real qke = 2.0 * cell_prim(i,j,k,
PrimKE_comp);
215 if (std::abs(qke) > 0.0) {
216 source_term -= cell_data(i,j,k,
Rho_comp) * std::pow(qke,1.5) /
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 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 RhoQc_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)
Definition: ERF_PBLModels.H:160
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 RhoQc_comp, const int RhoQr_comp, const bool use_most=true)
Definition: ERF_PBLModels.H:82
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)
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 RhoQc_comp, const int RhoQr_comp)
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 RhoQc_comp, const int RhoQr_comp)
Definition: ERF_Thetav.H:10
@ Theta_v
Definition: ERF_IndexDefines.H:157
@ Turb_lengthscale
Definition: ERF_IndexDefines.H:161
@ Mom_v
Definition: ERF_IndexDefines.H:156
@ xvel
Definition: ERF_IndexDefines.H:130
@ yvel
Definition: ERF_IndexDefines.H:131
Definition: ERF_TurbStruct.H:31