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 2-dimensional space:
Type | Intent | Optional | Attributes | Name | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
class(domain_type), | intent(in) | :: | self |
|
||||||||||||||||||||||||||||||||||||||||||||
public pure function advection_method(f, u, v, dx, dy) result(tendency)Arguments
Return Value real(kind=rk), dimension(:,:,:,:), allocatable |
||||||||||||||||||||||||||||||||||||||||||||||||
integer(kind=ik), | intent(in), | dimension(:) | :: | halowidth | number of halo cells to use in the advection method |
pure type(domain_type) function advect2dRank2(self,advection_method,halowidth)&
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 2-dimensional space:
!!
!! * advectUpwind1stOrder2dRank2
!! * advectCentered2ndOrder2dRank2
class(domain_type),intent(in) :: self
!! `domain` instance
interface
pure function advection_method(f,u,v,dx,dy) result(tendency)
import :: rk
real(kind=rk),dimension(:,:,:,:),intent(in) :: f
real(kind=rk),dimension(:,:,:,:),intent(in) :: u
real(kind=rk),dimension(:,:,:,:),intent(in) :: v
real(kind=rk),dimension(:,:),intent(in) :: dx
real(kind=rk),dimension(:,:),intent(in) :: dy
real(kind=rk),dimension(:,:,:,:),allocatable :: tendency
endfunction advection_method
endinterface
!! function with the requested advection method
integer(kind=ik),dimension(:),intent(in) :: halowidth
!! number of halo cells to use in the advection method
integer(kind=ik) :: idm,jdm,n
real(kind=rk),dimension(:,:,:,:),allocatable :: f
real(kind=rk),dimension(:,:,:),allocatable :: cg
real(kind=rk),dimension(:,:,:,:),allocatable :: cgx
real(kind=rk),dimension(:,:,:,:),allocatable :: cgy
real(kind=rk),dimension(:,:),allocatable :: dx
real(kind=rk),dimension(:,:),allocatable :: dy
real(kind=rk),dimension(:),allocatable :: theta
associate(lb => self % lb,ub => self % ub,hw => halowidth)
theta = self % getDirections()
adv = self
idm = ub(1)-lb(1)+1+2*hw(1)
jdm = ub(2)-lb(2)+1+2*hw(2)
f = reshape(self % getSpectrumArray(hw,.true.),[self % nfreqs,self % ndirs,[idm,jdm]])
allocate(cgx(self % nfreqs,self % ndirs,idm,jdm))
allocate(cgy(self % nfreqs,self % ndirs,idm,jdm))
cg = self % getGroupSpeed(hw,.true.)
do concurrent(n = 1:self % ndirs)
cgx(:,n,:,:) = cos(theta(n))*cg
cgy(:,n,:,:) = sin(theta(n))*cg
enddo
dx = self % getGridSpacingXWithHalo(hw,.true.)
dy = self % getGridSpacingYWithHalo(hw,.true.)
call adv % setSpectrumArray(advection_method(f,cgx,cgy,dx,dy))
deallocate(cgx,cgy)
endassociate
endfunction advect2dRank2