Repository navigation
Add bounding_box property to RectilinearMesh and UnstructuredMesh #2861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,3 +1,4 @@ | ||||||
| from __future__ import annotations | ||||||
| import typing | ||||||
| import warnings | ||||||
| from abc import ABC, abstractmethod | ||||||
|
|
@@ -35,6 +36,9 @@ class MeshBase(IDManagerMixin, ABC): | |||||
| Unique identifier for the mesh | ||||||
| name : str | ||||||
| Name of the mesh | ||||||
| bounding_box : openmc.BoundingBox | ||||||
| Axis-aligned bounding box of the cell defined by the upper-right and | ||||||
| lower-left coordinates. | ||||||
|
|
||||||
| """ | ||||||
|
|
||||||
|
|
@@ -58,6 +62,10 @@ def name(self, name: str): | |||||
| else: | ||||||
| self._name = '' | ||||||
|
|
||||||
| @property | ||||||
| def bounding_box(self) -> openmc.BoundingBox: | ||||||
| return openmc.BoundingBox(self.lower_left, self.upper_right) | ||||||
|
|
||||||
| def __repr__(self): | ||||||
| string = type(self).__name__ + '\n' | ||||||
| string += '{0: <16}{1}{2}\n'.format('\tID', '=\t', self._id) | ||||||
|
|
@@ -507,9 +515,9 @@ class RegularMesh(StructuredMesh): | |||||
| upper_right : Iterable of float | ||||||
| The upper-right corner of the structured mesh. If only two coordinate | ||||||
| are given, it is assumed that the mesh is an x-y mesh. | ||||||
| bounding_box: openmc.BoundingBox | ||||||
| Axis-aligned bounding box of the cell defined by the upper-right and lower- | ||||||
| left coordinates | ||||||
| bounding_box : openmc.BoundingBox | ||||||
| Axis-aligned bounding box of the cell defined by the upper-right and | ||||||
| lower-left coordinates. | ||||||
| width : Iterable of float | ||||||
| The width of mesh cells in each direction. | ||||||
| indices : Iterable of tuple | ||||||
|
|
@@ -660,12 +668,6 @@ def _grids(self): | |||||
| x1, = self.upper_right | ||||||
| return (np.linspace(x0, x1, nx + 1),) | ||||||
|
|
||||||
| @property | ||||||
| def bounding_box(self): | ||||||
| return openmc.BoundingBox( | ||||||
| np.array(self.lower_left), np.array(self.upper_right) | ||||||
| ) | ||||||
|
|
||||||
| def __repr__(self): | ||||||
| string = super().__repr__() | ||||||
| string += '{0: <16}{1}{2}\n'.format('\tDimensions', '=\t', self.n_dimension) | ||||||
|
|
@@ -1005,6 +1007,9 @@ class RectilinearMesh(StructuredMesh): | |||||
| indices : Iterable of tuple | ||||||
| An iterable of mesh indices for each mesh element, e.g. [(1, 1, 1), | ||||||
| (2, 1, 1), ...] | ||||||
| bounding_box : openmc.BoundingBox | ||||||
| Axis-aligned bounding box of the cell defined by the upper-right and | ||||||
| lower-left coordinates. | ||||||
|
|
||||||
| """ | ||||||
|
|
||||||
|
|
@@ -1056,6 +1061,14 @@ def z_grid(self, grid): | |||||
| def _grids(self): | ||||||
| return (self.x_grid, self.y_grid, self.z_grid) | ||||||
|
|
||||||
| @property | ||||||
| def lower_left(self): | ||||||
| return np.array([self.x_grid[0], self.y_grid[0], self.z_grid[0]]) | ||||||
|
|
||||||
| @property | ||||||
| def upper_right(self): | ||||||
| return np.array([self.x_grid[-1], self.y_grid[-1], self.z_grid[-1]]) | ||||||
|
|
||||||
| @property | ||||||
| def volumes(self): | ||||||
| """Return Volumes for every mesh cell | ||||||
|
|
@@ -1222,9 +1235,9 @@ class CylindricalMesh(StructuredMesh): | |||||
| upper_right : Iterable of float | ||||||
| The upper-right corner of the structured mesh. If only two coordinate | ||||||
| are given, it is assumed that the mesh is an x-y mesh. | ||||||
| bounding_box: openmc.OpenMC | ||||||
| Axis-aligned cartesian bounding box of cell defined by upper-right and lower- | ||||||
| left coordinates | ||||||
| bounding_box : openmc.BoundingBox | ||||||
| Axis-aligned bounding box of the cell defined by the upper-right and | ||||||
| lower-left coordinates. | ||||||
|
|
||||||
| """ | ||||||
|
|
||||||
|
|
@@ -1321,10 +1334,6 @@ def upper_right(self): | |||||
| self.origin[2] + self.z_grid[-1] | ||||||
| )) | ||||||
|
|
||||||
| @property | ||||||
| def bounding_box(self): | ||||||
| return openmc.BoundingBox(self.lower_left, self.upper_right) | ||||||
|
|
||||||
| def __repr__(self): | ||||||
| fmt = '{0: <16}{1}{2}\n' | ||||||
| string = super().__repr__() | ||||||
|
|
@@ -1666,8 +1675,8 @@ class SphericalMesh(StructuredMesh): | |||||
| The upper-right corner of the structured mesh. If only two coordinate | ||||||
| are given, it is assumed that the mesh is an x-y mesh. | ||||||
| bounding_box : openmc.BoundingBox | ||||||
| Axis-aligned bounding box of the cell defined by the upper-right and lower- | ||||||
| left coordinates | ||||||
| Axis-aligned bounding box of the cell defined by the upper-right and | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| lower-left coordinates. | ||||||
|
|
||||||
| """ | ||||||
|
|
||||||
|
|
@@ -1758,10 +1767,6 @@ def upper_right(self): | |||||
| r = self.r_grid[-1] | ||||||
| return np.array((self.origin[0] + r, self.origin[1] + r, self.origin[2] + r)) | ||||||
|
|
||||||
| @property | ||||||
| def bounding_box(self): | ||||||
| return openmc.BoundingBox(self.lower_left, self.upper_right) | ||||||
|
|
||||||
| def __repr__(self): | ||||||
| fmt = '{0: <16}{1}{2}\n' | ||||||
| string = super().__repr__() | ||||||
|
|
@@ -1943,8 +1948,8 @@ class UnstructuredMesh(MeshBase): | |||||
| library : {'moab', 'libmesh'} | ||||||
| Mesh library used for the unstructured mesh tally | ||||||
| output : bool | ||||||
| Indicates whether or not automatic tally output should | ||||||
| be generated for this mesh | ||||||
| Indicates whether or not automatic tally output should be generated for | ||||||
| this mesh | ||||||
| volumes : Iterable of float | ||||||
| Volumes of the unstructured mesh elements | ||||||
| centroids : numpy.ndarray | ||||||
|
|
@@ -1964,6 +1969,10 @@ class UnstructuredMesh(MeshBase): | |||||
| .. versionadded:: 0.13.1 | ||||||
| total_volume : float | ||||||
| Volume of the unstructured mesh in total | ||||||
| bounding_box : openmc.BoundingBox | ||||||
| Axis-aligned bounding box of the cell defined by the upper-right and | ||||||
| lower-left coordinates. | ||||||
|
|
||||||
| """ | ||||||
|
|
||||||
| _UNSUPPORTED_ELEM = -1 | ||||||
|
|
@@ -2096,6 +2105,14 @@ def __repr__(self): | |||||
| self.length_multiplier) | ||||||
| return string | ||||||
|
|
||||||
| @property | ||||||
| def lower_left(self): | ||||||
| return self.vertices.min(axis=0) | ||||||
|
|
||||||
| @property | ||||||
| def upper_right(self): | ||||||
| return self.vertices.max(axis=0) | ||||||
|
|
||||||
| def centroid(self, bin: int): | ||||||
| """Return the vertex averaged centroid of an element | ||||||
|
|
||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.