@@ -97,7 +97,7 @@ def _cells_from_data(connectivity, offsets, types, cell_data_raw):
9797 start_cn [items + 1 ],
9898 _vtk_to_meshio_order (types [start ], sz , dtype = offsets .dtype ) - sz ,
9999 )
100- cells .append (CellBlock (meshio_type + str ( sz ) , connectivity [indices ]))
100+ cells .append (CellBlock (meshio_type , connectivity [indices ]))
101101
102102 # Store cell data for this set of cells
103103 for name , d in cell_data_raw .items ():
@@ -668,9 +668,10 @@ def write(filename, mesh, binary=True, compression="zlib", header_type=None):
668668 # in certain places.
669669 is_polyhedron_grid = False
670670 for c in mesh .cells :
671- if c .type [: 10 ] == "polyhedron" :
671+ if c .type . startswith ( "polyhedron" ) :
672672 is_polyhedron_grid = True
673673 break
674+
674675 # The current implementation cannot mix polyhedral cells with other cell types.
675676 # To write such meshes, represent all cells as polyhedra.
676677 if is_polyhedron_grid :
@@ -908,31 +909,9 @@ def _polyhedron_face_cells(face_cells):
908909
909910 # types
910911 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" ):
936915 # Get face-cell relation on the vtu format. See comments in helper
937916 # function for more information of how to specify this.
938917 faces_loc , faceoffsets_loc = _polyhedron_face_cells (v )
@@ -944,8 +923,9 @@ def _polyhedron_face_cells(face_cells):
944923 assert faces is not None
945924 faces += faces_loc
946925 faceoffsets += faceoffsets_loc
926+ key = "polyhedron"
947927
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 ]))
949929
950930 types = np .concatenate (
951931 types_array
0 commit comments