From 5a716f1f3ad41cdaabe1dc1221404befa4cdad59 Mon Sep 17 00:00:00 2001 From: Ethan Peterson Date: Fri, 18 Nov 2022 11:56:27 -0500 Subject: [PATCH 1/2] moved coordinate axis to 0 --- openmc/mesh.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/openmc/mesh.py b/openmc/mesh.py index 72b0210666..d180bc7bd7 100644 --- a/openmc/mesh.py +++ b/openmc/mesh.py @@ -172,10 +172,10 @@ class StructuredMesh(MeshBase): ------- vertices : numpy.ndarray Returns a numpy.ndarray representing the coordinates of the mesh - vertices with a shape equal to (dim1 + 1, ..., dimn + 1, ndim). + vertices with a shape equal to (ndim, dim1 + 1, ..., dimn + 1). """ - return np.stack(np.meshgrid(*self._grids, indexing='ij'), axis=-1) + return np.stack(np.meshgrid(*self._grids, indexing='ij'), axis=0) @property def centroids(self): @@ -185,13 +185,14 @@ class StructuredMesh(MeshBase): ------- centroids : numpy.ndarray Returns a numpy.ndarray representing the mesh element centroid - coordinates with a shape equal to (dim1, ..., dimn, ndim). + coordinates with a shape equal to (ndim, dim1, ..., dimn). Can be + unpacked by the first dimension with xx, yy, zz = mesh.centroids """ ndim = self.n_dimension vertices = self.vertices - s0 = (slice(0, -1),)*ndim + (slice(None),) - s1 = (slice(1, None),)*ndim + (slice(None),) + s0 = (slice(None),) + (slice(0, -1),)*ndim + s1 = (slice(None),) + (slice(1, None),)*ndim return (vertices[s0] + vertices[s1]) / 2 @property From 3794673c704b18756ed28c836d7bab4be24c4f35 Mon Sep 17 00:00:00 2001 From: Ethan Peterson Date: Sun, 27 Nov 2022 15:54:03 -0500 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Patrick Shriwise --- openmc/mesh.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openmc/mesh.py b/openmc/mesh.py index d180bc7bd7..157e782633 100644 --- a/openmc/mesh.py +++ b/openmc/mesh.py @@ -172,7 +172,8 @@ class StructuredMesh(MeshBase): ------- vertices : numpy.ndarray Returns a numpy.ndarray representing the coordinates of the mesh - vertices with a shape equal to (ndim, dim1 + 1, ..., dimn + 1). + vertices with a shape equal to (ndim, dim1 + 1, ..., dimn + 1). Can be + unpacked along the first dimension with xx, yy, zz = mesh.vertices. """ return np.stack(np.meshgrid(*self._grids, indexing='ij'), axis=0) @@ -186,7 +187,8 @@ class StructuredMesh(MeshBase): centroids : numpy.ndarray Returns a numpy.ndarray representing the mesh element centroid coordinates with a shape equal to (ndim, dim1, ..., dimn). Can be - unpacked by the first dimension with xx, yy, zz = mesh.centroids + unpacked along the first dimension with xx, yy, zz = mesh.centroids. + """ ndim = self.n_dimension