hvisc_avg_A_face Subroutine

private pure subroutine hvisc_avg_A_face(ah_face_x, ah_face_y, ah_t, ah_q, nx, ny, nz)

Average the per-face harmonic viscosity (ah_face_x at u-faces, ah_face_y at v-faces) onto the T-cell centres (ah_t) and the Bu corners (ah_q). The stress form needs A co-located with the tension (T-cell) and shear (corner) strains; the lateral-mix closure produces A at faces, so this is a 4-point face→cell / face→corner reduction. On a uniform A field every average returns A, preserving the Laplacian reduction.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: ah_face_x(nx+1,ny,nz)
real(kind=wp), intent(in) :: ah_face_y(nx,ny+1,nz)
real(kind=wp), intent(out) :: ah_t(nx,ny,nz)
real(kind=wp), intent(out) :: ah_q(nx+1,ny+1,nz)
integer, intent(in) :: nx
integer, intent(in) :: ny
integer, intent(in) :: nz

Called by

proc~~hvisc_avg_a_face~~CalledByGraph proc~hvisc_avg_a_face hvisc_avg_A_face proc~ocean_horizontal_viscosity_compute_tendencies_on ocean_horizontal_viscosity_compute_tendencies_on proc~ocean_horizontal_viscosity_compute_tendencies_on->proc~hvisc_avg_a_face proc~ocean_horizontal_viscosity_compute_tendencies ocean_horizontal_viscosity_compute_tendencies proc~ocean_horizontal_viscosity_compute_tendencies->proc~ocean_horizontal_viscosity_compute_tendencies_on proc~run_stage run_stage proc~run_stage->proc~ocean_horizontal_viscosity_compute_tendencies proc~run_stage_split run_stage_split proc~run_stage_split->proc~ocean_horizontal_viscosity_compute_tendencies proc~ocean_dyn_step ocean_dyn_step proc~ocean_dyn_step->proc~run_stage proc~ocean_dyn_step_split ocean_dyn_step_split proc~ocean_dyn_step_split->proc~run_stage_split proc~engine_step engine_step proc~engine_step->proc~ocean_dyn_step proc~engine_step->proc~ocean_dyn_step_split

Variables

Type Visibility Attributes Name Initial
integer, private :: i
integer, private :: j
integer, private :: k

Source Code

   pure subroutine hvisc_avg_A_face(ah_face_x, ah_face_y, ah_t, ah_q, nx, ny, nz)
      !! Average the per-face harmonic viscosity (`ah_face_x` at
      !! u-faces, `ah_face_y` at v-faces) onto the T-cell centres
      !! (`ah_t`) and the Bu corners (`ah_q`).  The stress form needs A
      !! co-located with the tension (T-cell) and shear (corner)
      !! strains; the lateral-mix closure produces A at faces, so this
      !! is a 4-point face→cell / face→corner reduction.  On a uniform A
      !! field every average returns A, preserving the Laplacian
      !! reduction.
      integer, intent(in)  :: nx, ny, nz
      real(wp), intent(in)  :: ah_face_x(nx + 1, ny, nz), ah_face_y(nx, ny + 1, nz)
      real(wp), intent(out) :: ah_t(nx, ny, nz), ah_q(nx + 1, ny + 1, nz)
      integer :: i, j, k
      ! T-cell (i,j): mean of its west/east u-faces (i, i+1) and
      ! south/north v-faces (j, j+1).
      do concurrent(k=1:nz, j=1:ny, i=1:nx)
         ah_t(i, j, k) = 0.25_wp*((ah_face_x(i, j, k) + ah_face_x(i + 1, j, k)) + &
                                  (ah_face_y(i, j, k) + ah_face_y(i, j + 1, k)))
      end do
      ! Bu corner (i,j) = SW corner of cell (i,j): mean of the two
      ! u-faces sharing it (i, j) & (i, j-1) and the two v-faces
      ! (i, j) & (i-1, j).  Interior corners only; the divergence
      ! stencil never reads the outermost corner ring.
      do concurrent(k=1:nz, j=2:ny, i=2:nx)
         ah_q(i, j, k) = 0.25_wp*((ah_face_x(i, j, k) + ah_face_x(i, j - 1, k)) + &
                                  (ah_face_y(i, j, k) + ah_face_y(i - 1, j, k)))
      end do
      do concurrent(k=1:nz, j=1:ny + 1)
         ah_q(1, j, k) = 0.0_wp
         ah_q(nx + 1, j, k) = 0.0_wp
      end do
      do concurrent(k=1:nz, i=1:nx + 1)
         ah_q(i, 1, k) = 0.0_wp
         ah_q(i, ny + 1, k) = 0.0_wp
      end do
   end subroutine hvisc_avg_A_face