Adding a test for complex cell bounding boxes.

This commit is contained in:
Patrick Shriwise 2019-07-15 14:35:02 -05:00
parent d223046b30
commit 77d40effb1
2 changed files with 33 additions and 0 deletions

View file

@ -183,6 +183,14 @@ class Cell(_FortranObjectWithID):
_dll.openmc_cell_set_temperature(self._index, T, instance)
@property
def bounding_box(self):
llc = np.zeros((3,), dtype=float)
urc = np.zeros((3,), dtype=float)
_dll.openmc_bounding_box(b'Cell', self.id,
llc.ctypes.data_as(POINTER(c_double)),
urc.ctypes.data_as(POINTER(c_double)))
return llc, urc
class _CellMapping(Mapping):
def __getitem__(self, key):

View file

@ -1,6 +1,31 @@
from tests.testing_harness import TestHarness
import sys
import openmc.capi
def test_complex_cell():
harness = TestHarness('statepoint.10.h5')
harness.main()
def test_complex_cell_capi():
# initialize
openmc.capi.init([])
inf = sys.float_info.max
expected_boxes = { 1 : (( -4., -4., -inf), ( 4., 4., inf)),
2 : (( -7., -7., -inf), ( 7., 7., inf)),
3 : ((-10., -10., -inf), (10., 10., inf)),
4 : ((-10., -10., -inf), (10., 10., inf)) }
for cell_id, cell in openmc.capi.cells.items():
cell_box = cell.bounding_box
assert tuple(cell_box[0]) == expected_boxes[cell_id][0]
assert tuple(cell_box[1]) == expected_boxes[cell_id][1]
cell_box = openmc.capi.bounding_box("Cell", cell_id)
assert tuple(cell_box[0]) == expected_boxes[cell_id][0]
assert tuple(cell_box[1]) == expected_boxes[cell_id][1]