Ordering of quadrilateral meshes

Hello,

I am trying to convert a mesh with quadrilateral elements from .mesh (from SALOME) to .xdmf based on https://fenicsproject.discourse.group/t/transitioning-from-mesh-xml-to-mesh-xdmf-from-dolfin-convert-to-meshio/412/2 .

from dolfin import *
import meshio
msh = meshio.read(“mesh_quad_2d.mesh”)

meshio.write(“mesh_quad_2d.xdmf”, meshio.Mesh(points=msh.points, cells={“quad”: msh.cells[“quad”]}))
meshio.write(“mesh_function_quad_2d.xdmf”, meshio.Mesh(points=msh.points, cells={“line”: msh.cells[“line”]},
cell_data={“line”: {“name_to_read”: msh.cell_data[“line”][“medit:ref”]}}))

mesh = Mesh()
with XDMFFile(“mesh_quad_2d.xdmf”) as infile:
infile.read(mesh)
mvc = MeshValueCollection(“size_t”, mesh, 2)

with XDMFFile(“mesh_function_quad_2d.xdmf”) as infile:
infile.read(mvc, “name_to_read”)
mf = cpp.mesh.MeshFunctionSizet(mesh, mvc)
File(“dolfinmesh.pvd”).write(mesh)
File(“dolfincellfunc.pvd”).write(mf)

However, while ordering the mesh it gives an error.


*** Error: Unable to order quadrilateral cell.
*** Reason: Cell is not orderable.
*** Where: This error was encountered inside QuadrilateralCell.cpp.
*** Process: 0


*** DOLFIN version: 2019.1.0
*** Git changeset: unknown


I referred to https://bitbucket.org/fenics-project/dolfin/issues/997/quad-hex-meshes-need-ordering-check . Here, the cell order is changed manually. However, I do not know how to order the cells when meshes are generated from another program and it is not possible to order mesh manually.

In summary, I do not know how to resolve the error and get mesh with quadrilateral elements in format compatible with fenics.