Small fixes for #538

This commit is contained in:
Sterling Harper 2016-01-04 18:25:59 -05:00
parent 7fea70650f
commit bae0ad7136
11 changed files with 40 additions and 39 deletions

View file

@ -185,10 +185,6 @@ if run_mode == 'k-eigenvalue':
Type of the j-th filter. Can be 'universe', 'material', 'cell', 'cellborn',
'surface', 'mesh', 'energy', 'energyout', or 'distribcell'.
**/tallies/tally <uid>/filter <j>/offset** (*int*)
Filter offset (used for distribcell filter).
**/tallies/tally <uid>/filter <j>/n_bins** (*int*)
Number of bins for the j-th filter.

View file

@ -121,6 +121,10 @@ The current revision of the summary file format is 1.
Region specification for the cell.
**/geometry/cells/cell <uid>/distribcell_index** (*int*)
Index of this cell in distribcell filter arrays.
**/geometry/surfaces/surface <uid>/index** (*int*)
Index in surfaces array used internally in OpenMC.

View file

@ -66,20 +66,20 @@ class Geometry(object):
# Find the distribcell index of the cell.
cells = self.get_all_cells()
if path[-1] in cells:
distribcell_ind = cells[path[-1]].distribcell_ind
distribcell_index = cells[path[-1]].distribcell_index
else:
raise RuntimeError('Could not find cell {} specified in a \
distribcell filter'.format(path[-1]))
# Return memoize'd offset if possible
if (path, distribcell_ind) in self._offsets:
offset = self._offsets[(path, distribcell_ind)]
if (path, distribcell_index) in self._offsets:
offset = self._offsets[(path, distribcell_index)]
# Begin recursive call to compute offset starting with the base Universe
else:
offset = self._root_universe.get_cell_instance(path,
distribcell_ind)
self._offsets[(path, distribcell_ind)] = offset
distribcell_index)
self._offsets[(path, distribcell_index)] = offset
# Return the final offset
return offset

View file

@ -272,9 +272,9 @@ class Summary(object):
region, {s.id: s for s in self.surfaces.values()})
# Get the distribcell index
ind = self._f['geometry/cells'][key]['distribcell_ind'].value
ind = self._f['geometry/cells'][key]['distribcell_index'].value
if ind != 0:
cell.distribcell_ind = ind
cell.distribcell_index = ind
# Add the Cell to the global dictionary of all Cells
self.cells[index] = cell

View file

@ -63,7 +63,7 @@ class Cell(object):
that is used to translate (shift) the universe.
offsets : ndarray
Array of offsets used for distributed cell searches
distribcell_ind : int
distribcell_index : int
Index of this cell in distribcell arrays
"""
@ -78,7 +78,7 @@ class Cell(object):
self._rotation = None
self._translation = None
self._offsets = None
self._distribcell_ind = None
self._distribcell_index = None
def __eq__(self, other):
if not isinstance(other, Cell):
@ -126,7 +126,7 @@ class Cell(object):
self._translation)
string += '{0: <16}{1}{2}\n'.format('\tOffset', '=\t', self._offsets)
string += '{0: <16}{1}{2}\n'.format('\tDistribcell index', '=\t',
self._distribcell_ind)
self._distribcell_index)
return string
@ -170,8 +170,8 @@ class Cell(object):
return self._offsets
@property
def distribcell_ind(self):
return self._distribcell_ind
def distribcell_index(self):
return self._distribcell_index
@id.setter
def id(self, cell_id):
@ -240,10 +240,10 @@ class Cell(object):
cv.check_type('cell region', region, Region)
self._region = region
@distribcell_ind.setter
def distribcell_ind(self, ind):
@distribcell_index.setter
def distribcell_index(self, ind):
cv.check_type('distribcell index', ind, Integral)
self._distribcell_ind = ind
self._distribcell_index = ind
def add_surface(self, surface, halfspace):
"""Add a half-space to the list of half-spaces whose intersection defines the
@ -285,7 +285,7 @@ class Cell(object):
else:
self.region = Intersection(self.region, region)
def get_cell_instance(self, path, distribcell_ind):
def get_cell_instance(self, path, distribcell_index):
# 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_cell_instance(path, distribcell_ind)
offset = self.offsets[distribcell_index-1]
offset += self.fill.get_cell_instance(path, distribcell_index)
# If the Cell is filled by a Lattice
else:
offset = self.fill.get_cell_instance(path, distribcell_ind)
offset = self.fill.get_cell_instance(path, distribcell_index)
return offset
@ -605,7 +605,7 @@ class Universe(object):
self._cells.clear()
def get_cell_instance(self, path, distribcell_ind):
def get_cell_instance(self, path, distribcell_index):
# 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_cell_instance(path, distribcell_ind)
offset = self.cells[cell_id].get_cell_instance(path, distribcell_index)
# Return the offset computed at all nested Universe levels
return offset
@ -1073,22 +1073,22 @@ class RectLattice(Lattice):
cv.check_greater_than('lattice pitch', dim, 0.0)
self._pitch = pitch
def get_cell_instance(self, path, distribcell_ind):
def get_cell_instance(self, path, distribcell_index):
# Get the current element and remove it from the list
i = path[0]
path = path[1:]
# For 2D Lattices
if len(self._dimension) == 2:
offset = self._offsets[i[1]-1, i[2]-1, 0, distribcell_ind-1]
offset = self._offsets[i[1]-1, i[2]-1, 0, distribcell_index-1]
offset += self._universes[i[1]][i[2]].get_cell_instance(path,
distribcell_ind)
distribcell_index)
# For 3D Lattices
else:
offset = self._offsets[i[1]-1, i[2]-1, i[3]-1, distribcell_ind-1]
offset = self._offsets[i[1]-1, i[2]-1, i[3]-1, distribcell_index-1]
offset += self._universes[i[1]-1][i[2]-1][i[3]-1].get_cell_instance(
path, distribcell_ind)
path, distribcell_index)
return offset

