diff --git a/src/meshio/_mesh.py b/src/meshio/_mesh.py index 35c11620b..46ddc5467 100644 --- a/src/meshio/_mesh.py +++ b/src/meshio/_mesh.py @@ -333,9 +333,10 @@ def sets_to_int_data(self): intfun.append(arr) for item in intfun: - if np.any(item == default_value): + num_default = np.sum(item == default_value) + if num_default > 0: warnings.warn( - "Not all cells are part of a cell set. " + f"{num_default} cells are not part of any cell set. " f"Using default value {default_value}." ) break diff --git a/src/meshio/flac3d/_flac3d.py b/src/meshio/flac3d/_flac3d.py index fca76685e..f6d1d1184 100644 --- a/src/meshio/flac3d/_flac3d.py +++ b/src/meshio/flac3d/_flac3d.py @@ -4,6 +4,7 @@ import logging import struct import time +from warnings import warn import numpy as np @@ -112,6 +113,7 @@ def read_buffer(f, binary): point_ids = {} cells = [] cell_sets = {} + cell_ids = [] pidx = 0 if binary: @@ -128,7 +130,8 @@ def read_buffer(f, binary): for flag in ["zone", "face"]: (num_cells,) = struct.unpack(" 0: + # Can only deal with sequential cell_ids for now. If the order is messed + # up, or if some indices are missing, cell_sets will be wrong. + if not np.all(np.arange(cell_ids[0], cell_ids[-1] + 1) == cell_ids): + warn("FLAC3D cell IDs not sequential. Cell sets probably messed up.") + # cell_sets contains the indices into the global cell list. Since this is # split up into blocks, we need to split the cell_sets, too. bins = np.cumsum([len(cb[1]) for cb in cell_blocks])