From 33375dfa30f80de5fe69dcfb47425d21642e479a Mon Sep 17 00:00:00 2001 From: Sterling Harper Date: Wed, 30 Dec 2015 15:57:44 -0500 Subject: [PATCH] Small fixes for #538 --- openmc/filter.py | 2 +- openmc/geometry.py | 5 +++-- openmc/universe.py | 22 +++++++++++----------- src/initialize.F90 | 14 +++++++------- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/openmc/filter.py b/openmc/filter.py index ea92f5257..d61fb648f 100644 --- a/openmc/filter.py +++ b/openmc/filter.py @@ -609,7 +609,7 @@ class Filter(object): # If this region is in Cell corresponding to the # distribcell filter bin, store it in dictionary if cell_id == self.bins[0]: - offset = openmc_geometry.get_offset(path) + offset = openmc_geometry.get_cell_instance(path) offsets_to_coords[offset] = coords # Each distribcell offset is a DataFrame bin diff --git a/openmc/geometry.py b/openmc/geometry.py index 16f6a45e5..baadfce3c 100644 --- a/openmc/geometry.py +++ b/openmc/geometry.py @@ -42,7 +42,7 @@ class Geometry(object): self._root_universe = root_universe - def get_offset(self, path): + def get_cell_instance(self, path): """Returns the corresponding location in the results array for a given path and filter number. This is primarily intended to post-processing result when a distribcell filter is used. @@ -77,7 +77,8 @@ class Geometry(object): # Begin recursive call to compute offset starting with the base Universe else: - offset = self._root_universe.get_offset(path, distribcell_ind) + offset = self._root_universe.get_cell_instance(path, + distribcell_ind) self._offsets[(path, distribcell_ind)] = offset # Return the final offset diff --git a/openmc/universe.py b/openmc/universe.py index b346ffd00..e7b2151a3 100644 --- a/openmc/universe.py +++ b/openmc/universe.py @@ -285,7 +285,7 @@ class Cell(object): else: self.region = Intersection(self.region, region) - def get_offset(self, path, distribcell_ind): + def get_cell_instance(self, path, distribcell_ind): # Get the current element and remove it from the list cell_id = path[0] path = path[1:] @@ -296,12 +296,12 @@ class Cell(object): # If the Cell is filled by a Universe elif self._type == 'fill': - offset = self._offsets[distribcell_ind-1] - offset += self._fill.get_offset(path, distribcell_ind) + offset = self.offsets[distribcell_ind-1] + offset += self.fill.get_cell_instance(path, distribcell_ind) # If the Cell is filled by a Lattice else: - offset = self._fill.get_offset(path, distribcell_ind) + offset = self.fill.get_cell_instance(path, distribcell_ind) return offset @@ -605,7 +605,7 @@ class Universe(object): self._cells.clear() - def get_offset(self, path, distribcell_ind): + def get_cell_instance(self, path, distribcell_ind): # Get the current element and remove it from the list path = path[1:] @@ -613,7 +613,7 @@ class Universe(object): cell_id = path[0] # Make a recursive call to the Cell within this Universe - offset = self._cells[cell_id].get_offset(path, distribcell_ind) + offset = self.cells[cell_id].get_cell_instance(path, distribcell_ind) # Return the offset computed at all nested Universe levels return offset @@ -1073,7 +1073,7 @@ class RectLattice(Lattice): cv.check_greater_than('lattice pitch', dim, 0.0) self._pitch = pitch - def get_offset(self, path, distribcell_ind): + def get_cell_instance(self, path, distribcell_ind): # Get the current element and remove it from the list i = path[0] path = path[1:] @@ -1081,14 +1081,14 @@ class RectLattice(Lattice): # For 2D Lattices if len(self._dimension) == 2: offset = self._offsets[i[1]-1, i[2]-1, 0, distribcell_ind-1] - offset += self._universes[i[1]][i[2]].get_offset(path, - distribcell_ind) + offset += self._universes[i[1]][i[2]].get_cell_instance(path, + distribcell_ind) # For 3D Lattices else: offset = self._offsets[i[1]-1, i[2]-1, i[3]-1, distribcell_ind-1] - offset += self._universes[i[1]-1][i[2]-1][i[3]-1].get_offset(path, - distribcell_ind) + offset += self._universes[i[1]-1][i[2]-1][i[3]-1].get_cell_instance( + path, distribcell_ind) return offset diff --git a/src/initialize.F90 b/src/initialize.F90 index acfe92b92..1134040e9 100644 --- a/src/initialize.F90 +++ b/src/initialize.F90 @@ -1086,16 +1086,16 @@ contains found(:,:) = .false. k = 1 + ! Search through universes for distributed cells and assign each one a + ! unique distribcell array index. do i = 1, n_universes univ => universes(i) - do j = 1, univ % n_cells - if (.not. cell_list % contains(univ % cells(j))) cycle - - cells(univ % cells(j)) % distribcell_ind = k - - univ_list(k) = univ % id - k = k + 1 + if (cell_list % contains(univ % cells(j))) then + cells(univ % cells(j)) % distribcell_ind = k + univ_list(k) = univ % id + k = k + 1 + end if end do end do