From 4564607eff50e69c77071e52ff71242d1d0a6083 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Thu, 28 Jul 2022 18:48:11 -0500 Subject: [PATCH] Addressing comments from @paulromano --- docs/source/io_formats/statepoint.rst | 6 ++++-- openmc/mesh.py | 19 +++++++++++++------ src/mesh.cpp | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/docs/source/io_formats/statepoint.rst b/docs/source/io_formats/statepoint.rst index f96d7181d..26dbd9c2e 100644 --- a/docs/source/io_formats/statepoint.rst +++ b/docs/source/io_formats/statepoint.rst @@ -80,8 +80,10 @@ The current version of the statepoint file format is 17.0. dimension. - **Unstructured Mesh Only:** - **volumes** (*double[]*) -- Volume of each mesh cell. - - **centroids** (*double[]*) -- Location of the mesh cell - centroids. + - **vertices** (*double[]*) -- Location of the mesh vertices. + - **connectivity** (*int[]*) -- Connectivity array for the mesh + cells. + - **element_types** (*int[]*) -- Mesh element types. **/tallies/filters/** diff --git a/openmc/mesh.py b/openmc/mesh.py index 211c4075d..f2aced9f8 100644 --- a/openmc/mesh.py +++ b/openmc/mesh.py @@ -1477,7 +1477,7 @@ class UnstructuredMesh(MeshBase): .. versionadded:: 0.13 - connectivity : np.ndarray (8, n_elements) + connectivity : np.ndarray (n_elements, 8) Connectivity of the elements .. versionadded:: 0.13 @@ -1633,6 +1633,17 @@ class UnstructuredMesh(MeshBase): def centroid(self, bin): """Return the vertex averaged centroid of an element + + Parameters + ---------- + bin : int + Bin ID for the returned centroid + + Returns + ------- + numpy.ndarray + x, y, z values of the element centroid + """ conn = self.connectivity[bin] coords = self.vertices[conn] @@ -1749,11 +1760,7 @@ class UnstructuredMesh(MeshBase): arr.SetTuple1(i, data.flat[i]) grid.GetCellData().AddArray(arr) - if vtk.VTK_MAJOR_VERSION == 5: - grid.update() - writer.SetInput(grid) - else: - writer.SetInputData(grid) + writer.SetInputData(grid) writer.Write() diff --git a/src/mesh.cpp b/src/mesh.cpp index e701f954e..df5c7f2b3 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -256,7 +256,7 @@ void UnstructuredMesh::to_hdf5(hid_t group) const } else { num_elem_skipped++; xt::view(elem_types, i, xt::all()) = static_cast(ElementType::UNSUPPORTED); - xt::view(connectivity, i, xt::all()) = xt::xarray({-1, -1, -1, -1, -1, -1, -1, -1}); + xt::view(connectivity, i, xt::all()) = -1; } }