33 auto const& cons_arrs =
cons.const_arrays();
34 auto thetav_min = amrex::ReduceToPlane<amrex::ReduceOpMin,amrex::Real>(dir, bxlow,
cons,
35 [=] AMREX_GPU_DEVICE (
int box_no,
int i,
int j,
int k) -> amrex::Real
37 return GetThetav(i,j,k,cons_arrs[box_no],moisture_indices);
42 auto const& ba = pblh->boxArray();
43 auto const& dm = pblh->DistributionMap();
44 auto const&
ng = pblh->nGrowVect();
46 amrex::MultiFab min_thetav(ba,dm,1,
ng);
47 min_thetav.setVal(1.E34);
49 amrex::MultiFab pblh_tke(ba,dm,1,
ng);
55 for (amrex::MFIter mfi(
cons,
TileNoZ()); mfi.isValid(); ++mfi)
57 const amrex::Box& domain = geom.Domain();
58 amrex::Box gtbx = mfi.growntilebox();
59 gtbx.setSmall(2,domain.smallEnd(2));
60 gtbx.setBig(2,domain.bigEnd(2));
62 auto min_thv_arr = min_thetav.array(mfi);
63 auto pblh_arr = pblh->array(mfi);
64 auto pblh_tke_arr = pblh_tke.array(mfi);
66 const auto cons_arr =
cons.const_array(mfi);
67 const auto lmask_arr = (lmask) ? lmask->const_array(mfi) : amrex::Array4<int> {};
74 const auto zphys_arr = z_phys_cc->const_array(mfi);
77 int imin = lbound(zphys_arr).x;
78 int jmin = lbound(zphys_arr).y;
79 int imax = ubound(zphys_arr).x;
80 int jmax = ubound(zphys_arr).y;
84 ParallelFor(gtbx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) noexcept
86 int ii = amrex::max(amrex::min(i,imax),imin);
87 int jj = amrex::max(amrex::min(j,jmax),jmin);
90 amrex::Real thv =
GetThetav(i, j, k, cons_arr, moisture_indices);
91 if (min_thv_arr(i,j,0) > thv) min_thv_arr(i,j,0) = thv;
96 ParallelFor(gtbx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) noexcept
98 int ii = amrex::max(amrex::min(i,imax),imin);
99 int jj = amrex::max(amrex::min(j,jmax),jmin);
101 if (pblh_arr(i,j,0) == 0)
106 amrex::Real thv =
GetThetav(i, j, k , cons_arr, moisture_indices);
107 amrex::Real thv1 =
GetThetav(i, j, k+1, cons_arr, moisture_indices);
109 int is_land = (lmask_arr) ? lmask_arr(i,j,0) : 1;
114 pblh_arr(i,j,0) = zphys_arr(ii,jj,k)
115 + (zphys_arr(ii,jj,k+1)-zphys_arr(ii,jj,k))/(thv1-thv)
122 pblh_arr(i,j,0) = zphys_arr(ii,jj,k)
123 + (zphys_arr(ii,jj,k+1)-zphys_arr(ii,jj,k))/(thv1-thv)
127 if (pblh_tke_arr(i,j,0) == 0)
136 amrex::Real TKEeps = 0.05 * maxtke;
137 TKEeps = amrex::max(TKEeps, 0.02);
139 if ((tke1 <= TKEeps) && (tke > TKEeps))
142 pblh_tke_arr(i,j,0) = zphys_arr(ii,jj,k)
143 + (zphys_arr(ii,jj,k+1)-zphys_arr(ii,jj,k))/(tke1-tke)
154 const amrex::Real dz_no_terrain = geom.CellSize(2);
160 AMREX_ASSERT(kmax > 0);
161 amrex::Box gtbxlow = gtbx;
162 gtbxlow.setBig(2,kmax);
164 ParallelFor(gtbxlow, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) noexcept
166 amrex::Real thv =
GetThetav(i, j, k , cons_arr, moisture_indices);
167 if (min_thv_arr(i,j,0) > thv) min_thv_arr(i,j,0) = thv;
171 ParallelFor(gtbx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) noexcept
173 if (pblh_arr(i,j,0) == 0)
178 amrex::Real thv =
GetThetav(i, j, k , cons_arr, moisture_indices);
179 amrex::Real thv1 =
GetThetav(i, j, k+1, cons_arr, moisture_indices);
181 int is_land = (lmask_arr) ? lmask_arr(i,j,0) : 1;
186 pblh_arr(i,j,0) = (k+0.5)*dz_no_terrain
187 + dz_no_terrain/(thv1-thv)
194 pblh_arr(i,j,0) = (k+0.5)*dz_no_terrain
195 + dz_no_terrain/(thv1-thv)
199 if (pblh_tke_arr(i,j,0) == 0)
208 amrex::Real TKEeps = 0.05 * maxtke;
209 TKEeps = amrex::max(TKEeps, 0.02);
211 if ((tke1 <= TKEeps) && (tke > TKEeps))
214 pblh_tke_arr(i,j,0) = (k+0.5)*dz_no_terrain
215 + dz_no_terrain/(tke1-tke) * (TKEeps - tke);
225 for (amrex::MFIter mfi(*pblh); mfi.isValid(); ++mfi)
227 const auto cons_arr =
cons.const_array(mfi);
228 auto pblh_tke_arr = pblh_tke.array(mfi);
229 auto pblh_arr = pblh->array(mfi);
231 amrex::Box gtbx = mfi.growntilebox();
232 ParallelFor(gtbx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int) noexcept
243 amrex::Real zi = pblh_arr(i,j,0);
244 pblh_tke_arr(i,j,0) = amrex::max(
245 amrex::min(pblh_tke_arr(i,j,0), zi+350.),
246 amrex::max(zi-350., 10.));
254 pblh_arr(i,j,0) = (1.-wt)*pblh_tke_arr(i,j,0) + wt*pblh_arr(i,j,0);
#define Rho_comp
Definition: ERF_IndexDefines.H:36
#define RhoKE_comp
Definition: ERF_IndexDefines.H:38
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real GetThetav(int i, int j, int k, const amrex::Array4< amrex::Real const > &cell_data, const MoistureComponentIndices &moisture_indices)
Definition: ERF_MoistUtils.H:72
AMREX_FORCE_INLINE amrex::IntVect TileNoZ()
Definition: ERF_TileNoZ.H:11
@ ng
Definition: ERF_Morrison.H:48
@ cons
Definition: ERF_IndexDefines.H:140
static constexpr amrex::Real sbl_lim
Definition: ERF_PBLHeight.H:263
static constexpr amrex::Real theta_incr_land
Definition: ERF_PBLHeight.H:261
static constexpr amrex::Real thetamin_height
Definition: ERF_PBLHeight.H:260
static constexpr amrex::Real theta_incr_water
Definition: ERF_PBLHeight.H:262
static constexpr amrex::Real sbl_damp
Definition: ERF_PBLHeight.H:264