Fix particle position when crossing the 0,2pi boundary in noncartesian coordinates
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| double precision, | intent(inout) | :: | xp(1:3) | |||
| integer, | intent(in) | :: | igrid |
subroutine fix_phi_crossing(xp,igrid) use mod_global_parameters use mod_geometry integer, intent(in) :: igrid double precision, intent(inout) :: xp(1:3) double precision :: xpmod(1:3) integer :: phiind select case (coordinate) case (Cartesian,Cartesian_stretched,Cartesian_expansion) ! Do nothing return case (cylindrical) phiind = phi_ case (spherical) phiind = 3 end select xpmod = xp ! Fix phi-boundary crossing ! Case 1: particle has crossed from ~2pi to ~0 xpmod(phiind) = xp(phiind) + 2.d0*dpi if ((.not. point_in_igrid_ghostc(xp,igrid,& 0)) .and. (point_in_igrid_ghostc(xpmod,igrid,0))) then xp(phiind) = xpmod(phiind) return end if ! Case 2: particle has crossed from ~0 to ~2pi xpmod(phiind) = xp(phiind) - 2.d0*dpi if ((.not. point_in_igrid_ghostc(xp,igrid,& 0)) .and. (point_in_igrid_ghostc(xpmod,igrid,0))) then xp(phiind) = xpmod(phiind) return end if end subroutine fix_phi_crossing