def explore_mesh(mesh, name): print("Nb vertices:", mesh.nb_vertices) print("Nb cells:", mesh.nb_cells) print("Nb faces:", mesh.nb_faces) print("Vertices") print_collection(mesh.vertices) print("Cell nodes") print_collection(mesh.connectivity.cells.nodes) print("Cell face") print_collection(mesh.connectivity.cells.faces) print("Face nodes") print_collection(mesh.connectivity.faces.nodes) print("Boundary faces:", mesh.boundary_faces()) fcenters = MT.as_coordinate_array(mesh.face_centers()) print("All face centers: (with shape", fcenters.shape, ")") print(fcenters) ccenters = MT.as_coordinate_array(mesh.cell_centers()) print("All cell centers: (with shape", ccenters.shape, ")") print(ccenters) vertices = MT.as_coordinate_array(mesh.vertices) cellnodes = np.array( [np.array(cell) for cell in mesh.connectivity.cells.nodes]) print(cellnodes) vtkw.write_vtu(vtkw.vtu_doc(vertices, cellnodes), name + ".vtu") vtkw.write_vtu( vtkw.vtu_doc(fcenters, np.reshape(np.arange(fcenters.shape[0]), (-1, 1))), name + "_face_centers.vtu", )
def build_and_dump(name, hexaedra): print("-" * 80) print("processing", name) pil = dummy_grids.pilars(hexaedra) grid = PetrelGrid.build_from_arrays(pil[..., :3], pil[..., 3:], hexaedra[..., 2]) print("pilars shape", pil.shape) print("zcorn shape", hexaedra[..., 2].shape) hexa, vertices, cell_faces, face_nodes = grid.process() print("minimum distance", dummy_grids.minimum_distance(vertices)) to_vtu(HexMesh.make(dummy_grids.depth_to_elevation(vertices), hexa), name) mesh = RawMesh(vertices=vertices, face_nodes=face_nodes, cell_faces=cell_faces) print( f"Original {name} mesh with: {mesh.nb_vertices} vertices, {mesh.nb_cells} hexaedra, {mesh.nb_faces} faces" ) vertices, cell_faces, face_nodes = grid.process_faults(hexa) vtkw.write_vtu( vtkw.polyhedra_vtu_doc(vertices, [[face_nodes[face] for face in cell] for cell in cell_faces]), f"{name}_polyhedra", ) mesh = RawMesh(vertices=vertices, face_nodes=face_nodes, cell_faces=cell_faces) raw_mesh, original_cell = mesh.as_hybrid_mesh() print( f"Splitted {name} mesh with: {raw_mesh.nb_vertices} vertices, {raw_mesh.nb_cells} cells, {raw_mesh.nb_faces} faces" ) to_vtu(raw_mesh, f"{name}_splitted", celldata={"original_cell": original_cell})
def set_dirichlet_nodes(): vertices = ComPASS.global_vertices() boundary = ComPASS.get_global_boundary_vertices() vtkw.write_vtu( vtkw.points_as_vtu_doc( vertices, pointdata={"boundary": np.array(boundary, dtype=np.int)}, ), ComPASS.to_output_directory("boundary_vertices"), ) return ComPASS.get_global_boundary_vertices()
def test_write_composite(): vtkw.write_vtu(vtkw.polyhedra_vtu_doc(vertices, [diamond_faces]), "diamond") vtkw.write_vtu(vtkw.polyhedra_vtu_doc(vertices, [tet_faces]), "tet") vtkw.write_vtm(vtkw.vtm_doc(["diamond.vtu", "tet.vtu"]), "composite") vtkw.write_vtm( vtkw.vtm_doc({ "copy1": ["diamond.vtu", "tet.vtu"], "copy2": ["diamond.vtu", "tet.vtu"], }), "composite_with_duplicates", )
def dump_model(model, filename): mesh_arrays = [S.as_arrays() for S in model.surfaces()] nodes_offset = np.cumsum([0,] + [a[0].shape[0] for a in mesh_arrays]) faces_offset = np.cumsum([0,] + [a[1].shape[0] for a in mesh_arrays]) all_vertices = np.vstack([a[0] for a in mesh_arrays]) all_faces = np.vstack( [a[1] + offset for a, offset in zip(mesh_arrays, nodes_offset[:-1])] ) fault_id = np.zeros(all_faces.shape[0]) for fi, t in enumerate(zip(faces_offset[:-1], faces_offset[1:])): fault_id[t[0] : t[1]] = fi vtkw.write_vtu( vtkw.vtu_doc(all_vertices, all_faces, celldata={"id": fault_id}), filename )
def test_distribution(): nx, ny, nz = 4, 4, 1 nbparts = 4 mesh = MT.HexMesh.make(*GT.grid2hexs(shape=(nx, ny, nz))) cell_color = np.zeros(mesh.nb_cells, dtype="i") for i in range(1, nbparts): cell_color[i * (mesh.nb_cells // nbparts):] += 1 distribution = mesh.distribute(cell_color) node_color = np.empty(mesh.nb_vertices, dtype="i") face_color = np.empty(mesh.nb_faces, dtype="i") for proc, dist in enumerate(distribution): cells, nodes, faces = [v.array_view() for v in dist[0]] ghost_cells_index, ghost_nodes_index, ghost_faces_index = dist[1] node_color[nodes[:ghost_nodes_index]] = proc face_color[faces[:ghost_faces_index]] = proc offsets, cellsnodes = mesh.cells_nodes_as_COC() vtkw.write_vtu( vtkw.vtu_doc_from_COC( mesh.vertices_array(), np.array(offsets[1:], copy=False), # no first zero offset for wtk np.array(cellsnodes, copy=False), mesh.cells_vtk_ids(), pointdata={"color": node_color}, celldata={"color": cell_color}, ), "distribution.vtu", ) offsets, facesnodes = mesh.faces_nodes_as_COC() vtkw.write_vtu( vtkw.vtu_doc_from_COC( mesh.vertices_array(), np.array(offsets[1:], copy=False), # no first zero offset for wtk np.array(facesnodes, copy=False), mesh.faces_vtk_ids(), pointdata={"color": node_color}, celldata={"color": face_color}, ), "distribution_faces.vtu", )
def test_hexmesh(): vertices, cells = GT.grid2hexs(shape=(3, 2, 4)) cells = np.ascontiguousarray(cells, dtype=MT.idtype()) mesh = MT.HexMesh.make(vertices, cells) vertices = MT.as_coordinate_array(mesh.vertices) cellnodes = np.array( [np.array(nodes) for nodes in mesh.connectivity.cells.nodes]) vtkw.write_vtu(vtkw.vtu_doc(vertices, cellnodes), "hexs.vtu") try: import meshio meshio.read("hexs.vtu") except ModuleNotFoundError: pass
def write_vtu_mesh(simulation, filename, pointdata, celldata, ofmt): nb_own_cells = simulation.number_of_own_cells() vertices, offsets, cellnodes, celltypes = mesh_description( simulation, nb_own_cells) assert all([a.shape[0] == vertices.shape[0] for a in pointdata.values()]) assert all([a.shape[0] >= nb_own_cells for a in celldata.values()]) celldata = {name: a[:nb_own_cells] for name, a in celldata.items()} vtkw.write_vtu( vtkw.vtu_doc_from_COC( vertices, offsets, cellnodes, celltypes, pointdata=pointdata, celldata=celldata, ofmt=ofmt, ), filename, ) return vertices.dtype
def test_hexaedron(): Point = MT.Point Hexa = MT.Hexahedron pts = [ Point((0.0, 0.0, 0.0)), Point((1.0, 0.0, 0.0)), Point((1.0, 1.0, 0.0)), Point((0.0, 1.0, 0.0)), Point((0.0, 0.0, 1.0)), Point((1.0, 0.0, 1.0)), Point((1.0, 1.0, 1.0)), Point((0.0, 1.0, 1.0)), ] hexas = [ Hexa((0, 1, 2, 3, 4, 5, 6, 7)), ] mesh = MT.HybridMesh.Mesh() vertices = mesh.vertices for P in pts: vertices.append(P) cellnodes = mesh.connectivity.cells.nodes for elt in hexas: cellnodes.append(elt) mesh.connectivity.update_from_cellnodes() offsets, cellsnodes = mesh.cells_nodes_as_COC() vtkw.write_vtu( vtkw.vtu_doc_from_COC( mesh.vertices_array(), np.array(offsets[1:], copy=False), # no first zero offset for vtk np.array(cellsnodes, copy=False), mesh.cells_vtk_ids(), ), "hexa.vtu", )
def dump_mesh(basename, vertices, cells, pointdata, facedata, celldata, fractures=None): assert all(np.asarray(a).shape == (vertices.shape[0],) for a in pointdata.values()) assert all(np.asarray(a).shape == (cells.shape[0],) for a in celldata.values()) vtkw.write_vtu( vtkw.vtu_doc( vertices, cells, pointdata=pointdata, celldata=celldata, ofmt="ascii" ), "mesh" + basename, ) if facedata: assert "facecenters" in facedata face_centers = facedata["facecenters"] assert all( np.asarray(a).shape == (face_centers.shape[0],) for key, a in facedata.items() if key is not "facecenters" ) vtkw.write_vtu( vtkw.points_as_vtu_doc( face_centers, pointdata={ name: value for name, value in facedata.items() if name != "facecenters" }, ), "facedata" + basename + ".vtu", ) if fractures is not None: vtkw.write_vtu( vtkw.vtu_doc(vertices, fractures), "frac_mesh" + basename + ".vtu", )
# mesh = MT.TSurf.make(*boundary.as_arrays()) # MT.to_vtu(mesh, "boundary%02d.vtu" % bi) PlaneDefinition = namedtuple("PlaneDefinition", ["origin", "normal"]) plane_definitions = [ PlaneDefinition(Point(*Oi), Vector(*ni)) for Oi, ni in zip(origins, normals) ] planes = [Plane(*definition) for definition in plane_definitions] # select subset of planes n = 20 planes = planes[:n] # output normals as vtu vtkw.write_vtu( vtkw.points_as_vtu_doc(origins[:n], pointdata={"normals": normals[:n]},), "normals.vtu", ) surfaces = [hull.intersect(plane) for plane in planes] print("simplify original surfaces") for S in surfaces: S.mark_all_vertices_as_corners() S.simplify_connected_components() print("dump original surfaces") for k, S in enumerate(surfaces): mesh = MT.TSurf.make(*S.as_arrays()) MT.to_vtu(
def create_and_distribute_mesh(mesh_constructor, constructor_arguments, coloring_algorithm): # retrieve mesh class from underlying MeshTools module mesh_module_name = mesh_constructor.__module__.split(".")[-1] assert hasattr(MT, mesh_module_name) start = datetime.datetime.now() if rank == 0: global_mesh = mesh_constructor(*constructor_arguments) print("coloring after", (datetime.datetime.now() - start).total_seconds()) cell_color = coloring_algorithm(global_mesh) print("distributing after", (datetime.datetime.now() - start).total_seconds()) distribution = global_mesh.distribute(cell_color) node_color = np.empty(global_mesh.nb_vertices, dtype="i") face_color = np.empty(global_mesh.nb_faces, dtype="i") face_location = [] # we make a first loop to locate faces with relatively to cell for proc, dist in enumerate(distribution): cells, nodes, faces = [v.array_view() for v in dist[0]] # ghost_cells_index, ghost_nodes_index, ghost_faces_index = dist[1] # node_color[nodes[:ghost_nodes_index]] = proc # face_color[faces[:ghost_faces_index]] = proc face_location.append( global_mesh.locate_faces_with_cell(cells, faces)) vertices = global_mesh.vertices_array() cellnodes = global_mesh.connectivity.cells.nodes.raw_array() print( "starting distribution after", (datetime.datetime.now() - start).total_seconds(), ) nbparts = len(distribution) assert nbparts == comm.size for proc in range(1, nbparts): cells, nodes, faces = [ v.array_view() for v in distribution[proc][0] ] # ?? send owns or deduce owns from color ? comm.send( (cells.shape[0], nodes.shape[0], faces.shape[0], cellnodes.shape[1]), dest=proc, tag=11, ) comm.send(distribution[proc][1], dest=proc, tag=111) # send global ids -> assert cells.dtype == MT.idtype() comm.Send([cells, mpi_id_type], dest=proc, tag=12) assert nodes.dtype == MT.idtype() comm.Send([nodes, mpi_id_type], dest=proc, tag=13) assert faces.dtype == MT.idtype() comm.Send([faces, mpi_id_type], dest=proc, tag=14) # send part elements -> assert vertices.dtype == np.double comm.Send([vertices[nodes], np2mpi(np.double)], dest=proc, tag=15) comm.Send([cellnodes[cells], MPI.BYTE], dest=proc, tag=16) face_cell, face_position = face_location[proc] assert face_cell.dtype == MT.idtype() comm.Send([face_cell, mpi_id_type], dest=proc, tag=17) assert face_position.dtype == np.uint8 comm.Send([face_position, np2mpi(np.uint8)], dest=proc, tag=18) # part that stays on master proc cells_gid, nodes_gid, unsorted_faces_gid = [ v.array_view() for v in distribution[0][0] ] ghost_indexes = distribution[0][1] vertices = np.copy(vertices[nodes_gid]) cellnodes = cellnodes[cells_gid] face_cell, face_position = face_location[0] else: nbcells, nbnodes, nbfaces, raw_cell_size = comm.recv(source=0, tag=11) ghost_indexes = comm.recv(source=0, tag=111) # -> receive global ids cells_gid = np.empty((nbcells, ), dtype=MT.idtype()) comm.Recv([cells_gid, mpi_id_type], source=0, tag=12) nodes_gid = np.empty((nbnodes, ), dtype=MT.idtype()) comm.Recv([nodes_gid, mpi_id_type], source=0, tag=13) unsorted_faces_gid = np.empty((nbfaces, ), dtype=MT.idtype()) comm.Recv([unsorted_faces_gid, mpi_id_type], source=0, tag=14) # -> receive part elements vertices = np.empty((nbnodes, 3), dtype=np.double) comm.Recv([vertices, np2mpi(np.double)], source=0, tag=15) # print('proc', comm.rank, ':', vertices.min(axis=0), vertices.max(axis=0)) cellnodes = np.empty((nbcells, raw_cell_size), dtype=np.byte) comm.Recv([cellnodes, MPI.BYTE], source=0, tag=16) face_cell = np.empty((nbfaces, ), dtype=MT.idtype()) comm.Recv([face_cell, mpi_id_type], source=0, tag=17) face_position = np.empty((nbfaces, ), dtype=np.uint8) comm.Recv([face_position, np2mpi(np.uint8)], source=0, tag=18) # Rebuild local meshes print( "rebuilding on", rank, "after", (datetime.datetime.now() - start).total_seconds(), ) Mesh = getattr(MT, mesh_module_name) mesh = Mesh.create_from_remap(vertices, cellnodes, nodes_gid) # CHECKME: invert cell_gid, would this be faster in C++? gid2lid = {cells_gid[k]: k for k in range(cells_gid.shape[0])} local_face_cell = np.array([gid2lid[gci] for gci in face_cell], dtype=MT.idtype()) faces_gid_order = mesh.identify_faces_from_positions( local_face_cell, face_position) faces_gid = unsorted_faces_gid[faces_gid_order] sys.stdout.flush() comm.Barrier() print( "total processing time on", rank, ":", (datetime.datetime.now() - start).total_seconds(), ) offsets, cellsnodes = mesh.cells_nodes_as_COC() ghost_tag = np.zeros(mesh.nb_cells, dtype="i") ghost_tag[ghost_indexes[0]:] = 1 vtkw.write_vtu( vtkw.vtu_doc_from_COC( mesh.vertices_array(), np.array(offsets[1:], copy=False), # no first zero offset for vtk np.array(cellsnodes, copy=False), mesh.cells_vtk_ids(), celldata={"ghost": ghost_tag}, ), "localmesh-%03d.vtu" % rank, ) return mesh
def retrieve(filename, dtype): return np.loadtxt(os.path.join(dirname, filename), dtype=dtype) vertices = retrieve("vertices", np.double) cells = retrieve("cells", MT.idtype()) faces = retrieve("faces", MT.idtype()) fault_faces = retrieve("faces_fault", MT.idtype()) fault_faces_nodes = faces[fault_faces] mesh = MT.tetmesh(vertices, cells) fault_faces_id = mesh.faces_ids(fault_faces_nodes) vtkw.write_vtu(vtkw.vtu_doc(vertices, cells), os.path.join(dirname, "mesh.vtu")) ffcenters = mesh.face_centers(fault_faces_id) vtkw.write_vtu( vtkw.vtu_doc(ffcenters, np.reshape(np.arange(ffcenters.shape[0]), (-1, 1))), os.path.join(dirname, "fault_faces_centers.vtu"), ) fcenters = mesh.face_centers(mesh.faces_ids(faces)) patches = retrieve("patches", np.int) assert fcenters.shape[0] == patches.shape[0] vtkw.write_vtu( vtkw.vtu_doc( fcenters,
def rescale_into_unit_box(pts): return pts * np.array([1 / (nx - 1), 1 / (ny - 1), 1 / (nz - 1)]) as_tsurf = lambda t: MT.TSurf.make(t[0], MT.idarray(t[1])) verts, faces, normals, values = isocontour verts = rescale_into_unit_box(verts) MT.to_vtu( as_tsurf((verts, faces)), "%s_eggs.vtu" % (os.path.splitext(__file__)[0]), ) tsurf = CGAL.TSurf(verts, faces) offseted_tsurf = CGAL.TSurf(verts + np.array([0.3, 0.2, 0.1]), faces) # clip surface fc = offseted_tsurf.face_centers() # line: x + y - 1 = 0 offseted_tsurf.remove_faces(fc[:, 0] + fc[:, 1] - 1 < 0) verts, faces = offseted_tsurf.as_arrays() MT.to_vtu( as_tsurf((verts, faces)), "%s_offseted_eggs.vtu" % (os.path.splitext(__file__)[0]), ) polylines = CGAL.intersection_curves(tsurf, offseted_tsurf) for pi, polyline in enumerate(polylines): vtkw.write_vtu(vtkw.polyline_as_vtu(np.array(polyline)), "polyline_%03d" % pi)
def _dump_wells(simulation, well_type, outputdir=None, tag=None, verbose=False): if outputdir is None: outputdir = Path(".") else: outputdir = Path(outputdir) assert outputdir.exists() and outputdir.is_dir() info = _wells_info(simulation, well_type) if not _any_wells(info): return wells = info.information nb_own_wells = _check_own_wells(wells, info) if verbose: print(f"Dumping {info.nb_own} {info.type} wells out of {info.nb}.") wells_data = [data for data, _ in zip(info.data, range(nb_own_wells))] vertices = simulation.vertices() node_states = simulation.node_states() if len(set([data.id for data in wells_data])) != nb_own_wells: print("!!!") print( "!!! WARNING: you must use unique well id to discriminate output files" ) print("!!!") for wk, well in enumerate(wells): if wk >= nb_own_wells: break # We want to keep only well vertices not all revervoir vertices well_vertices = well.vertices assert well_vertices.shape == np.unique(well_vertices).shape remap = np.zeros(vertices.shape[0], dtype=well_vertices.dtype) remap[well_vertices] = 1 remap = np.cumsum(remap) - 1 # FIXME: well.pressure has no real meaning for multiple phases (reference pressure ?) welldata = { name: np.ascontiguousarray(a) for name, a in [ ("reservoir vertices id", well_vertices), ("well pressure", well.pressure), ("well temperature", K2degC(well.temperature)), ("well pressure drop", well.pressure_drop), ("well density", well.density), ("Darcy WI", well.well_index_Darcy), ("Fourier WI", well.well_index_Fourier), ("reservoir pressure", node_states.p[well_vertices]), ("reservoir temperature", K2degC(node_states.T[well_vertices])), ( "inflow", np.where( well.pressure < node_states.p[well_vertices], well.well_index_Darcy * (node_states.p[well_vertices] - well.pressure), 0, ), ), ] } try: welldata["well saturation pressure"] = np.ascontiguousarray( simulation.Psat(well.temperature)) except AttributeError: pass try: welldata["well saturation temperature"] = np.ascontiguousarray( simulation.Tsat(well.pressure)) except AttributeError: pass vtkw.write_vtu( vtkw.vtu_doc( vertices[well_vertices], np.hstack([ np.reshape(remap[well_vertices[:-1]], (-1, 1)), np.reshape(remap[well.parent_vertex], (-1, 1)), ]), pointdata=welldata, ), str(outputdir / _well_vtu_filename(wells_data[wk].id, tag)), )
def test_write_dummy_polyhedra(): vtkw.write_vtu(vtkw.polyhedra_vtu_doc(vertices, faces), "diamond_and_test")
paris["faces_nodes_top"] = arnul.faces_nodes_affl paris["faces_nodes_bot"] = arnul.faces_nodes_bot paris["cells_layers"] = arnul.cells_layers paris["cells_top"] = arnul.cells_affls paris["cells_bot"] = arnul.cells_bots with open("bassin_paris/meshs.pkl", "bw") as fichier: pickle.dump(paris, fichier) # Représentation sous vtk : for poly in paris["cells_nodes"]: mesh = MT.HybridMesh.Mesh() vertices = mesh.vertices for P in paris["vertices"]: vertices.append(MT.Point(P)) cellnodes = mesh.connectivity.cells.nodes for elt in paris["cells_nodes"][poly]: cellnodes.append(typ[poly](MT.idarray(elt))) mesh.connectivity.update_from_cellnodes() offsets, cellsnodes = mesh.cells_nodes_as_COC() vtkw.write_vtu( vtkw.vtu_doc_from_COC( mesh.vertices_array(), np.array(offsets[1:], copy=False), # no first zero offset for vtk np.array(cellsnodes, copy=False), mesh.cells_vtk_ids(), ), "{0}.vtu".format(poly), ) # python postprocess_snapshots -s output-test-bass_paris
Plane(Point(xmin - Lh, ymin, zmin), Vector(-1, 0, 0)), Plane(Point(xmax + Lh, ymin, zmin), Vector(1, 0, 0)), Plane(Point(xmin, ymin - Lh, zmin), Vector(0, -1, 0)), Plane(Point(xmin, ymax + Lh, zmin), Vector(0, 1, 0)), Plane(Point(xmin, ymin, zmin - Lv), Vector(0, 0, -1)), Plane(Point(xmin, ymin, zmax + Lv), Vector(0, 0, 1)), ] ) # n = 5 # origins = origins[:n] # normals = normals[:n] # output normals as vtu vtkw.write_vtu( vtkw.points_as_vtu_doc(origins, pointdata={"normals": normals},), "normals.vtu" ) origins = [Point(*a) for a in origins] normals = [Vector(*a) for a in normals] mesh = urg.Mesh(hull, list(zip(origins, normals))) print("built", len(list(mesh.surfaces())), "surface meshes") def dump_model(model, filename): mesh_arrays = [S.as_arrays() for S in model.surfaces()] nodes_offset = np.cumsum([0,] + [a[0].shape[0] for a in mesh_arrays]) faces_offset = np.cumsum([0,] + [a[1].shape[0] for a in mesh_arrays]) all_vertices = np.vstack([a[0] for a in mesh_arrays])
def write_mesh_vtu( self, proc, basename, own_only=True, dump_procid=False, nodedata=None, celldata=None, fracdata=None, ): assert proc < self.distribution.nb_procs nb_own_cells = self.distribution.nb_own_cells[proc] nb_own_fractures = self.distribution.nb_own_fractures[proc] if dump_procid: own_only = True assert nodedata is None and celldata is None and fracdata is None celldata = { "proc": np.array(np.tile(proc, nb_own_cells), dtype=self.proc_id_type) } if nb_own_fractures > 0: fracdata = { "proc": np.array( np.tile(proc, nb_own_fractures), dtype=self.proc_id_type ) } if nodedata is None: nodedata = {} if celldata is None: celldata = {} if fracdata is None: fracdata = {} meshfile = self.mesh_filename(proc) assert os.path.exists(meshfile) mesh = np.load(meshfile) if self.vertices_type is None: self.vertices_type = mesh["vertices"].dtype assert self.vertices_type == mesh["vertices"].dtype proc_label = self.dumper.proc_label(proc) piecefile = self.to_vtu_directory("%s_%s.vtu" % (basename, proc_label)) cell_nodes_offsets = mesh["cellnodes_offsets"] cell_nodes = mesh["cellnodes_values"] cell_types = mesh["celltypes"] if own_only: cell_nodes_offsets = cell_nodes_offsets[:nb_own_cells] cell_nodes = cell_nodes[: cell_nodes_offsets[-1]] cell_types = cell_types[:nb_own_cells] vtkw.write_vtu( vtkw.vtu_doc_from_COC( mesh["vertices"], cell_nodes_offsets, cell_nodes, cell_types, pointdata=nodedata, celldata=celldata, ), piecefile, ) if fracdata: fracdata_size = int( np.unique([a.shape[0] for a in fracdata.values()]) ) # will triger a TypeError if array sizes are not the same if fracdata_size > 0: fracpiecefile = self.to_vtu_directory( "fracture_%s_%s.vtu" % (basename, proc_label) ) cell_nodes_offsets = mesh["fracturenodes_offsets"] cell_nodes = mesh["fracturenodes_values"] cell_types = mesh["fracture_types"] if own_only: cell_nodes_offsets = cell_nodes_offsets[:nb_own_fractures] cell_nodes = cell_nodes[: cell_nodes_offsets[-1]] cell_types = cell_types[:nb_own_fractures] vtkw.write_vtu( vtkw.vtu_doc_from_COC( mesh["vertices"], cell_nodes_offsets, cell_nodes, cell_types, celldata=fracdata, ), fracpiecefile, ) return piecefile, fracpiecefile return piecefile, None