Controling the refinement of an element

Dear Fenics community.

In the context of adaptive refinement, one of the most used command in Fenics is refine. When marked elements (triangles in my case) are given to this function, they are splitted in four new triangles. I wonder if it will be possible to somehow control the refinement of the refine function such that the subdivision of the elements is in 2 triangles instead of 4?. Is there another tool to refine marked elements that can communicate with Fenics?

from dolfin import*
import matplotlib.pyplot as plt
N = 2
mesh = UnitSquareMesh(N, N, 'left')
refined_mesh=refine(mesh)
plt.figure()
plt.plot(mesh)
plt.figure()
plt.plot(refined_mesh)

The initial mesh
Captura de pantalla de 2021-04-27 13-15-31

The refined mesh after running refine(mesh)
Captura de pantalla de 2021-04-27 13-16-07

Thanks in advance!

In legacy (old) dolfin, there’s a parameter:

parameters["refinement_algorithm"]

which has the options

[plaza,plaza_with_parent_facets,regular_cut]

You can read the source to find out exactly what these do. But I believe the most popular is plaza refinement with parent facets since it preserves parent-child information between refinement levels.

Two reasons for bisecting into 4 rather than 2 simplices:

  1. Old dolfin doesn’t support non-conforming meshes, you cannot have hanging nodes.
  2. Following the previous point, it’s important to preserve mesh quality. This is extremely difficult if you restrict yourself to bisection of triangles only.