Computes the advective tendency for the domain instance given the desired
advection method as an input function and the number of halo cells. This
function works both when ndirs == 1
(omnidirectional) and when
ndirs > 1
(directional).
This implementation accepts the methods that operate on spectrum arrays of rank 2 (directional) in 1-dimensional space:
Type | Intent | Optional | Attributes | Name | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
class(domain_type), | intent(in) | :: | self |
|
||||||||||||||||||||||||||||||
public pure function advection_method(f, u, dx) result(tendency)Arguments
Return Value real(kind=rk), dimension(:,:,:), allocatable |
||||||||||||||||||||||||||||||||||
integer(kind=ik), | intent(in) | :: | halowidth | number of halo cells to use in the advection method |
||||||||||||||||||||||||||||||
integer(kind=ik), | intent(in), | dimension(:,:) | :: | directional_type | A global constant that helps resolve the interface of this specific prodedure |
pure type(domain_type) function advect1dRank2(self,advection_method,halowidth,&
directional_type) result(adv)
!! Computes the advective tendency for the domain instance given the desired
!! advection method as an input function and the number of halo cells. This
!! function works both when `ndirs == 1` (omnidirectional) and when
!! `ndirs > 1` (directional).
!!
!! This implementation accepts the methods that operate on spectrum arrays
!! of rank 2 (directional) in 1-dimensional space:
!!
!! * advectUpwind1stOrder1dRank2
!! * advectCentered2ndOrder1dRank2
class(domain_type),intent(in) :: self
!! `domain` instance
interface
pure function advection_method(f,u,dx) result(tendency)
import :: rk
real(kind=rk),dimension(:,:,:),intent(in) :: f
real(kind=rk),dimension(:,:,:),intent(in) :: u
real(kind=rk),dimension(:),intent(in) :: dx
real(kind=rk),dimension(:,:,:),allocatable :: tendency
endfunction advection_method
endinterface
!! function with the requested advection method
integer(kind=ik),intent(in) :: halowidth
!! number of halo cells to use in the advection method
integer(kind=ik),dimension(:,:),intent(in) :: directional_type
!! A global constant that helps resolve the interface of this specific
!! prodedure
integer(kind=ik) :: idm
real(kind=rk),dimension(:,:,:),allocatable :: f
real(kind=rk),dimension(:,:,:),allocatable :: cg
real(kind=rk),dimension(:),allocatable :: dx
associate(lb => self % lb,ub => self % ub,hw => halowidth)
adv = self
idm = ub(1)-lb(1)+1+2*hw
f = reshape(self % getSpectrumArray([hw,0],.true.),[self % nfreqs,self % ndirs,idm])
cg = reshape(self % getGroupSpeed([hw,0],.true.),[self % nfreqs,self % ndirs,idm])
dx = reshape(self % getGridSpacingXWithHalo([hw,0],.true.),[idm])
call adv % setSpectrumArray(advection_method(f,cg,dx))
endassociate
endfunction advect1dRank2