From e542b2f035e397a647cc3ad0ae39946b1ad81e7b Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Wed, 6 May 2026 16:07:35 +0100 Subject: [PATCH] Allow Mesh.volumes property for 1D and 2D RegularMesh (#3914) --- openmc/mesh.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/openmc/mesh.py b/openmc/mesh.py index 3c3c0a1ac5..4129913d85 100644 --- a/openmc/mesh.py +++ b/openmc/mesh.py @@ -268,10 +268,11 @@ class MeshBase(IDManagerMixin, ABC): return string def _volume_dim_check(self): - if self.n_dimension != 3 or \ - any([d == 0 for d in self.dimension]): - raise RuntimeError(f'Mesh {self.id} is not 3D. ' - 'Volumes cannot be provided.') + if any(d == 0 for d in self.dimension): + raise RuntimeError( + f'Mesh {self.id} has a zero-size dimension. ' + 'Volumes cannot be provided.' + ) @classmethod def from_hdf5(cls, group: h5py.Group):