165 int klo = geom.Domain().smallEnd(2);
166 int khi = geom.Domain().bigEnd(2);
169 #pragma omp parallel if (Gpu::notInLaunchRegion())
171 for (MFIter mfi(eddyViscosity,
TileNoZ()); mfi.isValid(); ++mfi) {
174 const Box& gbx = mfi.growntilebox(IntVect(1,1,0));
176 gbx.bigEnd(2) ==
khi );
179 const GeometryData gdata = geom.data();
180 const Box xybx = PerpendicularBox<ZDir>(gbx, IntVect{0, 0, 0});
187 FArrayBox pbl_height_predictor(xybx, 1, The_Async_Arena());
188 FArrayBox pbl_height_corrector(xybx, 1, The_Async_Arena());
189 IArrayBox pbl_index(xybx, 1, The_Async_Arena());
190 IArrayBox pbl_index_zero_ri(xybx, 1, The_Async_Arena());
191 FArrayBox hgamt_fab(xybx, 1, The_Async_Arena());
192 FArrayBox hgamq_fab(xybx, 1, The_Async_Arena());
193 FArrayBox wstar_fab(xybx, 1, The_Async_Arena());
194 FArrayBox vpert_fab(xybx, 1, The_Async_Arena());
195 const auto& pblh_pred_arr = pbl_height_predictor.array();
196 const auto& pblh_corr_arr = pbl_height_corrector.array();
197 const auto& pbli_arr = pbl_index.array();
198 const auto& pbli_zero_arr = pbl_index_zero_ri.array();
199 const auto& hgamt_arr = hgamt_fab.array();
200 const auto& hgamq_arr = hgamq_fab.array();
201 const auto& wstar_arr = wstar_fab.array();
202 const auto& vpert_arr = vpert_fab.array();
205 const auto& cell_data = cons_in.const_array(mfi);
206 const auto& uvel =
xvel.const_array(mfi);
207 const auto& vvel =
yvel.const_array(mfi);
210 const auto& u_star_arr = SurfLayer->get_u_star(level)->const_array(mfi);
211 const auto& t_star_arr = SurfLayer->get_t_star(level)->const_array(mfi);
212 const auto& l_obuk_arr = SurfLayer->get_olen(level)->const_array(mfi);
213 const auto& t10av_arr = SurfLayer->get_mac_avg(level, 2)->const_array(mfi);
214 const auto& q10av_arr = SurfLayer->get_mac_avg(level, 3)->const_array(mfi);
215 const auto& lmask_arr = (SurfLayer->get_lmask(level)) ?
216 SurfLayer->get_lmask(level)->const_array(mfi) :
219 const Array4<Real const> z_nd_arr = use_terrain_fitted_coords ? z_phys_nd->array(mfi)
220 : Array4<Real const>{};
229 ParallelFor(xybx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int) noexcept
231 const Real t_layer = t10av_arr(i, j, 0);
233 const Real t_layer_v = t_layer * (
one +
epsv * moisture_fraction);
239 zval = (use_terrain_fitted_coords)
241 : (kpbl +
myhalf) * gdata.CellSize(2);
242 const Real theta_v =
GetThetav(i, j, kpbl, cell_data, moisture_indices);
244 const Real theta_v_klo = amrex::max(
GetThetav(i, j, klo, cell_data, moisture_indices),
Real(1.0));
245 const Real ws2_raw =
fourth * ( (uvel(i, j, kpbl) + uvel(i + 1, j, kpbl)) *
246 (uvel(i, j, kpbl) + uvel(i + 1, j, kpbl)) +
247 (vvel(i, j, kpbl) + vvel(i, j + 1, kpbl)) *
248 (vvel(i, j, kpbl) + vvel(i, j + 1, kpbl)) );
249 const Real ws2 = amrex::max(ws2_raw,
Real(1.0));
250 Rib =
CONST_GRAV * zval * (theta_v - t_layer_v) / (ws2 * theta_v_klo);
253 Real zval0 = zval, Rib0 = Rib;
254 bool above_critical =
false;
255 while (!above_critical && ((kpbl + 1) <=
khi)) {
260 zval = (use_terrain_fitted_coords)
262 : (kpbl +
myhalf) * gdata.CellSize(2);
263 const Real theta_v =
GetThetav(i, j, kpbl, cell_data, moisture_indices);
265 const Real theta_v_klo = amrex::max(
GetThetav(i, j, klo, cell_data, moisture_indices),
Real(1.0));
266 const Real ws2_raw =
fourth * ( (uvel(i, j, kpbl) + uvel(i + 1, j, kpbl)) *
267 (uvel(i, j, kpbl) + uvel(i + 1, j, kpbl)) +
268 (vvel(i, j, kpbl) + vvel(i, j + 1, kpbl)) *
269 (vvel(i, j, kpbl) + vvel(i, j + 1, kpbl)) );
270 const Real ws2 = amrex::max(ws2_raw,
Real(1.0));
271 Rib =
CONST_GRAV * zval * (theta_v - t_layer_v) / (ws2 * theta_v_klo);
272 above_critical = (Rib >= Ribcr);
275 const Real pblh_emp = (use_terrain_fitted_coords)
277 :
myhalf * gdata.CellSize(2);
278 const Real z_max = (use_terrain_fitted_coords)
281 const Real pblh_max =
Real(0.9) * z_max;
282 const Real pblh_min = amrex::max(pblh_emp,
Real(10.0));
284 if (above_critical) {
287 const Real rib_diff = Rib - Rib0;
288 if (std::abs(rib_diff) >
Real(1.0e-10)) {
289 pblh_interp = zval0 + (zval - zval0) / rib_diff * (Ribcr - Rib0);
294 pblh_pred_arr(i, j, 0) = amrex::max(amrex::min(pblh_interp, pblh_max), pblh_min);
295 pbli_arr(i, j, 0) = kpbl;
297 pblh_pred_arr(i, j, 0) = pblh_min;
298 pbli_arr(i, j, 0) = klo + 1;
304 amrex::MultiFab* q_star_mf = SurfLayer->get_q_star(level);
305 Array4<Real const> q_star_arr = (q_star_mf !=
nullptr) ? q_star_mf->const_array(mfi)
306 : Array4<Real const>{};
313 constexpr
Real GAMCRQ =
Real(2.e-3);
324 ParallelFor(xybx, [=,zero_d=
zero] AMREX_GPU_DEVICE(
int i,
int j,
int) noexcept
326 const Real t_layer = t10av_arr(i, j, 0);
327 Real obuk_val = l_obuk_arr(i, j, 0);
333 const Real HOL = sf * pblh_pred_arr(i, j, 0) / obuk_val;
334 const Real HOL_bounded = amrex::max(amrex::min(HOL,
Real(100.0)),
Real(-100.0));
335 const Real one_quarter =
Real(0.25);
336 const Real phiM = (obuk_val > 0)
337 ? (1 + 5 * HOL_bounded)
338 : std::pow(amrex::max(1 - 16 * HOL_bounded,
Real(0.01)), -one_quarter);
339 const Real phiM_safe = amrex::max(phiM,
Real(0.01));
344 Real wstar = u_star_arr(i, j, 0) / phiM_safe;
345 wstar = amrex::max(wstar,
Real(0.01));
346 wstar = amrex::min(wstar,
Real(5.0));
348 bool SFCFLG = (obuk_val <= zero_d);
349 const Real HGAMT = (SFCFLG && enable_mrf_countergradient)
350 ? amrex::min(-const_b * u_star_arr(i, j, 0) * t_star_arr(i, j, 0) / wstar, GAMCRT)
354 if (SFCFLG &&
use_moisture && enable_mrf_countergradient) {
355 const Real q_star = q_star_arr(i, j, 0);
356 const Real HGAMQ_calc = -const_b * u_star_arr(i, j, 0) * q_star / wstar;
357 HGAMQ = amrex::max(amrex::min(HGAMQ_calc, GAMCRQ),
Real(0));
360 bool is_land = (lmask_arr(i,j,0) == 1);
361 if (!is_land) HGAMQ = zero_d;
364 if (moisture_indices.
qv >= 0) {
365 Real qv_klo = cell_data(i, j, klo, moisture_indices.
qv) / cell_data(i, j, klo,
Rho_comp);
369 Real qsat_klo = zero_d;
371 Real rh_klo = (qsat_klo >
Real(1.0e-10)) ? (qv_klo / qsat_klo) :
Real(0);
372 if (rh_klo >
Real(0.95)) {
373 Real rh_scaling = amrex::max(zero_d, (
Real(1) - rh_klo) /
Real(0.05));
382 if (pbli_arr(i, j, 0) <= klo + 1 || !enable_mrf_countergradient) {
383 vpert_arr(i, j, 0) = zero_d;
385 const Real VPERT_raw = HGAMT +
epsv * t_layer * HGAMQ;
386 const Real VPERT_capped = enable_mrf_unbounded_vpert
388 : amrex::min(VPERT_raw, GAMCRT);
389 vpert_arr(i, j, 0) = amrex::max(VPERT_capped, zero_d);
402 AMREX_GPU_DEVICE(
int i,
int j,
int) noexcept
404 const Real t_layer = t10av_arr(i, j, 0);
407 const Real t_layer_v = t_layer * (
one +
epsv * moisture_fraction)
408 + vpert_arr(i, j, 0);
410 Real obuk_val = l_obuk_arr(i, j, 0);
418 zval = (use_terrain_fitted_coords)
420 : (kpbl +
myhalf) * gdata.CellSize(2);
421 const Real theta_v =
GetThetav(i, j, kpbl, cell_data, moisture_indices);
423 const Real theta_v_klo = amrex::max(
GetThetav(i, j, klo, cell_data, moisture_indices), one_d);
424 const Real ws2_raw =
fourth * ( (uvel(i, j, kpbl) + uvel(i + 1, j, kpbl)) *
425 (uvel(i, j, kpbl) + uvel(i + 1, j, kpbl)) +
426 (vvel(i, j, kpbl) + vvel(i, j + 1, kpbl)) *
427 (vvel(i, j, kpbl) + vvel(i, j + 1, kpbl)) );
428 const Real ws2 = amrex::max(ws2_raw, one_d);
429 Rib =
CONST_GRAV * zval * (theta_v - t_layer_v) / (ws2 * theta_v_klo);
431 Real zval0 = zval, Rib0 = Rib;
433 bool above_critical =
false;
434 while (!above_critical && ((kpbl + 1) <=
khi)) {
439 zval = (use_terrain_fitted_coords)
441 : (kpbl +
myhalf) * gdata.CellSize(2);
442 const Real theta_v =
GetThetav(i, j, kpbl, cell_data, moisture_indices);
444 const Real theta_v_klo = amrex::max(
GetThetav(i, j, klo, cell_data, moisture_indices), one_d);
445 const Real ws2_raw =
fourth * ( (uvel(i, j, kpbl) + uvel(i + 1, j, kpbl)) *
446 (uvel(i, j, kpbl) + uvel(i + 1, j, kpbl)) +
447 (vvel(i, j, kpbl) + vvel(i, j + 1, kpbl)) *
448 (vvel(i, j, kpbl) + vvel(i, j + 1, kpbl)) );
449 const Real ws2 = amrex::max(ws2_raw, one_d);
450 Rib =
CONST_GRAV * zval * (theta_v - t_layer_v) / (ws2 * theta_v_klo);
451 above_critical = (Rib >= Ribcr);
454 const Real pblh_emp = (use_terrain_fitted_coords)
456 :
myhalf * gdata.CellSize(2);
457 const Real z_max = (use_terrain_fitted_coords)
460 const Real pblh_max =
Real(0.9) * z_max;
461 const Real pblh_min = amrex::max(pblh_emp,
Real(10.0));
463 if (above_critical) {
466 const Real rib_diff = Rib - Rib0;
467 if (std::abs(rib_diff) >
Real(1.0e-10)) {
468 pblh_interp = zval0 + (zval - zval0) / rib_diff * (Ribcr - Rib0);
473 pblh_corr_arr(i, j, 0) = amrex::max(amrex::min(pblh_interp, pblh_max), pblh_min);
474 pbli_arr(i, j, 0) = kpbl;
476 pblh_corr_arr(i, j, 0) = pblh_min;
477 pbli_arr(i, j, 0) = klo + 1;
488 ParallelFor(xybx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int) noexcept
491 Real obuk_val = l_obuk_arr(i, j, 0);
497 const Real HOL = sf * pblh_corr_arr(i, j, 0) / obuk_val;
498 const Real HOL_bounded = amrex::max(amrex::min(HOL,
Real(100.0)),
Real(-100.0));
499 const Real one_quarter =
Real(0.25);
500 const Real phiM = (obuk_val > 0)
501 ? (1 + 5 * HOL_bounded)
502 : std::pow(amrex::max(1 - 16 * HOL_bounded,
Real(0.01)), -one_quarter);
503 const Real phiM_safe = amrex::max(phiM,
Real(0.01));
506 Real wstar = u_star_arr(i, j, 0) / phiM_safe;
507 wstar = amrex::max(wstar,
Real(0.01));
508 wstar = amrex::min(wstar,
Real(5.0));
509 wstar_arr(i, j, 0) = wstar;
511 bool SFCFLG = (obuk_val <=
Real(0));
512 const Real HGAMT = (SFCFLG && enable_mrf_countergradient)
513 ? amrex::min(-const_b * u_star_arr(i, j, 0) * t_star_arr(i, j, 0) / wstar, GAMCRT)
517 if (SFCFLG &&
use_moisture && enable_mrf_countergradient) {
518 const Real q_star = q_star_arr(i, j, 0);
519 const Real HGAMQ_calc = -const_b * u_star_arr(i, j, 0) * q_star / wstar;
520 HGAMQ = amrex::max(amrex::min(HGAMQ_calc, GAMCRQ),
Real(0));
523 bool is_land = (lmask_arr(i,j,0) == 1);
524 if (!is_land) HGAMQ =
Real(0);
527 if (moisture_indices.
qv >= 0) {
528 Real qv_klo = cell_data(i, j, klo, moisture_indices.
qv) / cell_data(i, j, klo,
Rho_comp);
534 Real rh_klo = (qsat_klo >
Real(1.0e-10)) ? (qv_klo / qsat_klo) :
Real(0);
535 if (rh_klo >
Real(0.95)) {
542 if (pbli_arr(i, j, 0) <= klo + 1) {
543 hgamt_arr(i, j, 0) =
Real(0);
544 hgamq_arr(i, j, 0) =
Real(0);
546 const Real pblh = pblh_corr_arr(i, j, 0);
548 if (pblh >
Real(1.0e-10)) {
549 hgamt_arr(i, j, 0) = (enable_mrf_countergradient) ? HGAMT / pblh :
Real(0);
550 hgamq_arr(i, j, 0) = (enable_mrf_countergradient &&
use_moisture) ? HGAMQ / pblh :
Real(0);
552 hgamt_arr(i, j, 0) =
Real(0);
553 hgamq_arr(i, j, 0) =
Real(0);
564 constexpr
Real Ribcr_zero =
Real(0);
566 AMREX_GPU_DEVICE(
int i,
int j,
int) noexcept
568 const Real t_layer = t10av_arr(i, j, 0);
570 const Real t_layer_v = t_layer * (
one +
epsv * moisture_fraction);
571 const Real t_layer_v_enhanced = t_layer_v + vpert_arr(i, j, 0);
574 Real zval_zero, Rib_zero;
576 zval_zero = (use_terrain_fitted_coords)
578 : (kpbl_zero +
myhalf) * gdata.CellSize(2);
579 const Real theta_v =
GetThetav(i, j, kpbl_zero, cell_data, moisture_indices);
581 const Real theta_v_klo = amrex::max(
GetThetav(i, j, klo, cell_data, moisture_indices), one_d);
582 const Real ws2_raw =
fourth * ( (uvel(i, j, kpbl_zero) + uvel(i + 1, j, kpbl_zero)) *
583 (uvel(i, j, kpbl_zero) + uvel(i + 1, j, kpbl_zero)) +
584 (vvel(i, j, kpbl_zero) + vvel(i, j + 1, kpbl_zero)) *
585 (vvel(i, j, kpbl_zero) + vvel(i, j + 1, kpbl_zero)) );
586 const Real ws2 = amrex::max(ws2_raw, one_d);
587 Rib_zero =
CONST_GRAV * zval_zero * (theta_v - t_layer_v_enhanced) / (ws2 * theta_v_klo);
590 bool above_critical_zero =
false;
591 while (!above_critical_zero && ((kpbl_zero + 1) <=
khi)) {
593 zval_zero = (use_terrain_fitted_coords)
595 : (kpbl_zero +
myhalf) * gdata.CellSize(2);
596 const Real theta_v =
GetThetav(i, j, kpbl_zero, cell_data, moisture_indices);
598 const Real theta_v_klo = amrex::max(
GetThetav(i, j, klo, cell_data, moisture_indices), one_d);
599 const Real ws2_raw =
fourth * ( (uvel(i, j, kpbl_zero) + uvel(i + 1, j, kpbl_zero)) *
600 (uvel(i, j, kpbl_zero) + uvel(i + 1, j, kpbl_zero)) +
601 (vvel(i, j, kpbl_zero) + vvel(i, j + 1, kpbl_zero)) *
602 (vvel(i, j, kpbl_zero) + vvel(i, j + 1, kpbl_zero)) );
603 const Real ws2 = amrex::max(ws2_raw, one_d);
604 Rib_zero =
CONST_GRAV * zval_zero * (theta_v - t_layer_v_enhanced) / (ws2 * theta_v_klo);
605 above_critical_zero = (Rib_zero >= Ribcr_zero);
608 if (above_critical_zero) {
609 pbli_zero_arr(i, j, 0) = kpbl_zero;
611 pbli_zero_arr(i, j, 0) = klo + 1;
617 const Array4<Real>& K_turb = eddyViscosity.array(mfi);
626 const auto&
dxInv = geom.InvCellSizeArray();
627 const Real dz_inv = geom.InvCellSize(2);
628 const int izmin = geom.Domain().smallEnd(2);
629 const int izmax = geom.Domain().bigEnd(2);
631 ParallelFor(gbx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) noexcept
633 Real obuk_val = l_obuk_arr(i, j, 0);
638 const Real zval = (use_terrain_fitted_coords)
640 : (k +
myhalf) * gdata.CellSize(2);
653 const Real met_h_zeta = (use_terrain_fitted_coords)
655 const Real dz_terrain = met_h_zeta / dz_inv;
657 constexpr
Real qc_threshold =
Real(1.0e-4);
661 if (moisture_indices.
qc >= 0) {
662 qc_mix = cell_data(i, j, k, moisture_indices.
qc) /
rho;
664 if (moisture_indices.
qi >= 0) {
665 qi_mix = cell_data(i, j, k, moisture_indices.
qi) /
rho;
668 const Real total_qcloud = qc_mix + qi_mix;
673 if (k < pbli_extent) {
674 bool SFCFLG = (obuk_val <=
Real(0));
676 const Real HOL = sf * pblh_corr_arr(i, j, 0) / obuk_val;
677 const Real HOL_bounded = amrex::max(amrex::min(HOL,
Real(100.0)),
Real(-100.0));
679 const Real one_quarter =
Real(0.25);
680 const Real phiM = (obuk_val > 0)
681 ? (1 + 5 * HOL_bounded)
682 : std::pow(amrex::max(1 - 16 * HOL_bounded,
Real(0.01)), -one_quarter);
683 const Real phit = (obuk_val > 0)
684 ? (1 + 5 * HOL_bounded)
685 : std::pow(amrex::max(1 - 16 * HOL_bounded,
Real(0.01)), -
Real(0.5));
687 Real phit_cloud = phit;
688 Real phiM_cloud = phiM;
689 if (has_cloud && obuk_val >
Real(0)) {
690 Real reduction_factor =
Real(1) -
Real(0.15) * amrex::min(total_qcloud / qc_threshold,
Real(1));
691 phiM_cloud =
Real(1) +
Real(5.0) * reduction_factor * sf * pblh_corr_arr(i, j, 0) / obuk_val;
692 phit_cloud =
Real(1) +
Real(5.0) * reduction_factor * sf * pblh_corr_arr(i, j, 0) / obuk_val;
693 }
else if (has_cloud && obuk_val <=
Real(0)) {
694 Real cloud_boost =
Real(1.0) +
Real(0.05) * amrex::min(total_qcloud / qc_threshold,
Real(1));
695 phiM_cloud = std::pow(amrex::max(
Real(1) -
Real(16.0) * HOL_bounded / cloud_boost,
Real(0.01)), -one_quarter);
696 phit_cloud = std::pow(amrex::max(
Real(1) -
Real(16.0) * HOL_bounded / cloud_boost,
Real(0.01)), -
Real(0.5));
699 const Real phiM_eff = phiM_cloud;
700 const Real phit_eff = phit_cloud;
702 Real Prt_base = phit_eff / phiM_eff;
703 const Real Prt = amrex::min(amrex::max(Prt_base + const_b *
KAPPA * sf, prmin), prmax);
705 const Real wstar = wstar_arr(i, j, 0);
710 const Real z_sfc = (use_terrain_fitted_coords)
713 const Real zrel = zval - z_sfc;
714 const Real pblh = pblh_corr_arr(i, j, 0);
715 const Real pblh_rel = pblh - z_sfc;
716 const Real zfac = amrex::max(
Real(1) - zrel / pblh_rel,
Real(1.0e-8));
722 Real Prq_base = phit_eff / phiM_eff;
723 const Real Prq = amrex::min(amrex::max(Prq_base + const_b *
KAPPA * sf, prmin), prmax);
730 const Real lscale = (
KAPPA * zval * lambda) / (
KAPPA * zval + lambda);
731 Real dthetadz, dudz, dvdz;
732 ComputeVerticalDerivativesPBL(i, j, k, uvel, vvel, cell_data, izmin, izmax, pbl_derivative_dz_inv(i,j,k),
733 c_ext_dir_on_zlo, c_ext_dir_on_zhi, u_ext_dir_on_zlo,
734 u_ext_dir_on_zhi, v_ext_dir_on_zlo, v_ext_dir_on_zhi, dthetadz,
735 dudz, dvdz, moisture_indices);
737 const Real dudz_safe = (k < izmax) ? dudz :
Real(0);
738 const Real dvdz_safe = (k < izmax) ? dvdz :
Real(0);
739 const Real wind_shear = dudz_safe * dudz_safe + dvdz_safe * dvdz_safe;
740 const Real wind_shear_safe = std::max(wind_shear,
Real(1.0e-8));
743 const Real theta_v = amrex::max(
GetThetav(i, j, k, cell_data, moisture_indices),
Real(1.0));
744 const Real dtheta_v_dz = dthetadz;
746 Real grad_Ri =
CONST_GRAV / theta_v * dtheta_v_dz / wind_shear_safe;
747 grad_Ri = std::max(std::min(grad_Ri,
Real(100.0)), -
Real(100.0));
749 const Real grad_Ri_safe = amrex::max(grad_Ri, -
Real(100.0));
751 const Real fm = (grad_Ri_safe > 0)
753 : 1 - 8 * grad_Ri_safe / (1 +
Real(1.746) * std::sqrt(amrex::max(-grad_Ri_safe,
Real(0))));
754 const Real ft = (grad_Ri_safe > 0)
756 : 1 - 8 * grad_Ri_safe / (1 +
Real(1.286) * std::sqrt(amrex::max(-grad_Ri_safe,
Real(0))));
757 const Real rl2wsp =
rho * lscale * lscale * std::sqrt(wind_shear);
769 }
else if (k >= pbli_extent) {
771 const Real lscale = (
KAPPA * zval * lambda) / (
KAPPA * zval + lambda);
772 Real dthetadz, dudz, dvdz;
773 ComputeVerticalDerivativesPBL(i, j, k, uvel, vvel, cell_data, izmin, izmax, pbl_derivative_dz_inv(i,j,k),
774 c_ext_dir_on_zlo, c_ext_dir_on_zhi, u_ext_dir_on_zlo,
775 u_ext_dir_on_zhi, v_ext_dir_on_zlo, v_ext_dir_on_zhi, dthetadz,
776 dudz, dvdz, moisture_indices);
778 const Real dudz_safe = (k < izmax) ? dudz :
Real(0);
779 const Real dvdz_safe = (k < izmax) ? dvdz :
Real(0);
780 const Real wind_shear = dudz_safe * dudz_safe + dvdz_safe * dvdz_safe;
781 const Real wind_shear_safe = std::max(wind_shear,
Real(1.0e-8));
784 const Real theta_v = amrex::max(
GetThetav(i, j, k, cell_data, moisture_indices),
Real(1.0));
785 const Real dtheta_v_dz = dthetadz;
787 Real grad_Ri =
CONST_GRAV / theta_v * dtheta_v_dz / wind_shear_safe;
788 grad_Ri = std::max(std::min(grad_Ri,
Real(100.0)), -
Real(100.0));
790 const Real grad_Ri_safe = amrex::max(grad_Ri, -
Real(100.0));
792 const Real fm = (grad_Ri_safe > 0)
794 : 1 - 8 * grad_Ri_safe / (1 +
Real(1.746) * std::sqrt(amrex::max(-grad_Ri_safe,
Real(0))));
795 const Real ft = (grad_Ri_safe > 0)
797 : 1 - 8 * grad_Ri_safe / (1 +
Real(1.286) * std::sqrt(amrex::max(-grad_Ri_safe,
Real(0))));
798 const Real rl2wsp =
rho * lscale * lscale * std::sqrt(wind_shear);
814 Real rhoKmin, rhoKmax;
818 rhoKmin = ckz * dz_terrain *
rho;
819 rhoKmax =
rho * Kmax;
823 rhoKmin =
rho * Kmin;
824 rhoKmax =
rho * Kmax;
835 if (k < pbli_extent) {
845 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(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_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
TurbChoice turbChoice
Definition: ERF_SetupVertDiff.H:6
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:248
@ Theta_v
Definition: ERF_IndexDefines.H:211
@ Turb_lengthscale
Definition: ERF_IndexDefines.H:215
@ Q_v
Definition: ERF_IndexDefines.H:214
@ Mom_v
Definition: ERF_IndexDefines.H:210
@ HGAMQ_v
Definition: ERF_IndexDefines.H:217
@ HGAMT_v
Definition: ERF_IndexDefines.H:216
@ xvel
Definition: ERF_IndexDefines.H:176
@ yvel
Definition: ERF_IndexDefines.H:177
int qi
Definition: ERF_DataStruct.H:109
int qv
Definition: ERF_DataStruct.H:107
int qc
Definition: ERF_DataStruct.H:108
Definition: ERF_PBLModels.H:416
bool pbl_mrf_use_zero_ri_extent
Definition: ERF_TurbStruct.H:636
amrex::Real pbl_mrf_const_b
Definition: ERF_TurbStruct.H:629
bool enable_mrf_unbounded_vpert
Definition: ERF_TurbStruct.H:635
amrex::Real pbl_mrf_Ribcr
Definition: ERF_TurbStruct.H:628
amrex::Real pbl_mrf_sf
Definition: ERF_TurbStruct.H:630
bool enable_mrf_countergradient
Definition: ERF_TurbStruct.H:632
bool mrf_moistvars
Definition: ERF_TurbStruct.H:631
bool enable_mrf_cloud_adjustment
Definition: ERF_TurbStruct.H:633
bool pbl_mrf_highres_bounds
Definition: ERF_TurbStruct.H:634