added numbers for size

This commit is contained in:
Jonathan Shimwell 2022-08-25 12:50:56 +01:00
parent 2805060ddd
commit fb6984e0a7

View file

@ -217,7 +217,7 @@ class StructuredMesh(MeshBase):
Raises
------
RuntimeError
When the size of a dataset doesn't match the number of cells
When the size of a dataset doesn't match the number of mesh cells
Returns
-------
@ -229,13 +229,14 @@ class StructuredMesh(MeshBase):
from vtk.util import numpy_support as nps
# check that the data sets are appropriately sized
errmsg = "The size of the dataset {} should be equal to the number of cells"
errmsg = "The size of the dataset {} ({}) should be equal to the number of mesh cells ({})"
for label, dataset in datasets.items():
if isinstance(dataset, np.ndarray):
if not dataset.size == self.dimension[0] * self.dimension[1]* self.dimension[2]:
raise RuntimeError(errmsg.format(label))
num_cells = self.dimension[0] * self.dimension[1] * self.dimension[2]
if not dataset.size == num_cells:
raise RuntimeError(errmsg.format(label, dataset.size, num_cells))
else:
if len(dataset) == self.dimension[0] * self.dimension[1]* self.dimension[2]:
if len(dataset) == self.dimension[0] * self.dimension[1] * self.dimension[2]:
raise RuntimeError(errmsg.format(label))
cv.check_type('label', label, str)