Skip to content
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 CollisionOperator/CollisionProcessors/neutronCEimp_class.f90
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ subroutine implicit(self, p, tally, collDat, thisCycle, nextCycle)
! Sample number of fission sites generated
! Support -ve weight particles
if (self % uniFissSites) then
val = self % ufsField % at(p)
val = self % ufsField % atP(p)
n = int(abs( (wgt * sig_nufiss) / (sig_tot * k_eff))*val(1)/val(2) + rand1, shortInt)
wgt = val(2)/val(1)
else
Expand Down Expand Up @@ -422,7 +422,7 @@ subroutine fission(self, p, tally, collDat, thisCycle, nextCycle)
! Support -ve weight particles
! Note change of denominator (sig_fiss) wrt implicit generation
if (self % uniFissSites) then
val = self % ufsField % at(p)
val = self % ufsField % atP(p)
n = int(abs( (wgt * sig_nufiss) / (sig_fiss * k_eff))*val(1)/val(2) + rand1, shortInt)
wgt = val(2)/val(1)
else
Expand Down Expand Up @@ -572,7 +572,7 @@ subroutine cutoffs(self, p, tally, collDat, thisCycle, nextCycle)

! Weight Windows treatment
elseif (self % weightWindows) then
val = self % weightWindowsMap % at(p)
val = self % weightWindowsMap % atP(p)
minWgt = val(1)
maxWgt = val(2)
avWgt = val(3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ subroutine cutoffs(self, p, tally, collDat, thisCycle, nextCycle)

! Weight Windows treatment
elseif (self % weightWindows) then
val = self % weightWindowsMap % at(p)
val = self % weightWindowsMap % atP(p)
minWgt = val(1)
maxWgt = val(2)
avWgt = val(3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module uniformScalarField_test

use numPrecision
use dictionary_class, only : dictionary
use coord_class, only : coordList
use particle_class, only : particle
use field_inter, only : field
use scalarField_inter, only : scalarField, scalarField_CptrCast
Expand All @@ -23,6 +24,7 @@ subroutine test_uniformScalarField()
type(uniformScalarField), pointer :: ptr2
type(dictionary) :: dict
type(particle) :: p
type(coordList) :: coords
real(defReal), parameter :: TOL = 1.0E-7_defReal

! Test invalid pointers
Expand Down Expand Up @@ -50,7 +52,10 @@ subroutine test_uniformScalarField()
call fieldT % init(dict)

! Check value
@assertEqual(9.6_defReal, fieldT % at(p), TOL)
@assertEqual(9.6_defReal, fieldT % atP(p), TOL)

call coords % assignPosition([ZERO, ZERO, ZERO])
@assertEqual(9.6_defReal, fieldT % at(coords), TOL)

! Kill
call fieldT % kill()
Expand Down
35 changes: 28 additions & 7 deletions Geometry/Fields/ScalarFields/scalarField_inter.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module scalarField_inter

use numPrecision
use field_inter, only : field
use coord_class, only : coordList
use particle_class, only : particle

implicit none
Expand All @@ -18,13 +19,17 @@ module scalarField_inter
!! Access to field is via coordList to allow more fancy fields to be defined
!! (e.g. assign value to each uniqueID etc.)
!!
!! Also allows access by particle until WW and UFS are sorted
!!
!! Interface:
!! field interface
!! at -> Return scalar value given position coordinates
!! at -> Return scalar value given position coordinates
!! atP -> Return scalar value given particle
!!
type, public, abstract, extends(field) :: scalarField
contains
procedure(at), deferred :: at
procedure(at), deferred :: at
procedure(atP), deferred :: atP
end type scalarField

abstract interface
Expand All @@ -38,12 +43,28 @@ module scalarField_inter
!! Result:
!! Value of the scalar field. Real number.
!!
function at(self, p) result(val)
import :: scalarField, particle, defReal
class(scalarField), intent(in) :: self
class(particle), intent(inout) :: p
real(defReal) :: val
function at(self, coords) result(val)
import :: scalarField, coordList, defReal
class(scalarField), intent(in) :: self
class(coordList), intent(in) :: coords
real(defReal) :: val
end function at

!!
!! Get value of the scalar field at the particle's phase space point
!!
!! Args:
!! particle [in] -> Coordinates + other phase space info
!!
!! Result:
!! Value of the scalar field. Real number.
!!
function atP(self, p) result(val)
import :: scalarField, particle, defReal
class(scalarField), intent(in) :: self
class(particle), intent(in) :: p
real(defReal) :: val
end function atP

end interface

Expand Down
20 changes: 18 additions & 2 deletions Geometry/Fields/ScalarFields/uniformScalarField_class.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module uniformScalarField_class

use numPrecision
use dictionary_class, only : dictionary
use coord_class, only : coordList
use particle_class, only : particle
use field_inter, only : field
use scalarField_inter, only : scalarField
Expand Down Expand Up @@ -35,6 +36,7 @@ module uniformScalarField_class
procedure :: init
procedure :: kill
procedure :: at
procedure :: atP
end type uniformScalarField

contains
Expand Down Expand Up @@ -68,14 +70,28 @@ end subroutine kill
!!
!! See scalarField_inter for details
!!
function at(self, p) result(val)
function at(self, coords) result(val)
class(uniformScalarField), intent(in) :: self
class(particle), intent(inout) :: p
class(coordList), intent(in) :: coords
real(defReal) :: val

val = self % val

end function at

!!
!! Get value of the scalar field at particle phase space location
!!
!! See scalarField_inter for details
!!
function atP(self, p) result(val)
class(uniformScalarField), intent(in) :: self
class(particle), intent(in) :: p
real(defReal) :: val

val = self % val

end function atP

!!
!! Cast field pointer to uniformScalarField pointer
Expand Down
6 changes: 3 additions & 3 deletions Geometry/Fields/VectorFields/Tests/uniFissSitesField_test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ subroutine testGetValue(this)
! Test case in the map
p % coords % lvl(1) % r = [0.5, 7.0, 50.0]

bins = this % ufsField % at(p)
EXPECTED_BINS = [0.25, 0.25, 0.0]
bins = this % ufsField % atP(p)
@assertEqual(EXPECTED_BINS, bins, tolerance=1.0e-6)

! Test case outside the map
p % coords % lvl(1) % r = [0.5, 7.0, 100.0]

bins = this % ufsField % at(p)
bins = this % ufsField % atP(p)
EXPECTED_BINS = [1.0, 1.0, 1.0]
@assertEqual(EXPECTED_BINS,bins)

Expand All @@ -107,7 +107,7 @@ subroutine testGetValue(this)
! Test case in the updated map
p % coords % lvl(1) % r = [0.5, 7.0, 18.1]

bins = this % ufsField % at(p)
bins = this % ufsField % atP(p)
EXPECTED_BINS = [0.25, 0.06666666667, 0.0]
@assertEqual(EXPECTED_BINS, bins, tolerance=1.0e-6)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module uniformVectorField_test

use numPrecision
use dictionary_class, only : dictionary
use coord_class, only : coordList
use particle_class, only : particle
use field_inter, only : field
use vectorField_inter, only : vectorField, vectorField_CptrCast
Expand All @@ -23,6 +24,7 @@ subroutine test_uniformVectorField()
type(uniformVectorField), pointer :: ptr2
type(dictionary) :: dict
type(particle) :: p
type(coordList) :: coords
real(defReal), parameter :: TOL = 1.0E-7_defReal

! Test invalid pointers
Expand Down Expand Up @@ -50,7 +52,10 @@ subroutine test_uniformVectorField()
call fieldT % init(dict)

! Check value
@assertEqual([9.6_defReal, -8.0_defReal, 9.7_defReal], fieldT % at(p), TOL)
@assertEqual([9.6_defReal, -8.0_defReal, 9.7_defReal], fieldT % atP(p), TOL)
Copy link
Member

Choose a reason for hiding this comment

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

Same comment as above!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This one does do both atP and at. It can't be done for the UFS field and WW field though because they only define atP and give a fatalError for at.


call coords % assignPosition([ZERO, ZERO, ZERO])
@assertEqual([9.6_defReal, -8.0_defReal, 9.7_defReal], fieldT % at(coords), TOL)

! Kill
call fieldT % kill()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ subroutine testGetValue(this)
p % coords % lvl(1) % r = [0.5, 7.0, 0.0]
p % E = 10.0

bins = this % wwField % at(p)
bins = this % wwField % atP(p)
EXPECTED_BINS = [0.4, 1.5, 0.8]

@assertEqual(EXPECTED_BINS, bins, tolerance=1e-6)
Expand All @@ -76,7 +76,7 @@ subroutine testGetValue(this)
p % coords % lvl(1) % r = [-0.5, 7.0, 0.0]
p % E = 10.0

bins = this % wwField % at(p)
bins = this % wwField % atP(p)
EXPECTED_BINS = ZERO

@assertEqual(EXPECTED_BINS, bins, tolerance=1e-6)
Expand Down
25 changes: 22 additions & 3 deletions Geometry/Fields/VectorFields/uniFissSitesField_class.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module uniFissSitesField_class
use genericProcedures, only : fatalError, numToChar
use universalVariables, only : OUTSIDE_MAT, VOID_MAT, P_NEUTRON_CE
use dictionary_class, only : dictionary
use coord_class, only : coordList
use particle_class, only : particle, particleState
use field_inter, only : field
use vectorField_inter, only : vectorField
Expand Down Expand Up @@ -77,6 +78,7 @@ module uniFissSitesField_class
procedure :: kill
procedure :: estimateVol
procedure :: at
procedure :: atP
procedure :: storeFS
procedure :: updateMap
end type uniFissSitesField
Expand Down Expand Up @@ -230,15 +232,32 @@ subroutine estimateVol(self, geom, rand, type)
end if

end subroutine estimateVol

!!
!! Get value of the vector field given coordinates
!! Not defined for UFS field
!!
!! See vectorField_inter for details
!!
function at(self, coords) result(val)
class(uniFissSitesField), intent(in) :: self
class(coordList), intent(in) :: coords
real(defReal), dimension(3) :: val
character(100), parameter :: Here = 'at (uniFissSitesField_class.f90)'

val = ZERO
call fatalError(Here,'Not defined when providing coords - must provide particle.')

end function at

!!
!! Get value of the vector field given the phase-space location of a particle
!!
!! See vectorField_inter for details
!!
function at(self, p) result(val)
function atP(self, p) result(val)
class(uniFissSitesField), intent(in) :: self
class(particle), intent(inout) :: p
class(particle), intent(in) :: p
real(defReal), dimension(3) :: val
type(particleState) :: state
integer(shortInt) :: binIdx
Expand All @@ -259,7 +278,7 @@ function at(self, p) result(val)
val(2) = self % sourceFraction(binIdx)
val(3) = ZERO

end function at
end function atP

!!
!! Store the fission sites generated in a vector
Expand Down
20 changes: 18 additions & 2 deletions Geometry/Fields/VectorFields/uniformVectorField_class.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module uniformVectorField_class
use numPrecision
use genericProcedures, only : fatalError, numToChar
use dictionary_class, only : dictionary
use coord_class, only : coordList
use particle_class, only : particle
use field_inter, only : field
use vectorField_inter, only : vectorField
Expand Down Expand Up @@ -36,6 +37,7 @@ module uniformVectorField_class
procedure :: init
procedure :: kill
procedure :: at
procedure :: atP
end type uniformVectorField

contains
Expand Down Expand Up @@ -77,14 +79,28 @@ end subroutine kill
!!
!! See vectorField_inter for details
!!
function at(self, p) result(val)
function at(self, coords) result(val)
class(uniformVectorField), intent(in) :: self
class(particle), intent(inout) :: p
class(coordList), intent(in) :: coords
real(defReal), dimension(3) :: val

val = self % val

end function at

!!
!! Get value of the scalar field by particle
!!
!! See vectorField_inter for details
!!
function atP(self, p) result(val)
class(uniformVectorField), intent(in) :: self
class(particle), intent(in) :: p
real(defReal), dimension(3) :: val

val = self % val

end function atP

!!
!! Cast field pointer to uniformVectorField pointer
Expand Down
Loading