Get coordo and connect for a domain with an open crack without writing the mesh file
Hello Mr. Geuzaine,
Currently I have created a domain with an open crack in 2D.
For the moment I am getting the coordinate and connectivity table with the code below (using meshio).
elementTypes = gmsh.model.mesh.getElementTypes()
gmsh.write(filename)
mesh = meshio.read(filename)
points = mesh.points
cells = mesh.cells
cellsTypes = np.unique(np.array([c.type for c in cells], dtype=str))
for gmshId in elementTypes:
match GroupElem.Get_ElemInFos(gmshId)[0]:
case "SEG2":
cT = "line"
case "SEG3":
cT = "line3"
case "TRI3":
cT = "triangle"
case "TRI6":
cT = "triangle6"
case "QUAD4":
cT = "quad"
case "QUAD8":
cT = "quad8"
case "POINT":
cT = "vertex"
case _:
raise "Unknown type"
assert cT in cellsTypes, "Type not used in the mesh"
connect = mesh.get_cells_type(cT)
noeuds = np.unique(connect)
coordo = points[noeuds]
I am trying today to recover coordo and connect without writing the .msh file
I wrote this routine which works when the crack is closed.
elementTypes, elementTags, nodeTags = gmsh.model.mesh.getElements()
nodes, coord, parametricCoord = gmsh.model.mesh.getNodes()
coord = coord.reshape(-1,3)
for t, gmshId in enumerate(elementTypes):
Ne = elementTags[t].shape[0]
nPe = GroupElem.Get_ElemInFos(gmshId)[1]
connect = nodeTags[t].reshape(Ne, nPe)-1 # nPe : number of nodes per elements
nodes = np.unique(nodeTags[t]-1)
Nmax = nodes.max()
assert Nmax <= (coord.shape[0]-1), f"Nodes {Nmax} doesn't exist in coordo"
coordo = cast(np.ndarray, coord[nodes])
It seems that when I open the crack the split nodes are not added in coordo
Is there a command to use before retrieving the mesh of the above commands?
Many thanks in advance,
Matthieu