View file

@ -136,7 +136,7 @@ module geometry_header
! expression
logical :: simple ! Is the region simple (intersections
! only)
integer :: distribcell_ind ! Index corresponding to this cell in
integer :: distribcell_index ! Index corresponding to this cell in
! distribcell arrays
! Rotation matrix and translation vector

View file

@ -1092,7 +1092,7 @@ contains
univ => universes(i)
do j = 1, univ % n_cells
if (cell_list % contains(univ % cells(j))) then
cells(univ % cells(j)) % distribcell_ind = k
cells(univ % cells(j)) % distribcell_index = k
univ_list(k) = univ % id
k = k + 1
end if

View file

@ -1051,7 +1051,7 @@ contains
! Initialize distribcell instances and distribcell index
c % instances = 0
c % distribcell_ind = NONE
c % distribcell_index = NONE
! Get pointer to i-th cell node
call get_list_item(node_cell_list, i, node_cell)

View file

@ -1436,7 +1436,7 @@ contains
class(Lattice), pointer :: lat ! Pointer to current lattice
! Get the distribcell index for this cell
map = cells(goal) % distribcell_ind
map = cells(goal) % distribcell_index
n = univ % n_cells

View file

@ -196,7 +196,7 @@ contains
end do
call write_dataset(cell_group, "region", adjustl(region_spec))
call write_dataset(cell_group, "distribcell_ind", c % distribcell_ind)
call write_dataset(cell_group, "distribcell_index", c % distribcell_index)
call close_group(cell_group)
end do CELL_LOOP

View file

@ -1712,7 +1712,7 @@ contains
integer :: j
integer :: n ! number of bins for single filter
integer :: offset ! offset for distribcell
integer :: distribcell_ind ! index in distribcell arrays
integer :: distribcell_index ! index in distribcell arrays
real(8) :: E ! particle energy
real(8) :: theta, phi ! Polar and Azimuthal Angles, respectively
type(TallyObject), pointer :: t
@ -1757,13 +1757,14 @@ contains
case (FILTER_DISTRIBCELL)
! determine next distribcell bin
distribcell_ind = cells(t % filters(i) % int_bins(1)) % distribcell_ind
distribcell_index = cells(t % filters(i) % int_bins(1)) &
% distribcell_index
matching_bins(i) = NO_BIN_FOUND
offset = 0
do j = 1, p % n_coord
if (cells(p % coord(j) % cell) % type == CELL_FILL) then
offset = offset + cells(p % coord(j) % cell) % &
offset(distribcell_ind)
offset(distribcell_index)
elseif(cells(p % coord(j) % cell) % type == CELL_LATTICE) then
if (lattices(p % coord(j + 1) % lattice) % obj &
% are_valid_indices([&
@ -1771,7 +1772,7 @@ contains
p % coord(j + 1) % lattice_y, &
p % coord(j + 1) % lattice_z])) then
offset = offset + lattices(p % coord(j + 1) % lattice) % obj % &
offset(distribcell_ind, &
offset(distribcell_index, &
p % coord(j + 1) % lattice_x, &
p % coord(j + 1) % lattice_y, &
p % coord(j + 1) % lattice_z)