Parse mesh from elements and points file
Full example code: examples/parser/opencarp_mesh.py
The mesh of an OpenCARP simulation consists of vertices and a list of elements to connect these vertices. For a surface mesh, these elements often consist of triangles. The .pts file contains the index and coordinates of all the vertices (points). The .elem file contains a list of elements, connecting vertices using their points id.
from dgmr.parser import OpencarpReader
pts_file = "path_to_your_points_file"
elem_file = "path_to_your_elements_file"
vertices, elements = OpencarpReader.load_mesh(pts_file, elem_file)
print(vertices[:5])
print(elements[:5])
Output: pandas DataFrame for both vertices and elements.