From 671b5c7a821f8e4e785849992c202c73430177e7 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Sat, 26 Sep 2015 09:36:39 +0700 Subject: [PATCH] Rename surfaces attribute of to region. --- openmc/summary.py | 8 +++---- src/geometry.F90 | 16 +++++++------- src/geometry_header.F90 | 7 +++--- src/initialize.F90 | 8 +++---- src/input_xml.F90 | 48 +++++++++++++++++++++++----------------- src/relaxng/geometry.rnc | 2 +- src/relaxng/geometry.rng | 4 ++-- src/summary.F90 | 20 ++++++++--------- 8 files changed, 60 insertions(+), 53 deletions(-) diff --git a/openmc/summary.py b/openmc/summary.py index c2c02da18a..3522e707d4 100644 --- a/openmc/summary.py +++ b/openmc/summary.py @@ -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) diff --git a/src/geometry.F90 b/src/geometry.F90 index 9e40155e52..a7a36a5351 100644 --- a/src/geometry.F90 +++ b/src/geometry.F90 @@ -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 diff --git a/src/geometry_header.F90 b/src/geometry_header.F90 index c8c99783f3..c9889a5c82 100644 --- a/src/geometry_header.F90 +++ b/src/geometry_header.F90 @@ -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 diff --git a/src/initialize.F90 b/src/initialize.F90 index d46fd8d48a..16a6a17b03 100644 --- a/src/initialize.F90 +++ b/src/initialize.F90 @@ -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))) diff --git a/src/input_xml.F90 b/src/input_xml.F90 index 156d33ce46..f074898f23 100644 --- a/src/input_xml.F90 +++ b/src/input_xml.F90 @@ -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 diff --git a/src/relaxng/geometry.rnc b/src/relaxng/geometry.rnc index 07a02af9ea..2a8d07b8c0 100644 --- a/src/relaxng/geometry.rnc +++ b/src/relaxng/geometry.rnc @@ -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+ } })? }* diff --git a/src/relaxng/geometry.rng b/src/relaxng/geometry.rng index 6a68aa721e..fcb310d0b3 100644 --- a/src/relaxng/geometry.rng +++ b/src/relaxng/geometry.rng @@ -62,10 +62,10 @@ - + - + diff --git a/src/summary.F90 b/src/summary.F90 index 49fe802305..1edb645432 100644 --- a/src/summary.F90 +++ b/src/summary.F90 @@ -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