34 int klo = geom.Domain().smallEnd(2);
35 int khi = geom.Domain().bigEnd(2);
38 #pragma omp parallel if (Gpu::notInLaunchRegion())
40 for (MFIter mfi(eddyViscosity,
TileNoZ()); mfi.isValid(); ++mfi) {
43 const Box& gbx = mfi.growntilebox(IntVect(1,1,0));
44 AMREX_ALWAYS_ASSERT( gbx.smallEnd(2) == klo &&
45 gbx.bigEnd(2) == khi );
50 const GeometryData gdata = geom.data();
51 const Box xybx = PerpendicularBox<ZDir>(gbx, IntVect{0, 0, 0});
52 FArrayBox pbl_height_predictor(xybx, 1, The_Async_Arena());
53 FArrayBox pbl_height_corrector(xybx, 1, The_Async_Arena());
54 IArrayBox pbl_index(xybx, 1, The_Async_Arena());
55 const auto& pblh_arr = pbl_height_predictor.array();
56 const auto& pblh_corr_arr = pbl_height_corrector.array();
57 const auto& pbli_arr = pbl_index.array();
60 const auto& cell_data = cons_in.const_array(mfi);
61 const auto& uvel =
xvel.const_array(mfi);
62 const auto& vvel =
yvel.const_array(mfi);
66 const auto& u_star_arr = SurfLayer->get_u_star(level)->const_array(mfi);
67 const auto& t_star_arr = SurfLayer->get_t_star(level)->const_array(mfi);
68 const auto& l_obuk_arr = SurfLayer->get_olen(level)->const_array(mfi);
69 const auto& t10av_arr = SurfLayer->get_mac_avg(level, 2)->const_array(mfi);
70 const auto& t_surf_arr = SurfLayer->get_t_surf(level)->const_array(mfi);
71 const Array4<Real const> z_nd_arr = z_phys_nd->array(mfi);
73 ParallelFor(xybx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int) noexcept
75 const Real t_surf = t_surf_arr(i, j, 0);
76 const Real t_layer = t10av_arr(i, j, 0);
80 bool above_critical =
false;
81 while (!above_critical && ((kpbl + 1) <= khi)) {
85 zval = (use_terrain_fitted_coords)
87 : (kpbl + 0.5) * gdata.CellSize(2);
91 const Real ws2 = 0.25 * ( (uvel(i, j, kpbl) + uvel(i + 1, j, kpbl)) *
92 (uvel(i, j, kpbl) + uvel(i + 1, j, kpbl)) +
93 (vvel(i, j, kpbl) + vvel(i, j + 1, kpbl)) *
94 (vvel(i, j, kpbl) + vvel(i, j + 1, kpbl)) );
96 above_critical = (Rib >= Ribcr);
105 const Real pblh_emp = gdata.ProbLo(2) + 0.5 * gdata.CellSize(2);
106 pblh_arr(i, j, 0) = (above_critical) ? zval : pblh_emp;
107 pbli_arr(i, j, 0) = (above_critical) ? kpbl : klo+1;
113 ParallelFor(xybx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int) noexcept
115 const Real t_layer = t10av_arr(i, j, 0);
116 const Real phiM = (l_obuk_arr(i, j, 0) > 0)
117 ? (1 + 5 * sf * pblh_arr(i, j, 0) / l_obuk_arr(i, j, 0))
119 (1 - 8 * sf * pblh_arr(i, j, 0) / l_obuk_arr(i, j, 0)),
121 const Real wstar = u_star_arr(i, j, 0) / phiM;
122 const Real t_excess = -const_b * u_star_arr(i, j, 0) * t_star_arr(i, j, 0) / wstar;
123 const Real t_surf = t_layer + std::max(std::min(t_excess, 3.0), 0.0);
127 bool above_critical =
false;
128 while (!above_critical && ((kpbl + 1) <= khi)) {
129 zval = (use_terrain_fitted_coords)
131 : gdata.ProbLo(2) + (kpbl + 0.5) * gdata.CellSize(2);
135 const Real ws2 = 0.25 * ( (uvel(i, j, kpbl) + uvel(i + 1, j, kpbl)) *
136 (uvel(i, j, kpbl) + uvel(i + 1, j, kpbl)) +
137 (vvel(i, j, kpbl) + vvel(i, j + 1, kpbl)) *
138 (vvel(i, j, kpbl) + vvel(i, j + 1, kpbl)) );
140 above_critical = (Rib >= Ribcr);
144 const Real pblh_emp = gdata.ProbLo(2) + 0.5 * gdata.CellSize(2);
145 pblh_corr_arr(i, j, 0) = (above_critical) ? zval : pblh_emp;
146 pbli_arr(i, j, 0) = (above_critical) ? kpbl : klo+1;
158 const Array4<Real>& K_turb = eddyViscosity.array(mfi);
168 const auto& dxInv = geom.InvCellSizeArray();
169 const Real dz_inv = geom.InvCellSize(2);
170 const int izmin = geom.Domain().smallEnd(2);
171 const int izmax = geom.Domain().bigEnd(2);
173 ParallelFor(gbx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) noexcept
175 const Real zval = (use_terrain_fitted_coords)
177 : gdata.ProbLo(2) + (k + 0.5) * gdata.CellSize(2);
179 const Real met_h_zeta = (use_terrain_fitted_coords)
181 const Real dz_terrain = met_h_zeta / dz_inv;
182 if (k < pbli_arr(i, j, 0)) {
183 const Real phiM = (l_obuk_arr(i, j, 0) > 0)
184 ? (1 + 5 * sf * pblh_arr(i, j, 0) / l_obuk_arr(i, j, 0))
186 (1 - 8 * sf * pblh_arr(i, j, 0) / l_obuk_arr(i, j, 0)),
188 const Real phit = (l_obuk_arr(i, j, 0) > 0)
189 ? (1 + 5 * sf * pblh_arr(i, j, 0) / l_obuk_arr(i, j, 0))
191 (1 - 16 * sf * pblh_arr(i, j, 0) / l_obuk_arr(i, j, 0)),
193 const Real Prt = phit / phiM + const_b *
KAPPA * sf;
194 const Real wstar = u_star_arr(i, j, 0) / phiM;
196 * (1 - zval / pblh_corr_arr(i, j, 0))
197 * (1 - zval / pblh_corr_arr(i, j, 0));
200 const Real lambda = 150.0;
201 const Real lscale = (
KAPPA * zval * lambda) / (
KAPPA * zval + lambda);
202 Real dthetadz, dudz, dvdz;
204 c_ext_dir_on_zlo, c_ext_dir_on_zhi, u_ext_dir_on_zlo,
205 u_ext_dir_on_zhi, v_ext_dir_on_zlo, v_ext_dir_on_zhi, dthetadz,
206 dudz, dvdz, moisture_indices);
207 const Real wind_shear = dudz * dudz + dvdz * dvdz + 1.0e-9;
222 const Real Pr = 1.0 + 2.1 * grad_Ri;
223 const Real fm = (grad_Ri > 0)
224 ? 1.0 / ((1.0 + 5.0 * grad_Ri) * (1.0 + 5.0 * grad_Ri))
225 : 1 - 8 * grad_Ri / (1 + 1.746 * std::sqrt(-grad_Ri));
226 const Real ft = (grad_Ri > 0)
227 ? 1.0 / ((1.0 + 5.0 * grad_Ri) * (1.0 + 5.0 * grad_Ri))
228 : 1 - 8 * grad_Ri / (1 + 1.286 * std::sqrt(-grad_Ri));
229 const Real rl2wsp =
rho * lscale * lscale * std::sqrt(wind_shear);
236 constexpr
Real ckz = 0.001;
237 constexpr
Real Kmax = 1000.0;
238 const Real rhoKmin = ckz * dz_terrain *
rho;
239 const Real rhoKmax =
rho * Kmax;
249 ParallelFor(xybx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int ) noexcept
constexpr amrex::Real KAPPA
Definition: ERF_Constants.H:20
constexpr amrex::Real CONST_GRAV
Definition: ERF_Constants.H:21
TurbChoice turbChoice
Definition: ERF_DiffSetup.H:2
#define Rho_comp
Definition: ERF_IndexDefines.H:36
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:37
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 MoistureComponentIndices &moisture_indices)
Definition: ERF_PBLModels.H:181
amrex::Real Real
Definition: ERF_ShocInterface.H:19
AMREX_FORCE_INLINE AMREX_GPU_DEVICE amrex::Real Compute_h_zeta_AtCellCenter(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:47
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real Compute_Zrel_AtCellCenter(const int &i, const int &j, const int &k, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:381
AMREX_FORCE_INLINE amrex::IntVect TileNoZ()
Definition: ERF_TileNoZ.H:11
@ yvel_bc
Definition: ERF_IndexDefines.H:88
@ cons_bc
Definition: ERF_IndexDefines.H:76
@ xvel_bc
Definition: ERF_IndexDefines.H:87
@ ext_dir
Definition: ERF_IndexDefines.H:209
@ Theta_v
Definition: ERF_IndexDefines.H:176
@ Turb_lengthscale
Definition: ERF_IndexDefines.H:180
@ Q_v
Definition: ERF_IndexDefines.H:179
@ Mom_v
Definition: ERF_IndexDefines.H:175
@ theta
Definition: ERF_MM5.H:20
@ rho
Definition: ERF_Kessler.H:22
@ xvel
Definition: ERF_IndexDefines.H:141
@ yvel
Definition: ERF_IndexDefines.H:142
amrex::Real pbl_mrf_const_b
Definition: ERF_TurbStruct.H:421
amrex::Real pbl_mrf_Ribcr
Definition: ERF_TurbStruct.H:419
amrex::Real pbl_mrf_sf
Definition: ERF_TurbStruct.H:423