This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

How to create a mesh consisting of two geometries, where the boundary between the geometries is contained?

+2 votes

I would like to create a mesh consisting of two concentric spheres without loosing the boundary between the spheres. I've tried this:

from dolfin import *
from mshr import *

sphere1 = Sphere(Point(0., 0., 0.), 10.)  # inner sphere
sphere2 = Sphere(Point(0., 0., 0.), 20.) - sphere1  # outer sphere
concentric_spheres = sphere1 + sphere2

mesh = generate_mesh(concentric_spheres, 20., “cgal”)

As far as I understand, the mesh I end up with eliminates the boundary between the spheres. I would, however, like the outer boundary of sphere1/ the inner boundary of sphere2 to be part of the mesh.

Any advice is highly appreciated!=)

asked Mar 9, 2016 by solveignaess FEniCS Novice (160 points)

1 Answer

+1 vote

In the 2d case, something similar can be done with the below code:

from dolfin import *
from mshr import *

outer_circle = Circle(Point(0., 0.), 20.)
inner_circle = Circle(Point(0., 0.), 10.)

outer_circle.set_subdomain(1, inner_circle)

mesh = generate_mesh(outer_circle, 20.)
plot(mesh, interactive=True)
cf = MeshFunction("size_t", mesh, 2, mesh.domains())
plot(cf, interactive=True)

However, in the 3d case this is not possible with the latest releases of the mshr library (including the development version) becasue subdomains are currently supported only in 2d.

Apparently this feature will be supported in the next releases of mshr (see Issue #9 and Issue #10 for more details).

Edit: Maybe a solution for now is to use external softwares and/or libraries for this purpose.

answered Mar 9, 2016 by hernan_mella FEniCS Expert (19,460 points)
edited Mar 9, 2016 by hernan_mella

Thanks for the quick answer! I'll probably see what I can do with gmsh (?), then.

Trying to solve my issue, I came across MultiMesh()

I'm not sure if I understand what it does, yet, but do you think it could be possible to combine the two meshes in a MultiMesh? Or would that be making things unnecessarily complicated.

Yes, gmsh seems to be a good option (reading the documentation, i think that MultiMesh isn't util for what you wants).

...