How to subtract a subdomain from a parent domain and retain the meshing?

Suppose I have a domain as below:

I want to subtract the domain tagged 8 from the whole structure but retain the mesh of the surface 8 and of the rest of the structure as well.

So what I want are these two structures:

  1. Here the mesh should be the same as above (the mesh is coarser than the above since this was created with different scripts in gmsh)

and

  1. the innermost domain with the same mesh as the original figure at the beginning.

In FEniCS, I can subtract domains before meshing and mesh them separately. But as soon as I am trying to subtract subdomains after meshing, it’s returning error.

Here is a rough idea what I tried in FEniCS to do this:

  1. I extracted the the innermost submesh and named it mesh1.
  2. The whole mesh is named mesh
  3. mesh2 = mesh - mesh1

This is returning the error that ‘-’ operation is not supported.

Is there a way to do this? Also, please let me know if you have any questions.

You cannot subtract a mesh from another mesh, as it would require remeshing (since there is no guarantee that the boundaries of the meshes align). This is why you can do it before generating the mesh.