metrics_bt_cfl_length Function

public pure function metrics_bt_cfl_length(metrics, grid) result(l_cfl)

2-D external-gravity-wave CFL length over the PHYSICAL region: l_cfl = min_cell 1 / sqrt(1/dxT^2 + 1/dyT^2). Length scale for the barotropic CFL c_ext*dt*sqrt(1/dx^2+1/dy^2) <= 1 (includes the cross-direction term; on uniform Cartesian = dx/sqrt(2)). Handles anisotropic cells exactly. Host-side, configure time.

Arguments

Type IntentOptional Attributes Name
type(ocean_metrics_t), intent(in) :: metrics
type(hgrid_t), intent(in) :: grid

Return Value real(kind=wp)


Variables

Type Visibility Attributes Name Initial
integer, private :: i0
integer, private :: i1
real(kind=wp), private :: inv_l2_max
integer, private :: j0
integer, private :: j1
integer, private :: ng

Source Code

   pure function metrics_bt_cfl_length(metrics, grid) result(l_cfl)
      !! 2-D external-gravity-wave CFL length over the PHYSICAL region:
      !!     l_cfl = min_cell  1 / sqrt(1/dxT^2 + 1/dyT^2).
      !! Length scale for the barotropic CFL `c_ext*dt*sqrt(1/dx^2+1/dy^2) <= 1`
      !! (includes the cross-direction term; on uniform Cartesian = dx/sqrt(2)).
      !! Handles anisotropic cells exactly.  Host-side, configure time.
      type(ocean_metrics_t), intent(in) :: metrics
      type(hgrid_t), intent(in) :: grid
      real(wp) :: l_cfl, inv_l2_max
      integer :: ng, i0, i1, j0, j1
      ng = grid%nghost
      i0 = ng + 1
      i1 = ng + grid%nx_phys
      j0 = ng + 1
      j1 = ng + grid%ny_phys
      inv_l2_max = maxval(1.0_wp/metrics%dxT(i0:i1, j0:j1)**2 &
                          + 1.0_wp/metrics%dyT(i0:i1, j0:j1)**2)
      l_cfl = 1.0_wp/sqrt(inv_l2_max)
   end function metrics_bt_cfl_length