Marking the boundary of a complex 3D geometry

Hi everyone!

I have the .h5 file of a complex 3d mesh with outer and inner boundaries. I can import the mesh and read the markers of these boundaries, and apply an adaptive mesh refinement by using FEniCS. Now, I’d to keep the markers of the boundary in order to apply again my adaptive refinement. However, since the information of the markers is not available anymore, I can’t perform a second refinement for a new level of the adaptive procedure. Is there a way to mark the two boundaries in the second step?

Here my code to call the mesh:

def create_mesh():
	# Read mesh
	mesh = Mesh()
	file = HDF5File(mesh.mpi_comm(), "mesh/colin27_coarse_boundaries.h5", "r")
	file.read(mesh, "/mesh", False)

	# Read white/gray markers
	D = mesh.topology().dim()

	# Read skull/ventricle markers
	boundaries = MeshFunction("size_t", mesh, D-1)
	file.read(boundaries, "/boundaries")
	file.close()

	return mesh, boundaries

mesh, boundaries = create_mesh()

Paulo

I found the solution.

Firstly, the adaptive procedure is performed as usual.

mesh = refine(mesh, cells_marked)

Then, in order to adapt the old markers to our current mesh, we need to add the following:

boundaries = adapt(boundaries,mesh)

However, the following code need to be added at the beginning of our code, as well.

parameters["refinement_algorithm"] = "plaza_with_parent_facets"

This solutions was tested with a two dimensional code, and it worked as expected. I’m now testing the 3D case, and it seems to be working fine.

I hope this could be helpful for someone.

Paulo