I'm trying to generate a triangular mesh with gmsh and then read it with python, for the python part I'm using meshio. But my problem is that the mesh elements are always readead as lines, not triangles.
Here is my .geo
SetFactory("OpenCASCADE");
Circle(1) = {0, 0, 0, 1, 0, 2*Pi};
Curve Loop(1) = {1};
Plane Surface(1) = {1};
Physical Curve("circle", 2) = {1};
then I run:
gmsh -2 circle.geo
and get this mesh:
With this python code I read the mesh:
ELEMENT_TYPES = {
"line": 2,
"line3": 3,
"triangle": 3,
"quadrangle": 4,
"tetrahedron": 4,
"hexahedron": 8,
"prism": 6,
"pyramid": 5,
}
def read(self, mesh_file: str):
msh = meshio.read(mesh_file)
points = msh.points
number_of_nodes = points.shape[0]
point_index = range(number_of_nodes)
mesh_nodes = dict(zip(point_index, points))
elements = []
for cell in msh.cells:
cell_type = cell.type
for idx, element_nodes in enumerate(cell.data, 1):
element_nodes_coordinates = np.array([mesh_nodes[node] for node in element_nodes])
element = Element(
index=idx,
type=cell_type,
size=ELEMENT_TYPES[cell_type],
nodes=element_nodes,
nodes_coordinates=element_nodes_coordinates,
)
elements.append(element)
But I always get a mesh type of line (2 node element), I need a 3 node triangular mesh.