central2.f90 Source File


Source Code

!> @file central2.f90
!> @brief Second-order central reconstruction scheme.

module central2
  use precision, only: wp
  implicit none
  private

  public :: central2_reconstruct

contains

  ! ---------------------------------------------------------------------------
  !> Second-order central reconstruction in physical space.
  !!
  !! Uses a 3-point stencil (half_stencil = 2, stencil_width = 3).
  !! For the positive (left-biased) stencil (indices: 1={i-1}, 2={i}, 3={i+1}):
  !!   F_hat^+ = 0.5 * (F^+_i + F^+_{i+1}) = 0.5*(stencil(:,2) + stencil(:,3))
  !!
  !! For the reversed negative stencil (indices: 1={i+2}, 2={i+1}, 3={i}):
  !!   F_hat^- = 0.5 * (F^-_{i+1} + F^-_i) = 0.5*(stencil(:,2) + stencil(:,3))
  !!   [identical formula; sum is commutative]
  !!
  !! Total numerical flux = F_hat^+ + F_hat^- = 0.5*(F_i + F_{i+1}).
  !!
  !! WARNING: Zero numerical dissipation. Stable only for smooth, periodic
  !! problems within the CFL stability region. Do not use for discontinuous
  !! or non-periodic problems.
  !!
  !! @param[in]  f_stencil  Stencil (neq x 3)
  !! @param[out] f_hat      Central flux at the interface
  ! ---------------------------------------------------------------------------
  pure subroutine central2_reconstruct(f_stencil, f_hat)
    real(wp), intent(in) :: f_stencil(:, :)
    real(wp), intent(out) :: f_hat(:)

    ! Average of centre (index 2) and the point toward the face (index 3).
    f_hat = 0.5_wp * (f_stencil(:, 2) + f_stencil(:, 3))
  end subroutine central2_reconstruct

end module central2