Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move reading of id, origin and rotation to universe_inter #74

Merged
merged 3 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Geometry/Universes/Tests/cellUniverse_test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module cellUniverse_test
contains

!!
!! Setup enviroment
!! Setup environment
!!
@Before
subroutine setUp()
Expand Down Expand Up @@ -73,7 +73,7 @@ subroutine setUp()
end subroutine setUp

!!
!! Clean enviroment
!! Clean environment
!!
@After
subroutine clean()
Expand Down Expand Up @@ -201,7 +201,7 @@ subroutine test_distance()
@assertEqual(ref, d, TOL * ref)
@assertEqual(surfs % getIdx(2), surfIdx )

! ** In local cell 2 distance to infintity
! ** In local cell 2 distance to infinity
! surfIdx must be set to 0
pos % dir = [ONE, ZERO, ZERO]
call uni % distance(d, surfIdx, pos)
Expand Down
4 changes: 2 additions & 2 deletions Geometry/Universes/Tests/latUniverse_test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module latUniverse_test
contains

!!
!! Setup enviroment
!! Setup environment
!!
@Before
subroutine setUp()
Expand Down Expand Up @@ -73,7 +73,7 @@ subroutine setUp()
end subroutine setUp

!!
!! Clean enviroment
!! Clean environment
!!
@After
subroutine clean()
Expand Down
2 changes: 1 addition & 1 deletion Geometry/Universes/Tests/pinUniverse_test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module pinUniverse_test
contains

!!
!! Set-up test enviroment
!! Set-up test environment
!!
@Before
subroutine setup()
Expand Down
4 changes: 2 additions & 2 deletions Geometry/Universes/Tests/rootUniverse_test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module rootUniverse_test
contains

!!
!! Setup enviroment
!! Setup environment
!!
@Before
subroutine setUp()
Expand All @@ -57,7 +57,7 @@ subroutine setUp()
end subroutine setUp

!!
!! Clean enviroment
!! Clean environment
!!
@After
subroutine clean()
Expand Down
2 changes: 1 addition & 1 deletion Geometry/Universes/Tests/uniFills_test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ subroutine test_cycles()

@assertTrue(graph % hasCycles())

! Move recursion to 3rd diffrent universe (loop from 3rd to 2nd)
! Move recursion to 3rd different universe (loop from 3rd to 2nd)
!
graph % uni(2) % fill(1) = 3
graph % uni(3) % fill(1) = -2
Expand Down
4 changes: 2 additions & 2 deletions Geometry/Universes/Tests/universe_test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module universe_test


!!
!! Note that universe is abstract thus it canot be tested by itself
!! Note that universe is abstract thus it cannot be tested by itself
!!
!! Tests for universe non-overridable procedures are in cellUniverse_test
!!
Expand Down Expand Up @@ -36,7 +36,7 @@ subroutine test_charToFill()
name = 'mat47'
call mats % add(name, 47)

! Test material converstion
! Test material conversion
name = 'mat13'
@assertEqual(13, charToFill(name, mats, Here))

Expand Down
37 changes: 7 additions & 30 deletions Geometry/Universes/cellUniverse_class.f90
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module cellUniverse_class
!!
!! Representation of a universe via cells
!!
!! Each local cell in the universe corespondes to a cell given by an ID.
!! Each local cell in the universe corresponds to a cell given by an ID.
!! An extra local cell is always defined inside the cellUniverse with UNDEF_MAT
!! (undefined material) filling. If position is not in any user-defined cell, it is in this
!! extra cell. Extra cell exists to enable plotting of geometry without fatalErrors.
Expand Down Expand Up @@ -78,35 +78,12 @@ subroutine init(self, fill, dict, cells, surfs, mats)
type(surfaceShelf), intent(inout) :: surfs
type(charMap), intent(in) :: mats
integer(shortInt), dimension(:), allocatable :: cellTemp
real(defReal), dimension(:), allocatable :: temp
integer(shortInt) :: id, N, i
integer(shortInt) :: N, i
character(100), parameter :: Here = 'init (cellUniverse_class.f90)'

