I have modified code to -
msh = meshio.read("/mnt/d/Research Projects/FEM for microstructures/modified_2cmp1.msh")
def create_mesh(mesh, cell_type, prune_z=False):
cells = mesh.get_cells_type(cell_type)
points = mesh.points[:,:2] if prune_z else mesh.points
out_mesh = meshio.Mesh(points=points, cells={cell_type: cells})
return out_mesh
line_mesh = create_mesh(msh, "line", prune_z=True)
meshio.write("mf.xdmf", line_mesh)
triangle_mesh = create_mesh(msh, "triangle", prune_z=True)
meshio.write("mesh.xdmf", triangle_mesh)
mesh = Mesh()
with XDMFFile("mesh.xdmf") as infile:
infile.read(mesh)
mvc = MeshValueCollection("size_t", mesh, 1)
with XDMFFile("mf.xdmf") as infile:
infile.read(mvc, "name_to_read")
but now the following error comes:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/tmp/ipykernel_142/2838469791.py in <module>
14
15 line_mesh = create_mesh(msh, "line", prune_z=True)
---> 16 meshio.write("mf.xdmf", line_mesh)
17
18 triangle_mesh = create_mesh(msh, "triangle", prune_z=True)
~/.local/lib/python3.10/site-packages/meshio/_helpers.py in write(filename, mesh, file_format, **kwargs)
186
187 # Write
--> 188 return writer(filename, mesh, **kwargs)
~/.local/lib/python3.10/site-packages/meshio/xdmf/main.py in write(*args, **kwargs)
544
545 def write(*args, **kwargs):
--> 546 XdmfWriter(*args, **kwargs)
547
548
~/.local/lib/python3.10/site-packages/meshio/xdmf/main.py in __init__(self, filename, mesh, data_format, compression, compression_opts)
352 if data_format == "HDF":
353 self.h5_filename = self.filename.with_suffix(".h5")
--> 354 self.h5_file = h5py.File(self.h5_filename, "w")
355
356 xdmf_file = ET.Element("Xdmf", Version="3.0")
~/.local/lib/python3.10/site-packages/h5py/_hl/files.py in __init__(self, name, mode, driver, libver, userblock_size, swmr, rdcc_nslots, rdcc_nbytes, rdcc_w0, track_order, fs_strategy, fs_persist, fs_threshold, fs_page_size, page_buf_size, min_meta_keep, min_raw_keep, locking, alignment_threshold, alignment_interval, meta_block_size, **kwds)
556
557 with phil:
--> 558 fapl = make_fapl(driver, libver, rdcc_nslots, rdcc_nbytes, rdcc_w0,
559 locking, page_buf_size, min_meta_keep, min_raw_keep,
560 alignment_threshold=alignment_threshold,
~/.local/lib/python3.10/site-packages/h5py/_hl/files.py in make_fapl(driver, libver, rdcc_nslots, rdcc_nbytes, rdcc_w0, locking, page_buf_size, min_meta_keep, min_raw_keep, alignment_threshold, alignment_interval, meta_block_size, **kwds)
129 # we default to earliest
130 low, high = h5f.LIBVER_EARLIEST, h5f.LIBVER_LATEST
--> 131 plist.set_libver_bounds(low, high)
132 plist.set_alignment(alignment_threshold, alignment_interval)
133
h5py/_objects.pyx in h5py._objects.with_phil.wrapper()
h5py/_objects.pyx in h5py._objects.with_phil.wrapper()
h5py/h5p.pyx in h5py.h5p.PropFAID.set_libver_bounds()
ValueError: High bound is not valid (high bound is not valid)