mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Merge pull request #2111 from shimwell/adding_dagmc_bounding_box_property
adding bounding box property to DAGMCUniverse objects
This commit is contained in:
commit
f650721296
2 changed files with 17 additions and 0 deletions
|
|
@ -7,6 +7,7 @@ from pathlib import Path
|
|||
from tempfile import TemporaryDirectory
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
import h5py
|
||||
import numpy as np
|
||||
|
||||
import openmc
|
||||
|
|
@ -630,6 +631,9 @@ class DAGMCUniverse(UniverseBase):
|
|||
auto_mat_ids : bool
|
||||
Set IDs automatically on initialization (True) or report overlaps
|
||||
in ID space between OpenMC and UWUW materials (False)
|
||||
bounding_box : 2-tuple of numpy.array
|
||||
Lower-left and upper-right coordinates of an axis-aligned bounding box
|
||||
of the universe.
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
|
|
@ -650,6 +654,14 @@ class DAGMCUniverse(UniverseBase):
|
|||
string += '{: <16}=\t{}\n'.format('\tFile', self.filename)
|
||||
return string
|
||||
|
||||
@property
|
||||
def bounding_box(self):
|
||||
with h5py.File(self.filename) as dagmc_file:
|
||||
coords = dagmc_file['tstt']['nodes']['coordinates'][()]
|
||||
lower_left_corner = coords.min(axis=0)
|
||||
upper_right_corner = coords.max(axis=0)
|
||||
return (lower_left_corner, upper_right_corner)
|
||||
|
||||
@property
|
||||
def filename(self):
|
||||
return self._filename
|
||||
|
|
|
|||
|
|
@ -46,6 +46,11 @@ class DAGMCUniverseTest(PyAPITestHarness):
|
|||
# create the DAGMC universe
|
||||
pincell_univ = openmc.DAGMCUniverse(filename='dagmc.h5m', auto_geom_ids=True)
|
||||
|
||||
# checks that the bounding box is calculated correctly
|
||||
bounding_box = pincell_univ.bounding_box
|
||||
assert bounding_box[0].tolist() == [-25., -25., -25.]
|
||||
assert bounding_box[1].tolist() == [25., 25., 25.]
|
||||
|
||||
# create a 2 x 2 lattice using the DAGMC pincell
|
||||
pitch = np.asarray((24.0, 24.0))
|
||||
lattice = openmc.RectLattice()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue