Hello,
I am trying to generate a quadratic mesh in .msh format and convert it to .xdmf format.
On Gmsh, I used my .geo file which worked fine for the first order, but on the gmsh GUI I additionally clicked on “Set order 2” .
Then I also reused the code that worked fine for the linear mesh, which is the following:
msh = meshio.read("rectangle2D_order2.msh")
def create_mesh(mesh, cell_type, prune_z=False):
cells = mesh.get_cells_type(cell_type)
cell_data = mesh.get_cell_data("gmsh:physical", cell_type)
points = mesh.points[:,:2] if prune_z else mesh.points
out_mesh = meshio.Mesh(points=points, cells={cell_type: cells}, cell_data={"name_to_read":[cell_data]})
return out_mesh
line_mesh = create_mesh(msh, "line", prune_z=True)
meshio.write("rectangle2D_order2_facet_mesh.xdmf", line_mesh)
triangle_mesh = create_mesh(msh, "triangle", prune_z=True)
meshio.write("rectangle2D_order2_mesh.xdmf", triangle_mesh)
However, I get the following error:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/tmp/ipykernel_25068/3165531181.py in <module>
1 # Convert mesh to XDMF
----> 2 line_mesh = create_mesh(msh, "line", prune_z=True)
3 meshio.write("rectangle2D_order2_facet_mesh.xdmf", line_mesh)
4
5 triangle_mesh = create_mesh(msh, "triangle", prune_z=True)
/tmp/ipykernel_25068/1200146592.py in create_mesh(mesh, cell_type, prune_z)
1 # Helper function to extract the cells and physical data
2 def create_mesh(mesh, cell_type, prune_z=False):
----> 3 cells = mesh.get_cells_type(cell_type)
4 cell_data = mesh.get_cell_data("gmsh:physical", cell_type)
5 points = mesh.points[:,:2] if prune_z else mesh.points
~/anaconda3/lib/python3.8/site-packages/meshio/_mesh.py in get_cells_type(self, cell_type)
122
123 def get_cells_type(self, cell_type):
--> 124 return numpy.concatenate([c.data for c in self.cells if c.type == cell_type])
125
126 def get_cell_data(self, name, cell_type):
<__array_function__ internals> in concatenate(*args, **kwargs)
ValueError: need at least one array to concatenate
I am having trouble understanding why this is generating an error, do you have any suggestions on how to solve the problem?
Thank you very much for your help !