Subroutine ObserverSourcePairConstruct(self, x, f, fID, FirstCall, elementSide)
! use fluiddata
use FWHDefinitions, only: rho0, P0, c0, U0, M0, fwGamma2
implicit none
class(ObserverSourcePairClass) :: self
real(kind=RP), dimension(NDIM), intent(in) :: x ! observer position
type(face), intent(in) :: f ! source
integer, intent(in) :: fID, elementSide
logical, intent(in) :: FirstCall
! local variables
integer :: Nx,Ny
integer :: i, j
real(kind=RP) :: fwGammaInv
self % faceIDinMesh = fID
Nx = f % Nf(1)
Ny = f % Nf(2)
self % elementSide = elementSide
select case (elementSide)
case (1)
self % normalCorrection = 1.0_RP
case (2)
self % normalCorrection = -1.0_RP
end select
allocate( self % r(0:Nx,0:Ny), self % re(0:Nx,0:Ny), self % reStar(0:Nx,0:Ny) )
allocate( self % rVect(NDIM,0:Nx,0:Ny), self % reUnitVect(NDIM,0:Nx,0:Ny) ,self % reStarUnitVect(NDIM,0:Nx,0:Ny) )
fwGammaInv = 1.0_RP / sqrt(fwGamma2)
! source position, for each node of the face
associate (y => f % geom % x)
do j= 0, Ny; do i = 0,Nx
! store geometrical acoustic relations for each node
self % rVect(:,i,j) = x(:) - y(:,i,j)
self % r(i,j) = norm2(self % rVect(:,i,j))
self % reStar(i,j) = fwGammaInv*sqrt( self%r(i,j)**2 + fwGamma2*( dot_product(M0, self%rVect(:,i,j)) )**2 )
self % reStarUnitVect(:,i,j) = ( self%rVect(:,i,j) + fwGamma2*dot_product(M0, self%rVect(:,i,j))*M0(:) ) / &
(fwGamma2*self%reStar(i,j))
self % re(i,j) = fwGamma2*( self%reStar(i,j) - dot_product(M0, self%rVect(:,i,j)) )
self % reUnitVect(:,i,j) = fwGamma2*( self%reStarUnitVect(:,i,j) - M0(:) )
self % tDelay = (sum(self%re))/real(size(self%re),RP) / c0
end do; end do
end associate
End Subroutine ObserverSourcePairConstruct