Rename surfaces attribute of <cell> to region.

This commit is contained in:
Paul Romano 2015-09-26 09:36:39 +07:00
parent 7681995ef1
commit 671b5c7a82
8 changed files with 60 additions and 53 deletions

View file

@ -212,10 +212,10 @@ class Summary(object):
else:
fill = self._f['geometry/cells'][key]['lattice'].value
if 'surfaces' in self._f['geometry/cells'][key].keys():
surfaces = self._f['geometry/cells'][key]['surfaces'].value.decode()
if 'region' in self._f['geometry/cells'][key].keys():
region = self._f['geometry/cells'][key]['region'].value.decode()
else:
surfaces = []
region = []
# Create this Cell
cell = openmc.Cell(cell_id=cell_id, name=name)
@ -241,7 +241,7 @@ class Summary(object):
self._cell_fills[index] = (fill_type, fill)
# Iterate over all Surfaces and add them to the Cell
for token in surfaces.split():
for token in region.split():
try:
surface_halfspace = int(token)
halfspace = np.sign(surface_halfspace)

View file

@ -577,9 +577,9 @@ contains
! =======================================================================
! FIND MINIMUM DISTANCE TO SURFACE IN THIS CELL
SURFACE_LOOP: do i = 1, size(cl%surfaces)
SURFACE_LOOP: do i = 1, size(cl%region)
! check for operators
index_surf = cl%surfaces(i)
index_surf = cl%region(i)
coincident = (index_surf == p % surface)
! check for operators
@ -594,7 +594,7 @@ contains
if (d < d_surf) then
if (abs(d - d_surf)/d_surf >= FP_PRECISION) then
d_surf = d
level_surf_cross = -cl % surfaces(i)
level_surf_cross = -cl % region(i)
end if
end if
end do SURFACE_LOOP
@ -843,9 +843,9 @@ contains
do i = 1, n_cells
c => cells(i)
! loop over each surface specification
do j = 1, size(c%surfaces)
i_surface = c % surfaces(j)
! loop over each region specification
do j = 1, size(c%region)
i_surface = c % region(j)
positive = (i_surface > 0)
i_surface = abs(i_surface)
if (i_surface >= OP_UNION) cycle
@ -875,8 +875,8 @@ contains
c => cells(i)
! loop over each surface specification
do j = 1, size(c%surfaces)
i_surface = c % surfaces(j)
do j = 1, size(c%region)
i_surface = c % region(j)
positive = (i_surface > 0)
i_surface = abs(i_surface)
if (i_surface >= OP_UNION) cycle

View file

@ -130,10 +130,9 @@ module geometry_header
! universe)
integer, allocatable :: offset (:) ! Distribcell offset for tally
! counter
integer, allocatable :: surfaces(:) ! List of surfaces bounding cell --
! note that parentheses, union, etc
! operators will be listed here too
integer, allocatable :: rpn(:) ! Reverse Polish notation for surface
integer, allocatable :: region(:) ! Definition of spatial region as
! Boolean expression of half-spaces
integer, allocatable :: rpn(:) ! Reverse Polish notation for region
! expression
! Rotation matrix and translation vector

View file

