231 auto brunt = col.
brunt.array();
232 auto shoc_mix = col.
shoc_mix.array();
233 const auto zt = col.
zt.const_array();
234 const auto zi = col.
zi.const_array();
235 const auto dz = col.
dz.const_array();
236 const auto thetal = col.
thetal.const_array();
237 const auto qc = col.
qc.const_array();
238 const auto qi = col.
qi.const_array();
239 const auto qv = col.
qv.const_array();
240 const auto exner = col.
exner.const_array();
241 const auto tke = col.
tke.const_array();
242 const auto mf_area = col.
mf_area.const_array();
244 const Real max_horiz_len_comp = std::sqrt(
dx *
dy);
245 const auto layout = col.
layout;
246 const Box col_box(IntVect(0,0,0), IntVect(layout.ncell - 1, 0, 0));
248 ParallelFor(col_box, [=] AMREX_GPU_DEVICE (
int ic,
int,
int) noexcept
250 const Real z_sfc =
zi(ic,0,0);
251 Real numerator = 0.0_rt;
253 for (
int k = 0; k < layout.nlev; ++k) {
254 const Real tke_sqrt = std::sqrt(amrex::max(tke(ic,k,0),
shoc_min_tke()));
256 numerator += tke_sqrt * zt_agl *
dz(ic,k,0);
257 denom += tke_sqrt *
dz(ic,k,0);
259 const Real l_inf = (denom > 0.0_rt) ? 0.1_rt * numerator / denom : shoc_min_len();
260 const Real max_horiz_len = max_horiz_len_comp / std::sqrt(mf_area(ic,0,0));
262 for (
int k = 0; k < layout.nlev; ++k) {
263 const Real theta_v_k = virtual_theta_from_shoc_state(thetal(ic,k,0),
qc(ic,k,0),
qi(ic,k,0),
264 qv(ic,k,0), exner(ic,k,0));
265 Real theta_v_lo = theta_v_k;
266 Real theta_v_hi = theta_v_k;
267 if (layout.nlev > 1) {
269 const Real theta_v_kp1 = virtual_theta_from_shoc_state(thetal(ic,1,0),
qc(ic,1,0),
qi(ic,1,0),
270 qv(ic,1,0), exner(ic,1,0));
272 theta_v_k, theta_v_kp1,
zi(ic,0,0));
274 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),
275 qv(ic,k-1,0), exner(ic,k-1,0));
277 theta_v_km1, theta_v_k,
zi(ic,k,0));
280 if (k == layout.nlev - 1) {
281 const Real theta_v_km1 = virtual_theta_from_shoc_state(thetal(ic,layout.nlev-2,0),
282 qc(ic,layout.nlev-2,0),
qi(ic,layout.nlev-2,0),
283 qv(ic,layout.nlev-2,0), exner(ic,layout.nlev-2,0));
285 theta_v_km1, theta_v_k,
zi(ic,layout.nlev,0));
287 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),
288 qv(ic,k+1,0), exner(ic,k+1,0));
290 theta_v_k, theta_v_kp1,
zi(ic,k+1,0));
297 brunt(ic,k,0) = (
CONST_GRAV / amrex::max(theta_v_k, 1.0e-12_rt)) *
298 (theta_v_hi - theta_v_lo) / amrex::max(
dz(ic,k,0), 1.0e-12_rt);
299 const Real tkes = std::sqrt(amrex::max(tke(ic,k,0),
shoc_min_tke()));
300 const Real brunt_pos = amrex::max(brunt(ic,k,0), 0.0_rt);
302 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)) +
303 (1.0_rt / amrex::max(400.0_rt * tkes * amrex::max(l_inf, shoc_min_len()), 1.0e-12_rt)) +
304 0.01_rt * brunt_pos / amrex::max(tke(ic,k,0),
shoc_min_tke());
305 Real mix = amrex::min(shoc_max_len(),
306 2.8284_rt * std::sqrt(1.0_rt / amrex::max(inv_term, 1.0e-12_rt)) /
308 mix = amrex::min(max_horiz_len, amrex::max(shoc_min_len(), mix));
309 shoc_mix(ic,k,0) = mix;
GpuArray< Real, AMREX_SPACEDIM > dx
Definition: ERF_ActuatorSpreading.cpp:131
constexpr amrex::Real KAPPA
Definition: ERF_Constants.H:71
constexpr amrex::Real CONST_GRAV
Definition: ERF_Constants.H:72
const Real dy
Definition: ERF_InitCustomPert_ABL.H:101
ParallelFor(fab_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);})
@ qv
Definition: ERF_Kessler.H:31
@ qi
Definition: ERF_Morrison.H:111
@ qc
Definition: ERF_Morrison.H:110
@ dz
Definition: ERF_AdvanceWDM6.cpp:273
@ zi
Definition: ERF_AdvanceWDM6.cpp:277
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real weighted_linear_interp(Real x0, Real x1, Real y0, Real y1, Real x)
Definition: ERF_ShocDriver.cpp:137
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real shoc_min_tke() noexcept
Definition: ERF_ShocImplicit.cpp:20
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real height_agl(amrex::Real z, amrex::Real z_sfc) noexcept
Definition: ERF_ShocGpuUtils.H:50
amrex::FArrayBox qi
Definition: ERF_ShocTypes.H:86
amrex::FArrayBox dz
Definition: ERF_ShocTypes.H:76
amrex::FArrayBox shoc_mix
Definition: ERF_ShocTypes.H:103
amrex::FArrayBox qc
Definition: ERF_ShocTypes.H:85
amrex::FArrayBox tke
Definition: ERF_ShocTypes.H:89
amrex::FArrayBox exner
Definition: ERF_ShocTypes.H:81
ShocColumnLayout layout
Definition: ERF_ShocTypes.H:71
amrex::FArrayBox zi
Definition: ERF_ShocTypes.H:75
amrex::FArrayBox mf_area
Definition: ERF_ShocTypes.H:97
amrex::FArrayBox zt
Definition: ERF_ShocTypes.H:74
amrex::FArrayBox qv
Definition: ERF_ShocTypes.H:84
amrex::FArrayBox brunt
Definition: ERF_ShocTypes.H:104
amrex::FArrayBox thetal
Definition: ERF_ShocTypes.H:83
amrex::Real length_fac
Definition: ERF_ShocTypes.H:28