Skip to content

Commit

Permalink
Merge pull request #1 from NRavoisin96/MacOS
Browse files Browse the repository at this point in the history
macOS support, floating points comparison initial revision
  • Loading branch information
NRavoisin96 authored Oct 24, 2024
2 parents 08d8b27 + e7d5281 commit 48294b3
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 68 deletions.
12 changes: 7 additions & 5 deletions Geometry/Surfaces/QuadSurfaces/aPlane_class.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module aPlane_class

use numPrecision
use universalVariables, only : X_AXIS, Y_AXIS, Z_AXIS, INF
use genericProcedures, only : fatalError
use genericProcedures, only : fatalError, areEqual
use dictionary_class, only : dictionary
use quadSurface_inter, only : quadSurface
use surface_inter, only : kill_super => kill
Expand Down Expand Up @@ -196,14 +196,16 @@ pure function going(self, r, u) result(halfspace)
real(defReal) :: ua

ua = u(self % axis)
halfspace = ua > ZERO

! Special case of parallel direction
! Partilce stays in its current halfspace
if (ua == ZERO) then
! Special case of parallel direction. Particle stays in its current halfspace.
if (areEqual(ua, ZERO)) then
halfspace = (r(self % axis) - self % a0) >= ZERO
return

end if

halfspace = ua > ZERO

end function going

!!
Expand Down
15 changes: 8 additions & 7 deletions Geometry/Surfaces/QuadSurfaces/cone_class.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module cone_class

use numPrecision
use universalVariables, only : SURF_TOL, INF, X_AXIS, Y_AXIS, Z_AXIS
use genericProcedures, only : fatalError, numToChar, dotProduct
use genericProcedures, only : fatalError, numToChar, areEqual
use dictionary_class, only : dictionary
use quadSurface_inter, only : quadSurface
use surface_inter, only : kill_super => kill
Expand Down Expand Up @@ -418,15 +418,16 @@ pure function going(self, r, u) result(halfspace)
norm = norm/norm2(norm)
proj = dot_product(norm,u)

! Determine halfspace
halfspace = proj > ZERO

! Parallel direction
! Need to use position to determine halfspace
if (proj == ZERO) then
! Parallel direction. Need to use position to determine halfspace.
if (areEqual(proj, ZERO)) then
halfspace = self % evaluate(r) >= ZERO
return

end if

! Determine halfspace
halfspace = proj > ZERO

end function going

!!
Expand Down
4 changes: 2 additions & 2 deletions Geometry/Surfaces/QuadSurfaces/cylinder_class.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module cylinder_class

use numPrecision
use universalVariables, only : SURF_TOL, INF, X_AXIS, Y_AXIS, Z_AXIS
use genericProcedures, only : fatalError, numToChar, dotProduct
use genericProcedures, only : fatalError, numToChar, areEqual
use dictionary_class, only : dictionary
use quadSurface_inter, only : quadSurface
use surface_inter, only : kill_super => kill
Expand Down Expand Up @@ -242,7 +242,7 @@ pure function distance(self, r, u) result(d)
delta = k*k - a*c ! Technically delta/4

! Calculate the distance
if (delta < ZERO .or. a == ZERO) then ! No intersection
if (delta < ZERO .or. areEqual(a, ZERO)) then ! No intersection
d = INF

else if (abs(c) < self % surfTol()) then ! Point at a surface
Expand Down
22 changes: 12 additions & 10 deletions Geometry/Surfaces/QuadSurfaces/plane_class.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module plane_class

use numPrecision
use universalVariables, only : X_AXIS, Y_AXIS, Z_AXIS, INF
use genericProcedures, only : fatalError, dotProduct, numToChar
use genericProcedures, only : fatalError, numToChar, areEqual
use dictionary_class, only : dictionary
use quadSurface_inter, only : quadSurface
use surface_inter, only : kill_super => kill
Expand Down Expand Up @@ -128,7 +128,7 @@ pure function evaluate(self, r) result(c)
real(defReal), dimension(3), intent(in) :: r
real(defReal) :: c

c = dotProduct(r, self % norm) - self % offset
c = dot_product(r, self % norm) - self % offset

end function evaluate

Expand All @@ -151,10 +151,10 @@ pure function distance(self, r, u) result(d)
real(defReal) :: d
real(defReal) :: k, c

k = dotProduct(u, self % norm)
k = dot_product(u, self % norm)
c = self % evaluate(r)

if ( k == ZERO .or. abs(c) < self % surfTol()) then ! Parallel or at the surface
if (areEqual(k, ZERO) .or. abs(c) < self % surfTol()) then ! Parallel or at the surface
d = INF

else
Expand All @@ -180,15 +180,17 @@ pure function going(self, r, u) result(halfspace)
logical(defBool) :: halfspace
real(defReal) :: proj

proj = dotProduct(u, self % norm)
halfspace = proj > ZERO

! Special case of parallel direction
! Partilce stays in its current halfspace
if (proj == ZERO) then
proj = dot_product(u, self % norm)

! Special case of parallel direction. Particle stays in its current halfspace
if (areEqual(proj, ZERO)) then
halfspace = self % evaluate(r) >= ZERO
return

end if

halfspace = proj > ZERO

end function going

