Precompute the constant Smith & McWilliams (2003) direction-
tensor factors from the anisotropy direction vector (n1,n2)
(grid-relative i,j components). Normalises by n1²+n2² so the
caller need not pass a unit vector:
n1n2 = 2·n1·n2 / (n1²+n2²)
n1n1_m_n2n2 = (n1²−n2²) / (n1²+n2²)
The default grid-i direction (1,0) gives n1n2 = 0,
n1n1_m_n2n2 = 1 — the cross terms vanish and only the tension
coefficient picks up kh_aniso. A degenerate (0,0) vector
leaves the factors at their defaults (n1n2=0,
n1n1_m_n2n2=1), i.e. grid-i.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(ocean_horizontal_viscosity_t), | intent(inout) | :: | this | |||
| real(kind=wp), | intent(in) | :: | n1 | |||
| real(kind=wp), | intent(in) | :: | n2 |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=wp), | private | :: | recip_norm |
pure subroutine ocean_hvisc_set_aniso_direction(this, n1, n2) !! Precompute the constant Smith & McWilliams (2003) direction- !! tensor factors from the anisotropy direction vector `(n1,n2)` !! (grid-relative i,j components). Normalises by `n1²+n2²` so the !! caller need not pass a unit vector: !! !! n1n2 = 2·n1·n2 / (n1²+n2²) !! n1n1_m_n2n2 = (n1²−n2²) / (n1²+n2²) !! !! The default grid-i direction `(1,0)` gives `n1n2 = 0`, !! `n1n1_m_n2n2 = 1` — the cross terms vanish and only the tension !! coefficient picks up `kh_aniso`. A degenerate `(0,0)` vector !! leaves the factors at their defaults (`n1n2=0`, !! `n1n1_m_n2n2=1`), i.e. grid-i. class(ocean_horizontal_viscosity_t), intent(inout) :: this real(wp), intent(in) :: n1, n2 real(wp) :: recip_norm recip_norm = (n1*n1) + (n2*n2) if (recip_norm > 0.0_wp) then recip_norm = 1.0_wp/recip_norm this%aniso_n1n2 = 2.0_wp*(n1*n2)*recip_norm this%aniso_n1n1_m_n2n2 = ((n1*n1) - (n2*n2))*recip_norm else this%aniso_n1n2 = 0.0_wp this%aniso_n1n1_m_n2n2 = 1.0_wp end if end subroutine ocean_hvisc_set_aniso_direction