Creating quad mesh using RectangleMesh

Hi everyone,

Is there a way to create a quadrilateral mesh similar to UnitSquareMesh.create(nx,ny,CellType.Type.Quadrilateral) on a rectangular domain (with diagonal points p0 and p1)?

Something like RectangleMesh.create(p0,p1,...) ?

RectangleMesh.create([p0,p1],[nx,ny],CellType.Type.quadrilateral) seems to work.

do you know how to output/input a quad mesh?

I don’t think importing external quad meshes is supported in dolfin as yet. It was not till dolfin-2018.1.0 at least. I haven’t checked 2019 but most probably it is not

There is a workaround to import external quad mesh (like GMSH) into FEniCS. For example you can check this out.

1 Like

@Leo does this work, for instance, for unstructured quad meshes ? I believe the Mesh function only works for layered (structured) quads, right ?

It works for any type of quad mesh. It does not matter if it is structured or not.

1 Like

That is good to know. Will try this out.

It seems to me that the code that you posted is not completely working with 2019.1.0, and when I looked through the link it seems that you were able to work through it in 2017.2. With some changes to the code, which basically amount to addressing a couple of formatting issues, it at least adds the vertices and cells correctly but fails with an ordering issue, which again is weird because it was apparently resolved as reported here

Here is a MWE that works in 2019.1.0

  • For simplicity assume that v is an object with v.point being the node coordinate(s)
msh = Mesh() 
editr = MeshEditor()
editr.open(msh,'quadrilateral',2,2) 
editr.init_vertices(num_points)
editr.init_cells(num_cells)


for i,v in enumerate(nodes):
    editr.add_vertex(i,[*v.point])

for j,e in enumerate(verts_mio):
    # list_of_nodes = [int(i) for i in np.array(e.points,int)]
    print(e.astype(np.uintp))
    editr.add_cell(j,e.astype(np.uintp))

editr.close()

with XDMFFile(comm,'trial.xdmf') as f:
    f.write(msh)

however fails with the exception

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

You are right. The method I proposed works only in 2017 versions. version. It seems that quad mesh ordering issue still exists in 2019 versions.

But the corresponding issue is marked as resolved on bitbucket. I’ll look through this if there is an issue with my test mesh speifically. But if you were able to work through it in 2017.2 it should, in principle, work in 2019.1.0 too.

It also looks weird to me why it is marked as resolve. I have never used 2019 version but I am sure it works fine in 2017.

Hi,

I had a quad mesh generated using Tetgen and I wanted to load that in Fenics. Thus, I wrote a small C++ program that can read the Tetgen output files and can write a XML file compatible with Fenics. It works fine for me.

What version of dolfin are you using ? Also, I have used meshio-convert to interoperate between the .xdmf and .inp formats, which works seamlessly for 3D and simplical meshes.

After browsing the argument list for MeshEditor.close(), and passing order = False, I am able to read the mesh for the most part, except for one element. See here