! Load basic data
call dict % get(id, 'id')
if (id <= 0) call fatalError(Here, 'Universe ID must be +ve. Is: '//numToChar(id))
call self % setId(id)

! Load origin
if (dict % isPresent('origin')) then
call dict % get(temp, 'origin')

if (size(temp) /= 3) then
call fatalError(Here, 'Origin must have size 3. Has: '//numToChar(size(temp)))
end if
call self % setTransform(origin=temp)

end if

! Load rotation
if (dict % isPresent('rotation')) then
call dict % get(temp, 'rotation')

if (size(temp) /= 3) then
call fatalError(Here, '3 rotation angles must be given. Has only: '//numToChar(size(temp)))
end if
call self % setTransform(rotation=temp)
end if
! Setup the base class
! With: id, origin rotations...
call self % setupBase(dict)

! Load Cells by ID
call dict % get(cellTemp, 'cells')
Expand Down Expand Up @@ -191,8 +168,8 @@ end subroutine distance
!!
!! See universe_inter for details.
!!
!! Note: Introduces extra movment to the particle to push it over boundary
!! for more efficent search. Distance is NUGDE.
!! Note: Introduces extra movement to the particle to push it over boundary
!! for more efficient search. Distance is NUGDE.
!!
subroutine cross(self, coords, surfIdx)
class(cellUniverse), intent(inout) :: self
Expand Down
38 changes: 8 additions & 30 deletions Geometry/Universes/latUniverse_class.f90
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module latUniverse_class
!! Cells inside the lattice can only be filled with a universe (given as integer ID).
!! Background cell can have any filling given by keyword (material or universe)
!!
!! Every lattice cell has an offset to its centere (so the centre of the nested universe
!! Every lattice cell has an offset to its centre (so the centre of the nested universe
!! is in the center of the lattice cell).
!!
!! Minimum lattice pitch is set to 10 * SURF_TOL
Expand Down Expand Up @@ -66,7 +66,7 @@ module latUniverse_class
!! Private Members:
!! pitch -> Values of lattice pitch in x, y & z directions
!! sizeN -> Number of lattice cells in x, y & z directions
!! corner -> Location of the minumum corner
!! corner -> Location of the minimum corner
!! a_bar -> Halfwidth of lattice cell reduced by surface tolerance
!! outline -> Box type surface that is a boundary between lattice & background
!! outLocalID -> LocalID of the background cell
Expand Down Expand Up @@ -111,37 +111,15 @@ subroutine init(self, fill, dict, cells, surfs, mats)
type(charMap), intent(in) :: mats
real(defReal), dimension(:), allocatable :: temp
integer(shortInt), dimension(:), allocatable :: tempI
integer(shortInt) :: id, N, i, j, outFill
integer(shortInt) :: N, i, j, outFill
type(dictionary) :: tempDict
integer(shortInt), dimension(:,:), allocatable :: tempMap
character(nameLen) :: name
character(100), parameter :: Here = 'init (latUniverse_class.f90)'

! Load basic data
call dict % get(id, 'id')
if (id <= 0) call fatalError(Here, 'Universe ID must be +ve. Is: '//numToChar(id))
call self % setId(id)

! Load origin
if (dict % isPresent('origin')) then
call dict % get(temp, 'origin')

if (size(temp) /= 3) then
call fatalError(Here, 'Origin must have size 3. Has: '//numToChar(size(temp)))
end if
call self % setTransform(origin=temp)

end if

! Load rotation
if (dict % isPresent('rotation')) then
call dict % get(temp, 'rotation')

if (size(temp) /= 3) then
call fatalError(Here, '3 rotation angles must be given. Has only: '//numToChar(size(temp)))
end if
call self % setTransform(rotation=temp)
end if
! Setup the base class
! With: id, origin rotations...
call self % setupBase(dict)

! Load pitch
call dict % get(temp, 'pitch')
Expand Down Expand Up @@ -308,9 +286,9 @@ subroutine distance(self, d, surfIdx, coords)
! Provide default axis to ensure no out of bounds array access if
! all distances happen to be infinite
d = INF
ax = 1
ax = 1
do i = 1, 3
! Nominator and denominator will have the same sign (by ealier bounds selection)
! Nominator and denominator will have the same sign (by earlier bounds selection)
test_d = (bounds(i) - r_bar(i)) / u(i)

if (test_d < d) then
Expand Down
38 changes: 8 additions & 30 deletions Geometry/Universes/pinUniverse_class.f90
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ module pinUniverse_class
!! fills (u<3> void clad u<4>);
!! }
!!
!! There must be 0.0 entry, which indicates outermost annulus (infinate radius).
!! There must be 0.0 entry, which indicates outermost annulus (infinite radius).
!! `fills` and `radii` are given as pairs by position in the input arrays. Thus, fills
!! are sorted together with the `radii`. As a result, in the example, local cell 1 is
!! filled with u<4>, cell 2 with u<3> etc.
!!
!! Public Members:
!! r_sqr -> Array of radius^2 for each annulus
!! annuli -> Array of cylinder surfaces that represent diffrent annuli
!! annuli -> Array of cylinder surfaces that represent different annuli
!!
!! Interface:
!! universe interface
Expand Down Expand Up @@ -77,36 +77,14 @@ subroutine init(self, fill, dict, cells, surfs, mats)
type(cellShelf), intent(inout) :: cells
type(surfaceShelf), intent(inout) :: surfs
type(charMap), intent(in) :: mats
integer(shortInt) :: id, idx, N, i
real(defReal), dimension(:), allocatable :: radii, temp
integer(shortInt) :: idx, N, i
real(defReal), dimension(:), allocatable :: radii
character(nameLen), dimension(:), allocatable :: fillNames
character(100), parameter :: Here = 'init (pinUniverse_class.f90)'

! Load basic data
call dict % get(id, 'id')
if (id <= 0) call fatalError(Here, 'Universe ID must be +ve. Is: '//numToChar(id))
call self % setId(id)

! Load origin
if (dict % isPresent('origin')) then
call dict % get(temp, 'origin')

if (size(temp) /= 3) then
call fatalError(Here, 'Origin must have size 3. Has: '//numToChar(size(temp)))
end if
call self % setTransform(origin=temp)

end if

! Load rotation
if (dict % isPresent('rotation')) then
call dict % get(temp, 'rotation')

if (size(temp) /= 3) then
call fatalError(Here, '3 rotation angles must be given. Has only: '//numToChar(size(temp)))
end if
call self % setTransform(rotation=temp)
end if
! Setup the base class
! With: id, origin rotations...
call self % setupBase(dict)

! Load radii and fill data
call dict % get(radii, 'radii')
Expand All @@ -126,7 +104,7 @@ subroutine init(self, fill, dict, cells, surfs, mats)
! Change 0.0 to infinity
N = size(radii)
idx = minloc(radii, 1)
if (radii(idx) /= ZERO) call fatalError(Here, 'Did not found outermst element with radius 0.0.')
if (radii(idx) /= ZERO) call fatalError(Here, 'Did not found outermost element with radius 0.0.')
call swap( radii(idx), radii(N))
call swap( fillNames(idx), fillNames(N))
radii(N) = INF * 1.1_defReal
Expand Down
13 changes: 6 additions & 7 deletions Geometry/Universes/rootUniverse_class.f90
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module rootUniverse_class
!!
!! A top level (root) universe of geometry
!!
!! Is composed of two regions. Inside and outside seperated by a single surface.
!! Is composed of two regions. Inside and outside separated by a single surface.
!! Inside is the -ve halfspace of the boundary surface
!! +ve halfspace is OUTSIDE
!! Filling can be universe given by ID (`u<67` syntax) or a material given by name (e.g. 'fuel')
Expand Down Expand Up @@ -84,16 +84,15 @@ subroutine init(self, fill, dict, cells, surfs, mats)
character(nameLen) :: name
character(100), parameter :: Here = 'init (rootUniverse_class.f90)'

! Set ID
call dict % get(id, 'id')
if (id <= 0) call fatalError(Here, 'Universe ID must be +ve. Is: '//numToChar(id))
call self % setId(id)
! Setup the base class
! With: id, origin rotations...
call self % setupBase(dict)

! Make shure root does not contain neither origin nor rotation
! Make sure root does not contain neither origin nor rotation
if (dict % isPresent('origin')) then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dict % isPresent('origin')
is repeated twice in line 92 and 95

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes!!!
It has been there for long.... Good thing nobody was rotating root universes... 😨

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be resolved now.

call fatalError(Here, 'Origin is not allowed. Centre of the root universe is &
&always (0.0 0.0 0.0).')
else if (dict % isPresent('origin')) then
else if (dict % isPresent('rotation')) then
call fatalError(Here, 'Rotation is not allowed. Root universe cannot be rotated.')

end if
Expand Down
14 changes: 7 additions & 7 deletions Geometry/Universes/uniFills_class.f90
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ module uniFills_class
!! A Temporary structure to store universe fillings & check correctness
!!
!! Is used to transfer information about universe nesting structure decoupled from
!! the spatial subdivision. Will be used to constrct geomGraph.
!! the spatial subdivision. Will be used to construct geomGraph.
!!
!! TODO: The recursive procedures that do checks may not be the best from the point of
!! view of efficiency. Investigate if it is a problem.
!!
!! Public Mambers:
!! Public Members:
!! root -> Index of the root universe
!! uni -> Array of `fillInfo` with data for each universe. Universe indices are the
!! same on the uni array on on the universe Shelf.
Expand Down Expand Up @@ -304,7 +304,7 @@ function nestedOutside(self) result(hasIt)
call fatalError(Here, 'Root universe has not been set.')
end if

! Serach nested universes
! Search nested universes
hasIt = .false.
do i = 1, size(self % uni(self % root) % fill)
fill = self % uni(self % root) % fill(i)
Expand Down Expand Up @@ -360,7 +360,7 @@ function unusedUniverses(self) result(list)
end function unusedUniverses

!!
!! Get count of instances of diffrent universes in the geometry
!! Get count of instances of different universes in the geometry
!!
!! Args:
!! map [out] -> Map of uniIdx to number of instances. If uniIdx is not present in the
Expand Down Expand Up @@ -483,7 +483,7 @@ end function countDepth
!! idx [in] -> Index of the current universe
!!
!! Result:
!! True if universe under idx contains outside or outisde is present below it
!! True if universe under idx contains outside or outside is present below it
!!
!! Errors:
!! fatalError if idx is invalid
Expand Down Expand Up @@ -554,7 +554,7 @@ recursive subroutine collectUsed(self, set, idx)
end subroutine collectUsed

!!
!! Count instances of diffrent univeres in the current universe or below it
!! Count instances of different universes in the current universe or below it
!!
!! Args:
!! map [inout] -> Map of uniIdx to number of instances. Instances in the current universe
Expand All @@ -578,7 +578,7 @@ recursive subroutine countInstancesBelow(self, map, idx)
count = map % getOrDefault(idx, 0) + 1
call map % add(idx, count)

! Loop over local cells and add nexted universes
! Loop over local cells and add nested universes
do i = 1, size(self % uni(idx) % fill)
fill = self % uni(idx) % fill(i)

Expand Down
Loading