221 auto brunt = col.
brunt.array();
222 auto shoc_mix = col.
shoc_mix.array();
223 const auto zt = col.
zt.const_array();
224 const auto zi = col.
zi.const_array();
225 const auto dz = col.
dz.const_array();
226 const auto thetal = col.
thetal.const_array();
227 const auto qc = col.
qc.const_array();
228 const auto qi = col.
qi.const_array();
229 const auto qv = col.
qv.const_array();
230 const auto exner = col.
exner.const_array();
231 const auto tke = col.
tke.const_array();
232 const Real max_horiz_len = std::sqrt(
dx *
dy);
233 const auto layout = col.
layout;
234 const Box col_box(IntVect(0,0,0), IntVect(layout.ncell - 1, 0, 0));
236 ParallelFor(col_box, [=] AMREX_GPU_DEVICE (
int ic,
int,
int) noexcept
238 const Real z_sfc =
zi(ic,0,0);
239 Real numerator = 0.0_rt;
241 for (
int k = 0; k < layout.nlev; ++k) {
242 const Real tke_sqrt = std::sqrt(amrex::max(tke(ic,k,0), shoc_min_tke()));
244 numerator += tke_sqrt * zt_agl *
dz(ic,k,0);
245 denom += tke_sqrt *
dz(ic,k,0);
247 const Real l_inf = (denom > 0.0_rt) ? 0.1_rt * numerator / denom : shoc_min_len();
249 for (
int k = 0; k < layout.nlev; ++k) {
250 const Real theta_v_k = virtual_theta_from_shoc_state(thetal(ic,k,0),
qc(ic,k,0),
qi(ic,k,0),
251 qv(ic,k,0), exner(ic,k,0));
252 Real theta_v_lo = theta_v_k;
253 Real theta_v_hi = theta_v_k;
254 if (layout.nlev > 1) {
256 const Real theta_v_kp1 = virtual_theta_from_shoc_state(thetal(ic,1,0),
qc(ic,1,0),
qi(ic,1,0),
257 qv(ic,1,0), exner(ic,1,0));
258 theta_v_lo = weighted_linear_interp(zt(ic,0,0), zt(ic,1,0),
259 theta_v_k, theta_v_kp1,
zi(ic,0,0));
261 const Real theta_v_km1 = virtual_theta_from_shoc_state(thetal(ic,k-1,0),
qc(ic,k-1,0),
qi(ic,k-1,0),
262 qv(ic,k-1,0), exner(ic,k-1,0));
263 theta_v_lo = weighted_linear_interp(zt(ic,k-1,0), zt(ic,k,0),
264 theta_v_km1, theta_v_k,
zi(ic,k,0));
267 if (k == layout.nlev - 1) {
268 const Real theta_v_km1 = virtual_theta_from_shoc_state(thetal(ic,layout.nlev-2,0),
269 qc(ic,layout.nlev-2,0),
qi(ic,layout.nlev-2,0),
270 qv(ic,layout.nlev-2,0), exner(ic,layout.nlev-2,0));
271 theta_v_hi = weighted_linear_interp(zt(ic,layout.nlev-2,0), zt(ic,layout.nlev-1,0),
272 theta_v_km1, theta_v_k,
zi(ic,layout.nlev,0));
274 const Real theta_v_kp1 = virtual_theta_from_shoc_state(thetal(ic,k+1,0),
qc(ic,k+1,0),
qi(ic,k+1,0),
275 qv(ic,k+1,0), exner(ic,k+1,0));
276 theta_v_hi = weighted_linear_interp(zt(ic,k,0), zt(ic,k+1,0),
277 theta_v_k, theta_v_kp1,
zi(ic,k+1,0));
284 brunt(ic,k,0) = (
CONST_GRAV / amrex::max(theta_v_k, 1.0e-12_rt)) *
285 (theta_v_hi - theta_v_lo) / amrex::max(
dz(ic,k,0), 1.0e-12_rt);
286 const Real tkes = std::sqrt(amrex::max(tke(ic,k,0), shoc_min_tke()));
287 const Real brunt_pos = amrex::max(brunt(ic,k,0), 0.0_rt);
289 const Real inv_term = (1.0_rt / amrex::max(400.0_rt * tkes *
KAPPA * amrex::max(zt_agl, 1.0_rt), 1.0e-12_rt)) +
290 (1.0_rt / amrex::max(400.0_rt * tkes * amrex::max(l_inf, shoc_min_len()), 1.0e-12_rt)) +
291 0.01_rt * brunt_pos / amrex::max(tke(ic,k,0), shoc_min_tke());
292 Real mix = amrex::min(shoc_max_len(),
293 2.8284_rt * std::sqrt(1.0_rt / amrex::max(inv_term, 1.0e-12_rt)) /
295 mix = amrex::min(max_horiz_len, amrex::max(shoc_min_len(), mix));
296 shoc_mix(ic,k,0) = mix;
constexpr amrex::Real KAPPA
Definition: ERF_Constants.H:52
constexpr amrex::Real CONST_GRAV
Definition: ERF_Constants.H:53
const Real dy
Definition: ERF_InitCustomPert_ABL.H:24
const Real dx
Definition: ERF_InitCustomPert_ABL.H:23
ParallelFor(grown_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);})
amrex::Real Real
Definition: ERF_ShocInterface.H:19
@ qv
Definition: ERF_Kessler.H:29
@ qc
Definition: ERF_SatAdj.H:40
@ qi
Definition: ERF_WSM6.H:26
@ dz
Definition: ERF_AdvanceWSM6.cpp:104
@ zi
Definition: ERF_AdvanceWSM6.cpp:133
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real height_agl(amrex::Real z, amrex::Real z_sfc) noexcept
Definition: ERF_ShocGpuUtils.H:46
amrex::FArrayBox qi
Definition: ERF_ShocTypes.H:220
amrex::FArrayBox dz
Definition: ERF_ShocTypes.H:210
amrex::FArrayBox shoc_mix
Definition: ERF_ShocTypes.H:233
amrex::FArrayBox qc
Definition: ERF_ShocTypes.H:219
amrex::FArrayBox tke
Definition: ERF_ShocTypes.H:223
amrex::FArrayBox exner
Definition: ERF_ShocTypes.H:215
ShocColumnLayout layout
Definition: ERF_ShocTypes.H:205
amrex::FArrayBox zi
Definition: ERF_ShocTypes.H:209
amrex::FArrayBox zt
Definition: ERF_ShocTypes.H:208
amrex::FArrayBox qv
Definition: ERF_ShocTypes.H:218
amrex::FArrayBox brunt
Definition: ERF_ShocTypes.H:234
amrex::FArrayBox thetal
Definition: ERF_ShocTypes.H:217
amrex::Real length_fac
Definition: ERF_ShocTypes.H:92