convert to cartesian coordinates and vector components
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| double precision, | dimension(ixmin1:ixmax1,ixmin2:ixmax2,ixmin3:ixmax3, ndim) | :: | x_TMP | |||
| double precision, | dimension(ixmin1:ixmax1,ixmin2:ixmax2,ixmin3:ixmax3, nw+nwauxio) | :: | w_TMP | |||
| integer | :: | ixmin1 | ||||
| integer | :: | ixmin2 | ||||
| integer | :: | ixmin3 | ||||
| integer | :: | ixmax1 | ||||
| integer | :: | ixmax2 | ||||
| integer | :: | ixmax3 | ||||
| double precision, | dimension(ixmin1:ixmax1,ixmin2:ixmax2,ixmin3:ixmax3, ndim) | :: | xC | |||
| double precision, | dimension(ixmin1:ixmax1,ixmin2:ixmax2,ixmin3:ixmax3, nw+nwauxio) | :: | wC |
subroutine to_cartesian(x_TMP,w_TMP,ixmin1,ixmin2,ixmin3,ixmax1,ixmax2,& ixmax3,xC,wC) ! conversion of coordinate and vector components from cylindrical/spherical ! to cartesian coordinates and components done here ! Also: nullifying values lower than smalldouble use mod_global_parameters use mod_geometry integer :: ixmin1,ixmin2,ixmin3,ixmax1,ixmax2,ixmax3, ix1,ix2,ix3, idim,& iw, ivector, iw0 integer, dimension(nw) :: vectoriw double precision :: x_TEC(ndim), w_TEC(nw+nwauxio) double precision, dimension(ndim,ndim) :: normal double precision, dimension(ixmin1:ixmax1,ixmin2:ixmax2,ixmin3:ixmax3,& ndim) :: xC double precision, dimension(ixmin1:ixmax1,ixmin2:ixmax2,ixmin3:ixmax3,& nw+nwauxio) :: wC double precision, dimension(ixmin1:ixmax1,ixmin2:ixmax2,ixmin3:ixmax3,& ndim) :: x_TMP double precision, dimension(ixmin1:ixmax1,ixmin2:ixmax2,ixmin3:ixmax3,& nw+nwauxio) :: w_TMP iw0=0 vectoriw=-1 if(nvector>0) then do ivector=1,nvector do idim=1,ndim vectoriw(iw_vector(ivector)+idim)=iw_vector(ivector) end do end do endif x_TEC=0.d0 do ix3=ixmin3,ixmax3 do ix2=ixmin2,ixmax2 do ix1=ixmin1,ixmax1 select case (coordinate) case (Cartesian,Cartesian_stretched,Cartesian_expansion) x_TEC(1:ndim)=xC(ix1,ix2,ix3,1:ndim) w_TEC(1:nw+nwauxio)=wC(ix1,ix2,ix3,1:nw+nwauxio) case (cylindrical) x_TEC(1)=xC(ix1,ix2,ix3,1)*cos(xC(ix1,ix2,ix3,phi_)) x_TEC(2)=xC(ix1,ix2,ix3,1)*sin(xC(ix1,ix2,ix3,phi_)) x_TEC(3)=xC(ix1,ix2,ix3,z_) if (nvector>0) then normal(1,1)=cos(xC(ix1,ix2,ix3,phi_)) normal(1,phi_)=-sin(xC(ix1,ix2,ix3,phi_)) normal(1,z_)=zero normal(2,1)=sin(xC(ix1,ix2,ix3,phi_)) normal(2,phi_)=cos(xC(ix1,ix2,ix3,phi_)) normal(2,z_)=zero normal(3,1)=zero normal(3,phi_)=zero normal(3,z_)=one end if do iw=1,nw+nwauxio if (iw<=nw) iw0=vectoriw(iw) if (iw0>=0.and.iw<=iw0+ndim.and.iw<=nw) then idim=iw-iw0 w_TEC(iw0+idim)=wC(ix1,ix2,ix3,iw0+1)*normal(idim,1)+wC(ix1,& ix2,ix3,iw0+2)*normal(idim,2)+wC(ix1,ix2,ix3,& iw0+3)*normal(idim,3) else w_TEC(iw)=wC(ix1,ix2,ix3,iw) end if end do case (spherical) x_TEC(1)=xC(ix1,ix2,ix3,1)*sin(xC(ix1,ix2,ix3,2))*cos(xC(ix1,ix2,ix3,& 3)) x_TEC(2)=xC(ix1,ix2,ix3,1)*sin(xC(ix1,ix2,ix3,2))*sin(xC(ix1,ix2,ix3,& 3)) x_TEC(3)=xC(ix1,ix2,ix3,1)*cos(xC(ix1,ix2,ix3,2)) if (nvector>0) then normal(1,1)=sin(xC(ix1,ix2,ix3,2))*cos(xC(ix1,ix2,ix3,3)) normal(1,2)=cos(xC(ix1,ix2,ix3,2))*cos(xC(ix1,ix2,ix3,3)) normal(1,3)=-sin(xC(ix1,ix2,ix3,3)) normal(2,1)=sin(xC(ix1,ix2,ix3,2))*sin(xC(ix1,ix2,ix3,3)) normal(2,2)=cos(xC(ix1,ix2,ix3,2))*sin(xC(ix1,ix2,ix3,3)) normal(2,3)=cos(xC(ix1,ix2,ix3,3)) normal(3,1)=cos(xC(ix1,ix2,ix3,2)) normal(3,2)=-sin(xC(ix1,ix2,ix3,2)) normal(3,3)=zero end if do iw=1,nw+nwauxio if (iw<=nw) iw0=vectoriw(iw) if (iw0>=0.and.iw<=iw0+ndim.and.iw<=nw) then idim=iw-iw0 w_TEC(iw0+idim)=wC(ix1,ix2,ix3,iw0+1)*normal(idim,1)+wC(ix1,& ix2,ix3,iw0+2)*normal(idim,2)+wC(ix1,ix2,ix3,& iw0+3)*normal(idim,3) else w_TEC(iw)=wC(ix1,ix2,ix3,iw) end if end do case default write(*,*) "No converter for coordinate=",coordinate end select x_TMP(ix1,ix2,ix3,1:ndim)=x_TEC(1:ndim) w_TMP(ix1,ix2,ix3,1:nw+nwauxio)=w_TEC(1:nw+nwauxio) ! Be aware that small values are nullified here!!! where(dabs(w_TMP(ix1,ix2,ix3,1:nw+nwauxio))<smalldouble) w_TMP(ix1,ix2,ix3,1:nw+nwauxio)=zero endwhere end do end do end do end subroutine to_cartesian