@@ -97,7 +97,7 @@ def _cells_from_data(connectivity, offsets, types, cell_data_raw):
97
97
start_cn [items + 1 ],
98
98
_vtk_to_meshio_order (types [start ], sz , dtype = offsets .dtype ) - sz ,
99
99
)
100
- cells .append (CellBlock (meshio_type + str ( sz ) , connectivity [indices ]))
100
+ cells .append (CellBlock (meshio_type , connectivity [indices ]))
101
101
102
102
# Store cell data for this set of cells
103
103
for name , d in cell_data_raw .items ():
@@ -668,9 +668,10 @@ def write(filename, mesh, binary=True, compression="zlib", header_type=None):
668
668
# in certain places.
669
669
is_polyhedron_grid = False
670
670
for c in mesh .cells :
671
- if c .type [: 10 ] == "polyhedron" :
671
+ if c .type . startswith ( "polyhedron" ) :
672
672
is_polyhedron_grid = True
673
673
break
674
+
674
675
# The current implementation cannot mix polyhedral cells with other cell types.
675
676
# To write such meshes, represent all cells as polyhedra.
676
677
if is_polyhedron_grid :
@@ -908,31 +909,9 @@ def _polyhedron_face_cells(face_cells):
908
909
909
910
# types
910
911
types_array = []
911
- for k , v in mesh .cells :
912
- # For polygon and polyhedron grids, the number of nodes is part of the cell
913
- # type key. This part must be stripped away.
914
- special_cells = [
915
- "polygon" ,
916
- "polyhedron" ,
917
- "VTK_LAGRANGE_CURVE" ,
918
- "VTK_LAGRANGE_TRIANGLE" ,
919
- "VTK_LAGRANGE_QUADRILATERAL" ,
920
- "VTK_LAGRANGE_TETRAHEDRON" ,
921
- "VTK_LAGRANGE_HEXAHEDRON" ,
922
- "VTK_LAGRANGE_WEDGE" ,
923
- "VTK_LAGRANGE_PYRAMID" ,
924
- ]
925
- key_ = None
926
- for string in special_cells :
927
- if k .startswith (string ):
928
- key_ = string
929
-
930
- if key_ is None :
931
- # No special treatment
932
- key_ = k
933
-
934
- # further adaptions for polyhedron
935
- if k .startswith ("polyhedron" ):
912
+ for key , v in mesh .cells :
913
+ # some adaptions for polyhedron
914
+ if key .startswith ("polyhedron" ):
936
915
# Get face-cell relation on the vtu format. See comments in helper
937
916
# function for more information of how to specify this.
938
917
faces_loc , faceoffsets_loc = _polyhedron_face_cells (v )
@@ -944,8 +923,9 @@ def _polyhedron_face_cells(face_cells):
944
923
assert faces is not None
945
924
faces += faces_loc
946
925
faceoffsets += faceoffsets_loc
926
+ key = "polyhedron"
947
927
948
- types_array .append (np .full (len (v ), meshio_to_vtk_type [key_ ]))
928
+ types_array .append (np .full (len (v ), meshio_to_vtk_type [key ]))
949
929
950
930
types = np .concatenate (
951
931
types_array
0 commit comments