Subroutine that converts the position of simulated particles from cylindrical to Cartesian ((x,y,z)\ coordinates.
Here, the coordinate transformation is:
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rp), | intent(in), | DIMENSION(:,:), ALLOCATABLE | :: | Xcyl | Particles' position in cylindrical coordinates. Xcyl(1,:) = , Xcyl(2,:) = , Xcyl(3,:) = |
|
real(kind=rp), | intent(inout), | DIMENSION(:,:), ALLOCATABLE | :: | X | Particles' position in Cartesian coordinates. X(1,:) = , X(2,:) = , X(3,:) = |
subroutine cyl_to_cart(Xcyl,X)
!! @note Subroutine that converts the position of simulated particles
!! from cylindrical \((R,\phi,Z)\) to Cartesian \((x,y,z)\ coordinates.
!! @endnote
!! Here, the coordinate transformation is:
!!
!! $$x=R\cos(\phi),$$
!! $$y=R\sin(\phi),,$$
!! $$Z = z.$$
implicit none
REAL(rp), DIMENSION(:,:), ALLOCATABLE, INTENT(INOUT):: X
!! Particles' position in Cartesian coordinates. X(1,:) = \(x\), X(2,:)
!! = \(y\), X(3,:) = \(z\)
REAL(rp), DIMENSION(:,:), ALLOCATABLE, INTENT(IN) :: Xcyl
!! Particles' position in cylindrical coordinates. Xcyl(1,:) = \(R\),
!! Xcyl(2,:) = \(\phi\), Xcyl(3,:) = \(Z\)
INTEGER :: pp
!! Iterator.
INTEGER :: ss
!! Iterator.
if (size(Xcyl,1).eq.1) then
ss = size(Xcyl,1)
else
if (Xcyl(2,1).eq.0) then
ss=1_idef
else
ss = size(Xcyl,1)
end if
endif
!$OMP PARALLEL DO FIRSTPRIVATE(ss) PRIVATE(pp) SHARED(X,Xcyl)
do pp=1_idef,ss
X(pp,1) = Xcyl(pp,1)*cos(Xcyl(pp,2))
X(pp,2) = Xcyl(pp,1)*sin(Xcyl(pp,2))
X(pp,3) = Xcyl(pp,3)
end do
!$OMP END PARALLEL DO
end subroutine cyl_to_cart