@ -568,15 +568,15 @@ contains
do i = 1, n_cells
! =======================================================================
! ADJUST SURFACE LIST FOR EACH CELL
! ADJUST REGION SPECIFICATION FOR EACH CELL
c => cells(i)
do j = 1, size(c%surfaces)
id = c%surfaces(j)
do j = 1, size(c%region)
id = c%region(j)
if (id < OP_UNION) then
if (surface_dict%has_key(abs(id))) then
i_array = surface_dict%get_key(abs(id))
c%surfaces(j) = sign(i_array, id)
c%region(j) = sign(i_array, id)
else
call fatal_error("Could not find surface " // trim(to_str(abs(id)))&
&// " specified on cell " // trim(to_str(c%id)))

View file

@ -994,7 +994,7 @@ contains
logical :: boundary_exists
character(MAX_LINE_LEN) :: filename
character(MAX_WORD_LEN) :: word
character(MAX_LINE_LEN) :: surface_spec
character(MAX_LINE_LEN) :: region_spec
type(Cell), pointer :: c
class(Surface), pointer :: s
class(Lattice), pointer :: lat
@ -1118,27 +1118,35 @@ contains
call fatal_error("Cannot specify material and fill simultaneously")
end if
! Allocate array for surfaces and copy
! Check for region specification (also under deprecated name surfaces)
region_spec = ''
if (check_for_node(node_cell, "surfaces")) then
call get_node_value(node_cell, "surfaces", surface_spec)
if (len_trim(surface_spec) > 0) then
! Create surfaces array from string
call tokenize(surface_spec, tokens)
! Use shunting-yard algorithm to determine RPN for surface algorithm
call generate_rpn(tokens, rpn)
! Copy surface spec and RPN form to cell arrays
allocate(c % surfaces(tokens%size()))
allocate(c % rpn(rpn%size()))
c % surfaces(:) = tokens%data(1:tokens%size())
c % rpn(:) = rpn%data(1:rpn%size())
call tokens%clear()
call rpn%clear()
end if
call warning("The use of 'surfaces' is deprecated and will be &
&disallowed in a future release. Use 'region' instead. The &
&openmc-update-inputs utility can be used to automatically &
&update geometry.xml files.")
call get_node_value(node_cell, "surfaces", region_spec)
elseif (check_for_node(node_cell, "region")) then
call get_node_value(node_cell, "region", region_spec)
end if
if (.not. allocated(c%surfaces)) allocate(c%surfaces(0))
if (len_trim(region_spec) > 0) then
! Create surfaces array from string
call tokenize(region_spec, tokens)
! Use shunting-yard algorithm to determine RPN for surface algorithm
call generate_rpn(tokens, rpn)
! Copy surface spec and RPN form to cell arrays
allocate(c % region(tokens%size()))
allocate(c % rpn(rpn%size()))
c % region(:) = tokens%data(1:tokens%size())
c % rpn(:) = rpn%data(1:rpn%size())
call tokens%clear()
call rpn%clear()
end if
if (.not. allocated(c%region)) allocate(c%region(0))
if (.not. allocated(c%rpn)) allocate(c%rpn(0))
! Rotation matrix

View file

@ -9,7 +9,7 @@ element geometry {
(element material { ( xsd:int | "void" ) } |
attribute material { ( xsd:int | "void" ) })
) &
(element surfaces { xsd:string } | attribute surfaces { xsd:string })? &
(element region { xsd:string } | attribute region { xsd:string })? &
(element rotation { list { xsd:double+ } } | attribute rotation { list { xsd:double+ } })? &
(element translation { list { xsd:double+ } } | attribute translation { list { xsd:double+ } })?
}*

View file

@ -62,10 +62,10 @@
</choice>
<optional>
<choice>
<element name="surfaces">
<element name="region">
<data type="string"/>
</element>
<attribute name="surfaces">
<attribute name="region">
<data type="string"/>
</attribute>
</choice>

View file

@ -113,7 +113,7 @@ contains
integer(HID_T) :: universes_group, univ_group
integer(HID_T) :: lattices_group, lattice_group
real(8), allocatable :: coeffs(:)
character(MAX_LINE_LEN) :: surface_spec
character(MAX_LINE_LEN) :: region_spec
type(Cell), pointer :: c
class(Surface), pointer :: s
type(Universe), pointer :: u
@ -176,26 +176,26 @@ contains
end select
! Write list of bounding surfaces
surface_spec = ""
do j = 1, size(c%surfaces)
k = c%surfaces(j)
region_spec = ""
do j = 1, size(c%region)
k = c%region(j)
if (k < OP_UNION) then
surface_spec = trim(surface_spec) // " " // to_str(&
region_spec = trim(region_spec) // " " // to_str(&
sign(surfaces(abs(k))%obj%id, k))
else
select case(k)
case (OP_LEFT_PAREN)
surface_spec = trim(surface_spec) // " ("
region_spec = trim(region_spec) // " ("
case (OP_RIGHT_PAREN)
surface_spec = trim(surface_spec) // " ("
region_spec = trim(region_spec) // " )"
case (OP_COMPLEMENT)
surface_spec = trim(surface_spec) // " ~"
region_spec = trim(region_spec) // " ~"
case (OP_UNION)
surface_spec = trim(surface_spec) // " ^"
region_spec = trim(region_spec) // " ^"
end select
end if
end do
call write_dataset(cell_group, "surfaces", adjustl(surface_spec))
call write_dataset(cell_group, "region", adjustl(region_spec))
call close_group(cell_group)
end do CELL_LOOP