ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_PBLRibCrossing.H File Reference
#include <AMReX_REAL.H>
#include <AMReX_GpuQualifiers.H>
#include <AMReX_Algorithm.H>
Include dependency graph for ERF_PBLRibCrossing.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  RibCrossing
 

Functions

template<typename RibAt , typename ZAt >
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE RibCrossing find_rib_crossing (int ksrf, int khi, amrex::Real Ribcr, RibAt const &rib_at, ZAt const &z_at, amrex::Real pblh_min, amrex::Real pblh_max) noexcept
 

Function Documentation

◆ find_rib_crossing()

template<typename RibAt , typename ZAt >
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE RibCrossing find_rib_crossing ( int  ksrf,
int  khi,
amrex::Real  Ribcr,
RibAt const &  rib_at,
ZAt const &  z_at,
amrex::Real  pblh_min,
amrex::Real  pblh_max 
)
noexcept

Find the PBL height where the bulk Richardson number first reaches Ribcr, scanning one column from its surface cell ksrf up to the top cell khi (YSU, Hong et al. 2006; WRF bl_ysu.F90, the "brint" interpolation).

  • The scan looks for the first level k in (ksrf, khi] with Rib >= Ribcr. The surface value Rib(ksrf) only seeds the lower end of the first interval, as WRF's br does: a surface cell above Ribcr does not stop the scan by itself.
  • If Rib(ksrf) and Rib(ksrf+1) are both at or above Ribcr, the height is z(ksrf) and kpbl = ksrf (WRF: brint = 0); with the bounds below this is pblh_min.
  • Otherwise the height is interpolated linearly in Rib between k-1, the last level below Ribcr, and k. The two levels bracket Ribcr, so the Rib difference is positive.
  • No crossing up to khi: the height is the top of the scan, z(khi), and kpbl = khi (WRF: brint = 1). The pblh_max cap then applies.

Every height is then kept in [pblh_min, pblh_max] in that order, so pblh_min wins when a shallow column has pblh_max < pblh_min.

Parameters
[in]ksrffirst fluid cell of the column
[in]khitop cell of the scan
[in]Ribcrcritical bulk Richardson number
[in]rib_atcallable, rib_at(k) gives the bulk Richardson number at level k
[in]z_atcallable, z_at(k) gives the height of level k
[in]pblh_minlower bound on the height
[in]pblh_maxupper bound on the height
53 {
54  amrex::Real rib_lo = rib_at(ksrf);
55  amrex::Real z_lo = z_at(ksrf);
56  for (int k = ksrf + 1; k <= khi; ++k) {
57  const amrex::Real rib_k = rib_at(k);
58  const amrex::Real z_k = z_at(k);
59  if (rib_k >= Ribcr) {
60  if (rib_lo >= Ribcr) {
61  // only possible for k = ksrf + 1: both surface levels at or above Ribcr
62  return RibCrossing{ksrf, amrex::max(amrex::min(z_lo, pblh_max), pblh_min), true};
63  }
64  const amrex::Real pblh = z_lo + (z_k - z_lo) / (rib_k - rib_lo) * (Ribcr - rib_lo);
65  return RibCrossing{k, amrex::max(amrex::min(pblh, pblh_max), pblh_min), true};
66  }
67  rib_lo = rib_k;
68  z_lo = z_k;
69  }
70  return RibCrossing{khi, amrex::max(amrex::min(z_lo, pblh_max), pblh_min), false};
71 }
const int khi
Definition: ERF_InitCustomPert_Bubble.H:25
amrex::Real Real
Definition: ERF_ShocInterface.H:19
Definition: ERF_PBLRibCrossing.H:11

Referenced by ComputeDiffusivityYSUNew().

Here is the caller graph for this function: