!---------------------------------------------------------------------
!     Copyright (C) GFD Dennou Club, 2005. All rights reserved.
!---------------------------------------------------------------------
!= Module NumDiffusion
!
!   * Developer: SUGIYAMA Ko-ichiro
!   * Version: $Id: $
!   * Tag Name: $Name:  $
!   * Change History: 
!
!== Overview
!
!数値拡散の計算を行うための関数を束ねたモジュール
! 
!== Error Handling
!
!== Bugs
!
!== Note
!
!== Future Plans
!
!

module NumDiffusion

  interface ss_NumDiffX_ss
    function ss_NumDiffX_ss(ss_Scalar)
      use gridset
      real(8), intent(in) :: ss_Scalar(DimXMin:DimXMax, DimZMin:DimZMax)
                                                        !スカラー量
      real(8)             :: ss_NumDiffX_ss(DimXMin:DimXMax, DimZMin:DimZMax)
                                                        !水平方向の数値拡散
    end function ss_NumDiffX_ss
  end interface

  interface ss_NumDiffZ_ss
    function ss_NumDiffZ_ss(ss_Scalar)
      use gridset
      real(8), intent(in) :: ss_Scalar(DimXMin:DimXMax, DimZMin:DimZMax)
                                                        !スカラー量
      real(8)             :: ss_NumDiffZ_ss(DimXMin:DimXMax, DimZMin:DimZMax)
                                                        !鉛直方向の数値拡散
    end function ss_NumDiffZ_ss
  end interface

end module NumDiffusion


function ss_NumDiffX_ss(ss_Scalar)
  !
  ! スカラー量の水平方向の数値拡散を計算
  !
  use gridset, only: DimXMin, DimXMax, DimZMin, DimZMax
  use differentiate_center4, only: ss_dx_fs, fs_dx_ss, ss_dz_sf, sf_dz_ss
  use arareset, only: NuH
  implicit none
  
  real(8), intent(in) :: ss_Scalar(DimXMin:DimXMax, DimZMin:DimZMax)
                                                        !スカラー量
  real(8)             :: ss_NumDiffX_ss(DimXMin:DimXMax, DimZMin:DimZMax)
                                                        !水平方向の数値拡散
    
  ss_NumDiffX_ss = 0.0d0  !初期化
  ss_NumDiffX_ss = NuH * (ss_dx_fs(fs_dx_ss( ss_Scalar )))
    
end function ss_NumDiffX_ss


function ss_NumDiffZ_ss(ss_Scalar)
  !
  ! スカラー量の鉛直方向の数値拡散を計算
  !
  use gridset, only: DimXMin, DimXMax, DimZMin, DimZMax
  use differentiate_center4, only: ss_dx_fs, fs_dx_ss, ss_dz_sf, sf_dz_ss
  use arareset, only: NuV
  implicit none
  
  real(8), intent(in) :: ss_Scalar(DimXMin:DimXMax, DimZMin:DimZMax)
                                                        !スカラー量
  real(8)             :: ss_NumDiffZ_ss(DimXMin:DimXMax, DimZMin:DimZMax)
                                                        !鉛直方向の数値拡散

  ss_NumDiffZ_ss = 0.0d0  !初期化
  ss_NumDiffZ_ss = NuV * (ss_dz_sf(sf_dz_ss( ss_Scalar ))) 
  
end function ss_NumDiffZ_ss
  
  
