166 int klo = geom.Domain().smallEnd(2);
167 int khi = geom.Domain().bigEnd(2);
170 #pragma omp parallel if (Gpu::notInLaunchRegion())
172 for (MFIter mfi(eddyViscosity,
TileNoZ()); mfi.isValid(); ++mfi) {
175 const Box& gbx = mfi.growntilebox(IntVect(1,1,0));
177 gbx.bigEnd(2) ==
khi );
180 const GeometryData gdata = geom.data();
181 const Box xybx = PerpendicularBox<ZDir>(gbx, IntVect{0, 0, 0});
188 FArrayBox pbl_height_predictor(xybx, 1, The_Async_Arena());
189 FArrayBox pbl_height_corrector(xybx, 1, The_Async_Arena());
190 IArrayBox pbl_index(xybx, 1, The_Async_Arena());
191 IArrayBox pbl_index_zero_ri(xybx, 1, The_Async_Arena());
192 FArrayBox hgamt_fab(xybx, 1, The_Async_Arena());
193 FArrayBox hgamq_fab(xybx, 1, The_Async_Arena());
194 FArrayBox wstar_fab(xybx, 1, The_Async_Arena());
195 FArrayBox vpert_fab(xybx, 1, The_Async_Arena());
196 const auto& pblh_pred_arr = pbl_height_predictor.array();
197 const auto& pblh_corr_arr = pbl_height_corrector.array();
198 const auto& pbli_arr = pbl_index.array();
199 const auto& pbli_zero_arr = pbl_index_zero_ri.array();
200 const auto& hgamt_arr = hgamt_fab.array();
201 const auto& hgamq_arr = hgamq_fab.array();
202 const auto& wstar_arr = wstar_fab.array();
203 const auto& vpert_arr = vpert_fab.array();
206 const auto& cell_data = cons_in.const_array(mfi);
207 const auto& uvel =
xvel.const_array(mfi);
208 const auto& vvel =
yvel.const_array(mfi);
211 const auto& u_star_arr = SurfLayer->get_u_star(level)->const_array(mfi);
212 const auto& t_star_arr = SurfLayer->get_t_star(level)->const_array(mfi);
213 const auto& l_obuk_arr = SurfLayer->get_olen(level)->const_array(mfi);
214 const auto& t10av_arr = SurfLayer->get_mac_avg(level, 2)->const_array(mfi);
215 const auto& q10av_arr = SurfLayer->get_mac_avg(level, 3)->const_array(mfi);
216 const auto& lmask_arr = (SurfLayer->get_lmask(level)) ?
217 SurfLayer->get_lmask(level)->const_array(mfi) :
220 const Array4<Real const> z_nd_arr = use_terrain_fitted_coords ? z_phys_nd->array(mfi)
221 : Array4<Real const>{};
230 ParallelFor(xybx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int) noexcept
232 const Real t_layer = t10av_arr(i, j, 0);
234 const Real t_layer_v = t_layer * (
one +
epsv * moisture_fraction);
240 zval = (use_terrain_fitted_coords)
242 : (kpbl +
myhalf) * gdata.CellSize(2);
243 const Real theta_v =
GetThetav(i, j, kpbl, cell_data, moisture_indices);
245 const Real theta_v_klo = amrex::max(
GetThetav(i, j, klo, cell_data, moisture_indices),
Real(1.0));
246 const Real ws2_raw =
fourth * ( (uvel(i, j, kpbl) + uvel(i + 1, j, kpbl)) *
247 (uvel(i, j, kpbl) + uvel(i + 1, j, kpbl)) +
248 (vvel(i, j, kpbl) + vvel(i, j + 1, kpbl)) *
249 (vvel(i, j, kpbl) + vvel(i, j + 1, kpbl)) );
250 const Real ws2 = amrex::max(ws2_raw,
Real(1.0));
251 Rib =
CONST_GRAV * zval * (theta_v - t_layer_v) / (ws2 * theta_v_klo);
254 Real zval0 = zval, Rib0 = Rib;
255 bool above_critical =
false;
256 while (!above_critical && ((kpbl + 1) <=
khi)) {
261 zval = (use_terrain_fitted_coords)
263 : (kpbl +
myhalf) * gdata.CellSize(2);
264 const Real theta_v =
GetThetav(i, j, kpbl, cell_data, moisture_indices);
266 const Real theta_v_klo = amrex::max(
GetThetav(i, j, klo, cell_data, moisture_indices),
Real(1.0));
267 const Real ws2_raw =
fourth * ( (uvel(i, j, kpbl) + uvel(i + 1, j, kpbl)) *
268 (uvel(i, j, kpbl) + uvel(i + 1, j, kpbl)) +
269 (vvel(i, j, kpbl) + vvel(i, j + 1, kpbl)) *
270 (vvel(i, j, kpbl) + vvel(i, j + 1, kpbl)) );
271 const Real ws2 = amrex::max(ws2_raw,
Real(1.0));
272 Rib =
CONST_GRAV * zval * (theta_v - t_layer_v) / (ws2 * theta_v_klo);
273 above_critical = (Rib >= Ribcr);
276 const Real pblh_emp = (use_terrain_fitted_coords)
278 :
myhalf * gdata.CellSize(2);
279 const Real z_max = (use_terrain_fitted_coords)
282 const Real pblh_max =
Real(0.9) * z_max;
283 const Real pblh_min = amrex::max(pblh_emp,
Real(10.0));
285 if (above_critical) {
288 const Real rib_diff = Rib - Rib0;
289 if (std::abs(rib_diff) >
Real(1.0e-10)) {
290 pblh_interp = zval0 + (zval - zval0) / rib_diff * (Ribcr - Rib0);
295 pblh_pred_arr(i, j, 0) = amrex::max(amrex::min(pblh_interp, pblh_max), pblh_min);
296 pbli_arr(i, j, 0) = kpbl;
298 pblh_pred_arr(i, j, 0) = pblh_min;
299 pbli_arr(i, j, 0) = klo + 1;
305 amrex::MultiFab* q_star_mf = SurfLayer->get_q_star(level);
306 Array4<Real const> q_star_arr = (q_star_mf !=
nullptr) ? q_star_mf->const_array(mfi)
307 : Array4<Real const>{};
314 constexpr
Real GAMCRQ =
Real(2.e-3);
325 ParallelFor(xybx, [=,zero_d=
zero] AMREX_GPU_DEVICE(
int i,
int j,
int) noexcept
327 const Real t_layer = t10av_arr(i, j, 0);
328 Real obuk_val = l_obuk_arr(i, j, 0);
334 const Real HOL = sf * pblh_pred_arr(i, j, 0) / obuk_val;
335 const Real HOL_bounded = amrex::max(amrex::min(HOL,
Real(100.0)),
Real(-100.0));
336 const Real one_quarter =
Real(0.25);
337 const Real phiM = (obuk_val > 0)
338 ? (1 + 5 * HOL_bounded)
339 : std::pow(amrex::max(1 - 16 * HOL_bounded,
Real(0.01)), -one_quarter);
340 const Real phiM_safe = amrex::max(phiM,
Real(0.01));
345 Real wstar = u_star_arr(i, j, 0) / phiM_safe;
346 wstar = amrex::max(wstar,
Real(0.01));
347 wstar = amrex::min(wstar,
Real(5.0));
349 bool SFCFLG = (obuk_val <= zero_d);
350 const Real HGAMT = (SFCFLG && enable_mrf_countergradient)
351 ? amrex::min(-const_b * u_star_arr(i, j, 0) * t_star_arr(i, j, 0) / wstar, GAMCRT)
355 if (SFCFLG &&
use_moisture && enable_mrf_countergradient) {
356 const Real q_star = q_star_arr(i, j, 0);
357 const Real HGAMQ_calc = -const_b * u_star_arr(i, j, 0) * q_star / wstar;
358 HGAMQ = amrex::max(amrex::min(HGAMQ_calc, GAMCRQ),
Real(0));
361 bool is_land = (lmask_arr(i,j,0) == 1);
362 if (!is_land) HGAMQ = zero_d;
365 if (moisture_indices.
qv >= 0) {
366 Real qv_klo = cell_data(i, j, klo, moisture_indices.
qv) / cell_data(i, j, klo,
Rho_comp);
370 Real qsat_klo = zero_d;
372 Real rh_klo = (qsat_klo >
Real(1.0e-10)) ? (qv_klo / qsat_klo) :
Real(0);
373 if (rh_klo >
Real(0.95)) {
374 Real rh_scaling = amrex::max(zero_d, (
Real(1) - rh_klo) /
Real(0.05));
383 if (pbli_arr(i, j, 0) <= klo + 1 || !enable_mrf_countergradient) {
384 vpert_arr(i, j, 0) = zero_d;
386 const Real VPERT_raw = HGAMT +
epsv * t_layer * HGAMQ;
387 const Real VPERT_capped = enable_mrf_unbounded_vpert
389 : amrex::min(VPERT_raw, GAMCRT);
390 vpert_arr(i, j, 0) = amrex::max(VPERT_capped, zero_d);
403 AMREX_GPU_DEVICE(
int i,
int j,
int) noexcept
405 const Real t_layer = t10av_arr(i, j, 0);
408 const Real t_layer_v = t_layer * (
one +
epsv * moisture_fraction)
409 + vpert_arr(i, j, 0);
411 Real obuk_val = l_obuk_arr(i, j, 0);
419 zval = (use_terrain_fitted_coords)
421 : (kpbl +
myhalf) * gdata.CellSize(2);
422 const Real theta_v =
GetThetav(i, j, kpbl, cell_data, moisture_indices);
424 const Real theta_v_klo = amrex::max(
GetThetav(i, j, klo, cell_data, moisture_indices), one_d);
425 const Real ws2_raw =
fourth * ( (uvel(i, j, kpbl) + uvel(i + 1, j, kpbl)) *
426 (uvel(i, j, kpbl) + uvel(i + 1, j, kpbl)) +
427 (vvel(i, j, kpbl) + vvel(i, j + 1, kpbl)) *
428 (vvel(i, j, kpbl) + vvel(i, j + 1, kpbl)) );
429 const Real ws2 = amrex::max(ws2_raw, one_d);
430 Rib =
CONST_GRAV * zval * (theta_v - t_layer_v) / (ws2 * theta_v_klo);
432 Real zval0 = zval, Rib0 = Rib;
434 bool above_critical =
false;
435 while (!above_critical && ((kpbl + 1) <=
khi)) {
440 zval = (use_terrain_fitted_coords)
442 : (kpbl +
myhalf) * gdata.CellSize(2);
443 const Real theta_v =
GetThetav(i, j, kpbl, cell_data, moisture_indices);
445 const Real theta_v_klo = amrex::max(
GetThetav(i, j, klo, cell_data, moisture_indices), one_d);
446 const Real ws2_raw =
fourth * ( (uvel(i, j, kpbl) + uvel(i + 1, j, kpbl)) *
447 (uvel(i, j, kpbl) + uvel(i + 1, j, kpbl)) +
448 (vvel(i, j, kpbl) + vvel(i, j + 1, kpbl)) *
449 (vvel(i, j, kpbl) + vvel(i, j + 1, kpbl)) );
450 const Real ws2 = amrex::max(ws2_raw, one_d);
451 Rib =
CONST_GRAV * zval * (theta_v - t_layer_v) / (ws2 * theta_v_klo);
452 above_critical = (Rib >= Ribcr);
455 const Real pblh_emp = (use_terrain_fitted_coords)
457 :
myhalf * gdata.CellSize(2);
458 const Real z_max = (use_terrain_fitted_coords)
461 const Real pblh_max =
Real(0.9) * z_max;
462 const Real pblh_min = amrex::max(pblh_emp,
Real(10.0));
464 if (above_critical) {
467 const Real rib_diff = Rib - Rib0;
468 if (std::abs(rib_diff) >
Real(1.0e-10)) {
469 pblh_interp = zval0 + (zval - zval0) / rib_diff * (Ribcr - Rib0);
474 pblh_corr_arr(i, j, 0) = amrex::max(amrex::min(pblh_interp, pblh_max), pblh_min);
475 pbli_arr(i, j, 0) = kpbl;
477 pblh_corr_arr(i, j, 0) = pblh_min;
478 pbli_arr(i, j, 0) = klo + 1;
489 ParallelFor(xybx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int) noexcept
492 Real obuk_val = l_obuk_arr(i, j, 0);
498 const Real HOL = sf * pblh_corr_arr(i, j, 0) / obuk_val;
499 const Real HOL_bounded = amrex::max(amrex::min(HOL,
Real(100.0)),
Real(-100.0));
500 const Real one_quarter =
Real(0.25);
501 const Real phiM = (obuk_val > 0)
502 ? (1 + 5 * HOL_bounded)
503 : std::pow(amrex::max(1 - 16 * HOL_bounded,
Real(0.01)), -one_quarter);
504 const Real phiM_safe = amrex::max(phiM,
Real(0.01));
507 Real wstar = u_star_arr(i, j, 0) / phiM_safe;
508 wstar = amrex::max(wstar,
Real(0.01));
509 wstar = amrex::min(wstar,
Real(5.0));
510 wstar_arr(i, j, 0) = wstar;
512 bool SFCFLG = (obuk_val <=
Real(0));
513 const Real HGAMT = (SFCFLG && enable_mrf_countergradient)
514 ? amrex::min(-const_b * u_star_arr(i, j, 0) * t_star_arr(i, j, 0) / wstar, GAMCRT)
518 if (SFCFLG &&
use_moisture && enable_mrf_countergradient) {
519 const Real q_star = q_star_arr(i, j, 0);
520 const Real HGAMQ_calc = -const_b * u_star_arr(i, j, 0) * q_star / wstar;
521 HGAMQ = amrex::max(amrex::min(HGAMQ_calc, GAMCRQ),
Real(0));
524 bool is_land = (lmask_arr(i,j,0) == 1);
525 if (!is_land) HGAMQ =
Real(0);
528 if (moisture_indices.
qv >= 0) {
529 Real qv_klo = cell_data(i, j, klo, moisture_indices.
qv) / cell_data(i, j, klo,
Rho_comp);
535 Real rh_klo = (qsat_klo >
Real(1.0e-10)) ? (qv_klo / qsat_klo) :
Real(0);
536 if (rh_klo >
Real(0.95)) {
543 if (pbli_arr(i, j, 0) <= klo + 1) {
544 hgamt_arr(i, j, 0) =
Real(0);
545 hgamq_arr(i, j, 0) =
Real(0);
547 const Real pblh = pblh_corr_arr(i, j, 0);
549 if (pblh >
Real(1.0e-10)) {
550 hgamt_arr(i, j, 0) = (enable_mrf_countergradient) ? HGAMT / pblh :
Real(0);
551 hgamq_arr(i, j, 0) = (enable_mrf_countergradient &&
use_moisture) ? HGAMQ / pblh :
Real(0);
553 hgamt_arr(i, j, 0) =
Real(0);
554 hgamq_arr(i, j, 0) =
Real(0);
565 constexpr
Real Ribcr_zero =
Real(0);
567 AMREX_GPU_DEVICE(
int i,
int j,
int) noexcept
569 const Real t_layer = t10av_arr(i, j, 0);
571 const Real t_layer_v = t_layer * (
one +
epsv * moisture_fraction);
572 const Real t_layer_v_enhanced = t_layer_v + vpert_arr(i, j, 0);
575 Real zval_zero, Rib_zero;
577 zval_zero = (use_terrain_fitted_coords)
579 : (kpbl_zero +
myhalf) * gdata.CellSize(2);
580 const Real theta_v =
GetThetav(i, j, kpbl_zero, cell_data, moisture_indices);
582 const Real theta_v_klo = amrex::max(
GetThetav(i, j, klo, cell_data, moisture_indices), one_d);
583 const Real ws2_raw =
fourth * ( (uvel(i, j, kpbl_zero) + uvel(i + 1, j, kpbl_zero)) *
584 (uvel(i, j, kpbl_zero) + uvel(i + 1, j, kpbl_zero)) +
585 (vvel(i, j, kpbl_zero) + vvel(i, j + 1, kpbl_zero)) *
586 (vvel(i, j, kpbl_zero) + vvel(i, j + 1, kpbl_zero)) );
587 const Real ws2 = amrex::max(ws2_raw, one_d);
588 Rib_zero =
CONST_GRAV * zval_zero * (theta_v - t_layer_v_enhanced) / (ws2 * theta_v_klo);
591 bool above_critical_zero =
false;
592 while (!above_critical_zero && ((kpbl_zero + 1) <=
khi)) {
594 zval_zero = (use_terrain_fitted_coords)
596 : (kpbl_zero +
myhalf) * gdata.CellSize(2);
597 const Real theta_v =
GetThetav(i, j, kpbl_zero, cell_data, moisture_indices);
599 const Real theta_v_klo = amrex::max(
GetThetav(i, j, klo, cell_data, moisture_indices), one_d);
600 const Real ws2_raw =
fourth * ( (uvel(i, j, kpbl_zero) + uvel(i + 1, j, kpbl_zero)) *
601 (uvel(i, j, kpbl_zero) + uvel(i + 1, j, kpbl_zero)) +
602 (vvel(i, j, kpbl_zero) + vvel(i, j + 1, kpbl_zero)) *
603 (vvel(i, j, kpbl_zero) + vvel(i, j + 1, kpbl_zero)) );
604 const Real ws2 = amrex::max(ws2_raw, one_d);
605 Rib_zero =
CONST_GRAV * zval_zero * (theta_v - t_layer_v_enhanced) / (ws2 * theta_v_klo);
606 above_critical_zero = (Rib_zero >= Ribcr_zero);
609 if (above_critical_zero) {
610 pbli_zero_arr(i, j, 0) = kpbl_zero;
612 pbli_zero_arr(i, j, 0) = klo + 1;
618 const Array4<Real>& K_turb = eddyViscosity.array(mfi);
627 const auto&
dxInv = geom.InvCellSizeArray();
628 const Real dz_inv = geom.InvCellSize(2);
629 const int izmin = geom.Domain().smallEnd(2);
630 const int izmax = geom.Domain().bigEnd(2);
640 ParallelFor(gbx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) noexcept
642 Real obuk_val = l_obuk_arr(i, j, 0);
647 const Real zval = (use_terrain_fitted_coords)
649 : (k +
myhalf) * gdata.CellSize(2);
662 const Real met_h_zeta = (use_terrain_fitted_coords)
664 const Real dz_terrain = met_h_zeta / dz_inv;
666 constexpr
Real qc_threshold =
Real(1.0e-4);
670 if (moisture_indices.
qc >= 0) {
671 qc_mix = cell_data(i, j, k, moisture_indices.
qc) /
rho;
673 if (moisture_indices.
qi >= 0) {
674 qi_mix = cell_data(i, j, k, moisture_indices.
qi) /
rho;
677 const Real total_qcloud = qc_mix + qi_mix;
682 if (k < pbli_extent) {
683 bool SFCFLG = (obuk_val <=
Real(0));
685 const Real HOL = sf * pblh_corr_arr(i, j, 0) / obuk_val;
686 const Real HOL_bounded = amrex::max(amrex::min(HOL,
Real(100.0)),
Real(-100.0));
688 const Real one_quarter =
Real(0.25);
689 const Real phiM = (obuk_val > 0)
690 ? (1 + 5 * HOL_bounded)
691 : std::pow(amrex::max(1 - 16 * HOL_bounded,
Real(0.01)), -one_quarter);
692 const Real phit = (obuk_val > 0)
693 ? (1 + 5 * HOL_bounded)
694 : std::pow(amrex::max(1 - 16 * HOL_bounded,
Real(0.01)), -
Real(0.5));
696 Real phit_cloud = phit;
697 Real phiM_cloud = phiM;
698 if (has_cloud && obuk_val >
Real(0)) {
699 Real reduction_factor =
Real(1) -
Real(0.15) * amrex::min(total_qcloud / qc_threshold,
Real(1));
700 phiM_cloud =
Real(1) +
Real(5.0) * reduction_factor * sf * pblh_corr_arr(i, j, 0) / obuk_val;
701 phit_cloud =
Real(1) +
Real(5.0) * reduction_factor * sf * pblh_corr_arr(i, j, 0) / obuk_val;
702 }
else if (has_cloud && obuk_val <=
Real(0)) {
703 Real cloud_boost =
Real(1.0) +
Real(0.05) * amrex::min(total_qcloud / qc_threshold,
Real(1));
704 phiM_cloud = std::pow(amrex::max(
Real(1) -
Real(16.0) * HOL_bounded / cloud_boost,
Real(0.01)), -one_quarter);
705 phit_cloud = std::pow(amrex::max(
Real(1) -
Real(16.0) * HOL_bounded / cloud_boost,
Real(0.01)), -
Real(0.5));
708 const Real phiM_eff = phiM_cloud;
709 const Real phit_eff = phit_cloud;
711 Real Prt_base = phit_eff / phiM_eff;
712 const Real Prt = amrex::min(amrex::max(Prt_base + const_b *
KAPPA * sf, prmin), prmax);
714 const Real wstar = wstar_arr(i, j, 0);
719 const Real z_sfc = (use_terrain_fitted_coords)
722 const Real zrel = zval - z_sfc;
723 const Real pblh = pblh_corr_arr(i, j, 0);
724 const Real pblh_rel = pblh - z_sfc;
725 const Real zfac = amrex::max(
Real(1) - zrel / pblh_rel,
Real(1.0e-8));
731 Real Prq_base = phit_eff / phiM_eff;
732 const Real Prq = amrex::min(amrex::max(Prq_base + const_b *
KAPPA * sf, prmin), prmax);
739 const Real lscale = (
KAPPA * zval * lambda) / (
KAPPA * zval + lambda);
740 Real dthetadz, dudz, dvdz;
741 ComputeVerticalDerivativesPBL(i, j, k, uvel, vvel, cell_data, izmin, izmax, pbl_derivative_dz_inv(i,j,k),
742 c_ext_dir_on_zlo, c_ext_dir_on_zhi, u_ext_dir_on_zlo,
743 u_ext_dir_on_zhi, v_ext_dir_on_zlo, v_ext_dir_on_zhi, dthetadz,
744 dudz, dvdz, moisture_indices);
746 const Real dudz_safe = (k < izmax) ? dudz :
Real(0);
747 const Real dvdz_safe = (k < izmax) ? dvdz :
Real(0);
748 const Real wind_shear = dudz_safe * dudz_safe + dvdz_safe * dvdz_safe;
749 const Real wind_shear_safe = std::max(wind_shear,
Real(1.0e-8));
752 const Real theta_v = amrex::max(
GetThetav(i, j, k, cell_data, moisture_indices),
Real(1.0));
753 const Real dtheta_v_dz = dthetadz;
755 Real grad_Ri =
CONST_GRAV / theta_v * dtheta_v_dz / wind_shear_safe;
756 grad_Ri = std::max(std::min(grad_Ri,
Real(100.0)), -
Real(100.0));
758 const Real grad_Ri_safe = amrex::max(grad_Ri, -
Real(100.0));
760 const Real fm = (grad_Ri_safe > 0)
762 : 1 - 8 * grad_Ri_safe / (1 +
Real(1.746) * std::sqrt(amrex::max(-grad_Ri_safe,
Real(0))));
763 const Real ft = (grad_Ri_safe > 0)
765 : 1 - 8 * grad_Ri_safe / (1 +
Real(1.286) * std::sqrt(amrex::max(-grad_Ri_safe,
Real(0))));
766 const Real rl2wsp =
rho * lscale * lscale * std::sqrt(wind_shear);
778 }
else if (k >= pbli_extent) {
780 const Real lscale = (
KAPPA * zval * lambda) / (
KAPPA * zval + lambda);
781 Real dthetadz, dudz, dvdz;
782 ComputeVerticalDerivativesPBL(i, j, k, uvel, vvel, cell_data, izmin, izmax, pbl_derivative_dz_inv(i,j,k),
783 c_ext_dir_on_zlo, c_ext_dir_on_zhi, u_ext_dir_on_zlo,
784 u_ext_dir_on_zhi, v_ext_dir_on_zlo, v_ext_dir_on_zhi, dthetadz,
785 dudz, dvdz, moisture_indices);
787 const Real dudz_safe = (k < izmax) ? dudz :
Real(0);
788 const Real dvdz_safe = (k < izmax) ? dvdz :
Real(0);
789 const Real wind_shear = dudz_safe * dudz_safe + dvdz_safe * dvdz_safe;
790 const Real wind_shear_safe = std::max(wind_shear,
Real(1.0e-8));
793 const Real theta_v = amrex::max(
GetThetav(i, j, k, cell_data, moisture_indices),
Real(1.0));
794 const Real dtheta_v_dz = dthetadz;
796 Real grad_Ri =
CONST_GRAV / theta_v * dtheta_v_dz / wind_shear_safe;
797 grad_Ri = std::max(std::min(grad_Ri,
Real(100.0)), -
Real(100.0));
799 const Real grad_Ri_safe = amrex::max(grad_Ri, -
Real(100.0));
801 const Real fm = (grad_Ri_safe > 0)
803 : 1 - 8 * grad_Ri_safe / (1 +
Real(1.746) * std::sqrt(amrex::max(-grad_Ri_safe,
Real(0))));
804 const Real ft = (grad_Ri_safe > 0)
806 : 1 - 8 * grad_Ri_safe / (1 +
Real(1.286) * std::sqrt(amrex::max(-grad_Ri_safe,
Real(0))));
807 const Real rl2wsp =
rho * lscale * lscale * std::sqrt(wind_shear);
823 if (l_blend_length > 0.0) {
827 l_dx, l_blend_length, l_blend_cs, l_blend_cmax,
832 l_dx, l_blend_length, l_blend_cs, l_blend_cmax,
839 Real rhoKmin, rhoKmax;
843 rhoKmin = ckz * dz_terrain *
rho;
844 rhoKmax =
rho * Kmax;
848 rhoKmin =
rho * Kmin;
849 rhoKmax =
rho * Kmax;
860 if (k < pbli_extent) {
870 ParallelFor(xybx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int ) noexcept
constexpr amrex::Real epsv
Definition: ERF_Constants.H:53
constexpr amrex::Real KAPPA
Definition: ERF_Constants.H:63
constexpr amrex::Real one
Definition: ERF_Constants.H:9
constexpr amrex::Real fourth
Definition: ERF_Constants.H:14
constexpr amrex::Real zero
Definition: ERF_Constants.H:8
constexpr amrex::Real myhalf
Definition: ERF_Constants.H:13
constexpr amrex::Real CONST_GRAV
Definition: ERF_Constants.H:64
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getTgivenRandRTh(const amrex::Real rho, const amrex::Real rhotheta, const amrex::Real qv=amrex::Real(0))
Definition: ERF_EOS.H:46
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real getPgivenRTh(const amrex::Real rhotheta, const amrex::Real qv=amrex::Real(0))
Definition: ERF_EOS.H:81
#define Rho_comp
Definition: ERF_IndexDefines.H:36
#define RhoTheta_comp
Definition: ERF_IndexDefines.H:37
amrex::GpuArray< Real, AMREX_SPACEDIM > dxInv
Definition: ERF_InitCustomPertVels_ParticleTests.H:17
const bool use_moisture
Definition: ERF_InitCustomPert_Bomex.H:14
const int khi
Definition: ERF_InitCustomPert_Bubble.H:21
AMREX_ALWAYS_ASSERT(bx.length()[2]==khi+1)
rho
Definition: ERF_InitCustomPert_Bubble.H:107
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void erf_qsatw(amrex::Real t, amrex::Real p, amrex::Real &qsatw)
Definition: ERF_MicrophysicsUtils.H:228
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real GetThetav(const int &i, const int &j, const int &k, const amrex::Array4< amrex::Real const > &cell_data, const MoistureComponentIndices &moisture_indices)
Definition: ERF_MoistUtils.H:72
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);})
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 PBLDerivativeDzInv &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:254
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real pbl_kh_blend_and_cap(amrex::Real K_h, amrex::Real dx, amrex::Real L_blend, amrex::Real C_s, amrex::Real c_max, amrex::Real SmnSmn, bool use_smag) noexcept
Apply scale-aware blending and ceiling to a single K_h value.
Definition: ERF_PBLScaleAwareBlending.H:120
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:55
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:389
AMREX_FORCE_INLINE amrex::IntVect TileNoZ()
Definition: ERF_TileNoZ.H:11
@ yvel_bc
Definition: ERF_IndexDefines.H:103
@ cons_bc
Definition: ERF_IndexDefines.H:86
@ xvel_bc
Definition: ERF_IndexDefines.H:102
@ ext_dir
Definition: ERF_IndexDefines.H:249
@ Theta_v
Definition: ERF_IndexDefines.H:212
@ Turb_lengthscale
Definition: ERF_IndexDefines.H:216
@ Q_v
Definition: ERF_IndexDefines.H:215
@ Mom_v
Definition: ERF_IndexDefines.H:211
@ HGAMQ_v
Definition: ERF_IndexDefines.H:218
@ HGAMT_v
Definition: ERF_IndexDefines.H:217
@ xvel
Definition: ERF_IndexDefines.H:177
@ yvel
Definition: ERF_IndexDefines.H:178
int qi
Cloud ice component index.
Definition: ERF_DataStruct.H:169
int qv
Water vapor component index.
Definition: ERF_DataStruct.H:167
int qc
Cloud liquid water component index.
Definition: ERF_DataStruct.H:168
Definition: ERF_PBLModels.H:416
bool enable_mrf_unbounded_vpert
Whether MRF leaves VPERT unlimited by GAMCRT.
Definition: ERF_TurbStruct.H:725
amrex::Real pbl_blend_length
Boutle blending length L [m]. 0 = off.
Definition: ERF_TurbStruct.H:717
bool pbl_mrf_use_zero_ri_extent
Whether MRF uses the Ri=0 K-profile extent.
Definition: ERF_TurbStruct.H:726
bool enable_mrf_cloud_adjustment
Whether MRF cloud-aware stability adjustments are enabled.
Definition: ERF_TurbStruct.H:723
amrex::Real pbl_mrf_const_b
MRF constant used to compute PBL height.
Definition: ERF_TurbStruct.H:712
bool mrf_moistvars
Whether MRF applies turbulence to moisture variables.
Definition: ERF_TurbStruct.H:721
amrex::Real pbl_blend_cs
Smagorinsky coeff for K_h ceiling.
Definition: ERF_TurbStruct.H:718
amrex::Real pbl_blend_c_max
Power-law ceiling coeff [m^(2/3)/s].
Definition: ERF_TurbStruct.H:719
bool enable_mrf_countergradient
Whether MRF countergradient corrections are enabled.
Definition: ERF_TurbStruct.H:722
bool pbl_mrf_highres_bounds
Whether MRF applies high-resolution grid-dependent diffusivity bounds.
Definition: ERF_TurbStruct.H:724
amrex::Real pbl_mrf_Ribcr
Critical bulk Richardson number for the MRF PBL scheme.
Definition: ERF_TurbStruct.H:711
amrex::Real pbl_mrf_sf
MRF surface flux value used to compute PBL height.
Definition: ERF_TurbStruct.H:713