!!
Expand Down
8 changes: 4 additions & 4 deletions Geometry/Surfaces/QuadSurfaces/sphere_class.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module sphere_class

use numPrecision
use universalVariables, only : INF, SURF_TOL
use genericProcedures, only : fatalError, dotProduct, numToChar
use genericProcedures, only : fatalError, numToChar
use dictionary_class, only : dictionary
use surface_inter, only : kill_super => kill
use quadSurface_inter, only : quadSurface
Expand Down Expand Up @@ -135,7 +135,7 @@ pure function evaluate(self, r) result(c)

diff = r - self % origin

c = dotProduct(diff, diff) - self % r_sq
c = dot_product(diff, diff) - self % r_sq

end function evaluate

Expand All @@ -158,7 +158,7 @@ pure function distance(self, r, u) result(d)

! Calculate quadratic components
c = self % evaluate(r)
k = dotProduct(r - self % origin, u)
k = dot_product(r - self % origin, u)
delta = k*k - c ! Technically delta/4

! Calculate the distance
Expand Down Expand Up @@ -193,7 +193,7 @@ pure function going(self, r, u) result(halfspace)
real(defReal), dimension(3), intent(in) :: u
logical(defBool) :: halfspace

halfspace = dotProduct(r - self % origin, u) >= ZERO
halfspace = dot_product(r - self % origin, u) >= ZERO

end function going

Expand Down
13 changes: 7 additions & 6 deletions Geometry/Surfaces/box_class.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module box_class

use numPrecision
use universalVariables
use genericProcedures, only : fatalError, numToChar, swap
use genericProcedures, only : fatalError, numToChar, swap, areEqual
use dictionary_class, only : dictionary
use surface_inter, only : surface, kill_super => kill

Expand Down Expand Up @@ -264,14 +264,15 @@ pure function going(self, r, u) result(halfspace)
! Projection of direction on the normal
proj = u(maxCom) * sign(ONE, rl(maxCom))

halfspace = proj > ZERO

! Parallel direction
! Need to use position to determine halfspace
if (proj == ZERO) then
! Parallel direction. Need to use position to determine halfspace.
if (areEqual(proj, ZERO)) then
halfspace = self % evaluate(r) >= ZERO
return

end if

halfspace = proj > ZERO

end function going

!!
Expand Down
13 changes: 7 additions & 6 deletions Geometry/Surfaces/squareCylinder_class.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module squareCylinder_class

use numPrecision
use universalVariables
use genericProcedures, only : fatalError, numToChar, swap
use genericProcedures, only : fatalError, numToChar, swap, areEqual
use dictionary_class, only : dictionary
use surface_inter, only : surface, kill_super => kill

Expand Down Expand Up @@ -313,13 +313,14 @@ pure function going(self, r, u) result(halfspace)
! Projection of direction on the normal
proj = ul(maxCom) * sign(ONE, rl(maxCom))

halfspace = proj > ZERO

! Parallel direction
! Need to use position to determine halfspace
if (proj == ZERO) then
! Parallel direction. Need to use position to determine halfspace
if (areEqual(proj, ZERO)) then
halfspace = self % evaluate(r) >= ZERO
return

end if

halfspace = proj > ZERO

end function going

Expand Down
17 changes: 9 additions & 8 deletions Geometry/Surfaces/truncCylinder_class.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module truncCylinder_class

use numPrecision
use universalVariables
use genericProcedures, only : fatalError, numToChar, swap
use genericProcedures, only : fatalError, numToChar, swap, areEqual
use dictionary_class, only : dictionary
use surface_inter, only : surface, kill_super => kill

Expand Down Expand Up @@ -227,7 +227,7 @@ pure function distance(self, r, u) result(d)
delta = k*k - a*c1 ! Technically delta/4

! Find closes & furthest distance
if (delta <= ZERO .or. a == ZERO) then ! No intersection
if (delta <= ZERO .or. areEqual(a, ZERO)) then ! No intersection
far = INF
near = sign(INF, c1) ! If ray is parallel inside the cylinder it must be fully contained

Expand Down Expand Up @@ -328,15 +328,16 @@ pure function going(self, r, u) result(halfspace)

end if

! Determine next halfspace
halfspace = proj > ZERO

! Parallel direction
! Need to use position to determine halfspace
if (proj == ZERO) then
! Parallel direction. Need to use position to determine halfspace.
if (areEqual(proj, ZERO)) then
halfspace = c >= ZERO
return

end if

! Determine next halfspace
halfspace = proj > ZERO

end function going

!!
Expand Down
4 changes: 2 additions & 2 deletions ParticleObjects/particle_class.f90
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ end function getUniIdx
!!
!! Return current material index
!!
pure function matIdx(self) result(Idx)
pure function matIdx(self) result(idx)
class(particle), intent(in) :: self
integer(shortInt) :: idx

Expand Down Expand Up @@ -670,7 +670,7 @@ end subroutine particleState_fromParticle
function equal_particleState(LHS,RHS) result(isEqual)
class(particleState), intent(in) :: LHS
class(particleState), intent(in) :: RHS
logical(defBool) :: isEqual
logical(defBool) :: isEqual

isEqual = .true.
isEqual = isEqual .and. LHS % wgt == RHS % wgt
Expand Down
Loading

0 comments on commit 48294b3

Please sign in to comment.