Creating a unstructured triangular mesh or rectangular shape

Hello everyone,

I’ve been looking for a way of creating an unstructured triangular mesh of rectangular shape, but the following function creates a structured one:

mesh = RectangleMesh(Point(0., 0.),Point(N, N), N, N, "right")

however, I’m able to create an unstructured triangular one with circular shape using:

domain = Circle(dolfin.Point(0, 0), N)
mesh = generate_mesh(domain,N,10)

is there a way of combining both functionalities to create an unstructured triangular mesh of rectangular shape?

thanks in advance

It is quite straightforward. The built in mesh is structured, but if you use mshr to generate the mesh, it becomes unstructured. See minimal example below.

from dolfin import *
from mshr import *

domain = Rectangle(Point(0,0), Point(2,2))
mesh = generate_mesh(domain, 10)
File("mesh.pvd") << mesh
1 Like

Thank you. Is it also possible to create an unstructured quad mesh with mshr?

No, In dolfin, in general there is very little support for quadrilaterals cells. In dolfinx you can use quadrilateral elements, with built in meshes, or unstructured meshes creates with for instance gmsh.