How to read and visualize MESH file using PyVista
I have created a Cartesian grid model using Mesh Maker which is given the attached MESH file. How to read MESH file and visualize the grid model using PyVista?
12 replies
-
Hi Refaat G Hashish ,
Generally, given any MESH file, you can use the function `toughio.meshmaker.triangulate`. As you guess from the name, this function performs a Delaunay triangulation to reconstruct a mesh from a cloud of points (here, the X, Y, Z coordinates of the elements in the MESH file), so it not the actual mesh generated by MESHMAKER.
import toughio parameters = toughio.read_input("MESH") points = [v["center"] for v in parameters["elements"].values()] mesh = toughio.meshmaker.triangulate(points) mesh.plot(show_edges=True)
Otherwise, you can also use the function `toughio.meshmaker.from_meshmaker` to generate a mesh from your TOUGH input file that you used to generate your mesh with MESHMAKER (a file that contains a MESHMAKER block).
mesh = toughio.meshmaker.from_meshmaker("INFILE") mesh.plot(show_edges=True)
Alternatively, why not simply use the function `toughio.meshmaker.structured_grid` or `toughio.meshmaker.cylindric_grid` to generate your mesh (and MESH file via the method `mesh.write_tough`)?
import numpy as np dx = np.arange(5) dy = np.arange(6) dz = np.arange(7) mesh = toughio.meshmaker.structured_grid(dx, dy, dz) mesh.write_tough() mesh.plot(show_edges=True)