Returns a 4-dimensional spectrum array, where the first two dimensions are frequency and directional dimensions and the second two are spatial x and y dimensions.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(domain_type), | intent(in) | :: | self | Domain instance |
||
integer(kind=ik), | intent(in), | dimension(2) | :: | halowidth | Integers indicating how many cells to allocate for halo points |
|
logical, | intent(in) | :: | periodic | If |
Spectrum array
pure function getSpectrumArray(self,halowidth,periodic) result(spectrum_array)
!! Returns a 4-dimensional spectrum array, where the first two dimensions are
!! frequency and directional dimensions and the second two are spatial x and y
!! dimensions.
class(domain_type),intent(in) :: self
!! Domain instance
real(kind=rk),dimension(:,:,:,:),allocatable :: spectrum_array
!! Spectrum array
integer(kind=ik),dimension(2),intent(in) :: halowidth
!! Integers indicating how many cells to allocate for halo points
logical,intent(in) :: periodic
!! If `.true.`, halo cells will be updated with values corresponding to
!! periodic boundary conditions
integer(kind=ik) :: i,j
integer(kind=ik) :: ndirs,nfreqs
associate(lb => self % lb,ub => self % ub,hw => halowidth)
nfreqs = size(self % spectrum(1,1) % getSpectrum(),dim=1)
ndirs = size(self % spectrum(1,1) % getSpectrum(),dim=2)
allocate(spectrum_array(nfreqs,ndirs,lb(1)-hw(1):ub(1)+hw(1),&
lb(2)-hw(2):ub(2)+hw(2)))
do concurrent(i=lb(1):ub(1),j=lb(2):ub(2))
spectrum_array(:,:,i,j) = self % spectrum(i,j) % getSpectrum()
enddo
! Set halo values for periodic boundary conditions
if(periodic)then
spectrum_array(:,:,lb(1)-hw(1):lb(1)-1,:)&
= spectrum_array(:,:,ub(1)-hw(1)+1:ub(1),:)
spectrum_array(:,:,ub(1)+1:ub(1)+hw(1),:)&
= spectrum_array(:,:,lb(1):lb(1)+hw(1)-1,:)
spectrum_array(:,:,:,lb(2)-hw(2):lb(2)-1)&
= spectrum_array(:,:,:,ub(2)-hw(2)+1:ub(2))
spectrum_array(:,:,:,ub(2)+1:ub(2)+hw(2))&
= spectrum_array(:,:,:,lb(2):lb(2)+hw(2)-1)
endif
endassociate
endfunction getSpectrumArray