Meeting issue when load mesh created by gmsh

I want to create and load a mesh using gmsh to dolfinx mesh. However, I meet an unexpected crush. Here is my code:

import gmsh
# Define the geometry

LX = 1.1
LY = 1.1
nx = 11
ny = 11
# Initialize GMSH
gmsh.initialize()

# Create a new model
gmsh.model.add("mixed_mesh")
gmsh.option.setNumber("General.Terminal", 1)

#a0 = gmsh.model.geo.addPoint(0, LY, 0)
a1 = gmsh.model.geo.addPoint(0, LY-LY/ny, 0)
a2 = gmsh.model.geo.addPoint(LX/nx, LY-LY/ny, 0)
#a3 = gmsh.model.geo.addPoint(LX/nx, LY, 0)

#b0 = gmsh.model.geo.addPoint(0, 0, 0)
b1 = gmsh.model.geo.addPoint(LX/nx,0, 0)
b2 = gmsh.model.geo.addPoint(LX/nx, LY/ny, 0)
b3 = gmsh.model.geo.addPoint(0, LY/ny, 0)


# F
f = gmsh.model.geo.addPoint(LX/nx/2, LY/2, 0)
f0 = gmsh.model.geo.addPoint(0, LY/2+LY/ny/2, 0)
f1 = gmsh.model.geo.addPoint(0, LY/2-LY/ny/2, 0)
f2 = gmsh.model.geo.addPoint(LX/nx, LY/2-LY/ny/2, 0)
f3 = gmsh.model.geo.addPoint(LX/nx, LY/2+LY/ny/2, 0)
# Create lines
S1_l0 = gmsh.model.geo.addLine(a1, f0)
S1_l1 = gmsh.model.geo.addLine(f0, f3) # S10
S1_l2 = gmsh.model.geo.addLine(f3, a2)
S1_l3 = gmsh.model.geo.addLine(a2, a1)


S2_l1 = gmsh.model.geo.addLine(f0, f)
S2_l2 = gmsh.model.geo.addLine(f, f3)
S2_l3 = gmsh.model.geo.addLine(f3, f0)

S3_l1 = gmsh.model.geo.addLine(f, f1)
S3_l2 = gmsh.model.geo.addLine(f1, f2)
S3_l3 = gmsh.model.geo.addLine(f2, f)

S4_l1 = gmsh.model.geo.addLine(f1, b3)
S4_l2 = gmsh.model.geo.addLine(b3, b2)
S4_l3 = gmsh.model.geo.addLine(b2, f2)
S4_l4 = gmsh.model.geo.addLine(f2, f1)



# Create a line loop
S1_loop = gmsh.model.geo.addCurveLoop([S1_l0, S1_l1, S1_l2, S1_l3])
S2_loop = gmsh.model.geo.addCurveLoop([S2_l1, S2_l2, S2_l3])
S3_loop = gmsh.model.geo.addCurveLoop([S3_l1, S3_l2, S3_l3])
S4_loop = gmsh.model.geo.addCurveLoop([S4_l1, S4_l2, S4_l3, S4_l4])



# Create a plane surface
S1 = gmsh.model.geo.addPlaneSurface([S1_loop])
S2 = gmsh.model.geo.addPlaneSurface([S2_loop])
S3 = gmsh.model.geo.addPlaneSurface([S3_loop])
S4 = gmsh.model.geo.addPlaneSurface([S4_loop])

gmsh.model.addPhysicalGroup(2, [S1], 1)
gmsh.model.addPhysicalGroup(2, [S2], 2)
gmsh.model.addPhysicalGroup(2, [S3], 3)
gmsh.model.addPhysicalGroup(2, [S4], 4)



# Divide 4 parts
for i in [S1_l0,S1_l2,S4_l1,S4_l3]:
     gmsh.model.geo.mesh.setTransfiniteCurve(i, 5)   


gmsh.model.geo.mesh.setTransfiniteSurface(S1, "Left",[])
gmsh.model.geo.mesh.setTransfiniteSurface(S4, "Left",[])
gmsh.model.geo.mesh.setRecombine(2,S1) # If comment this, everything went well
gmsh.model.geo.mesh.setRecombine(2,S4) # If comment this, everything went well

# Synchronize the model with GMSH
# Generate the 2D mesh

gmsh.model.geo.synchronize()
gmsh.model.mesh.generate(2)
#gmsh.option.setNumber("Mesh.SaveAll", 1)
gmsh.fltk.run()

from dolfinx.io import gmshio
from mpi4py import MPI
mesh, cell_tags, facet_tags = gmshio.model_to_mesh(gmsh.model, MPI.COMM_WORLD, 0)

And the error is:

Invalid rank, error stack:
internal_Issend(61644): MPI_Issend(buf=0x17ff6d001, count=1, MPI_BYTE, 1, 1, comm=0x84000005, request=0x17ff106a4) failed
internal_Issend(61605): Invalid rank has value 1 but must be nonnegative and less than 1
Abort(866780422) on node 0 (rank 0 in comm 416): application called MPI_Abort(comm=0x84000005, 866780422) - process 0

My fenicsx version is 0.9 and the system is MocOS.

I found that everything works fine if I don’t use quadrilateral meshes. I am a beginner in FEniCSx and don’t know how to handle this issue. I hope someone can provide a solution.

This command is in general not adviced. This can result in duplicate points, facets and cells being stored in the mesh file. Could you turn it off?

Thanks for your reply. This was off already. It still can’t work.

How are you expecting the triangular ends to be meshed with quadrilateral elements with your current code?


If you use:

gmsh.option.setNumber("Mesh.Algorithm", 8)
gmsh.option.setNumber("Mesh.RecombinationAlgorithm", 2)
gmsh.option.setNumber("Mesh.RecombineAll", 1)
gmsh.option.setNumber("Mesh.SubdivisionAlgorithm", 1)

from my tutorial
https://jsdokken.com/dolfinx-tutorial/chapter2/ns_code2.html#generating-the-mesh
you get


However, please note that cells connected by vertex only is not well-adviced, as it:

  1. Can cause singular behavior for some PDEs (such as elasticity equations).
  2. Is not supported in DOLFINx in parallel.

Could you provide some context about why you want this mesh?

It works for me. Thank you very much. Actually, I want to define a hinge between two components but haven’t found a good way to express it. Therefore, I used a single point between two elements to connect them. Since there is still elastic deformation, is there any other method to define a hinge? Regardless, thank you for your help and advice.

I would probably use an MPC:

Thanks for your advice! I will try it.