HOWTO: combine geometries with keeping interfaces

Hi

I was trying to use mshr to combine different geometries and create a mesh. What I realized was the interface between geometries was smeared after mesh generation. Is there a way to combine geometries with keeping those interfaces as is?

Thanks,
Victor

Hello, I don’t know if it is exactly what you want but you can use the set_subdomain method of mshr to define subdomains which will then have a mesh-conforming interface:

from dolfin import *
from mshr import *
domain = Rectangle(Point(0, 0), Point(1, 1))
domain.set_subdomain(1, Circle(Point(0.5, 0.5), 0.4))
mesh = generate_mesh(domain, 10)
plot(mesh)
1 Like

This only works for 2D, right?

Possibly,
did you check https://github.com/FEniCS/mshr/blob/master/demo/python/simple-csg-3D.py ?
However if you need 3D meshes with multiple domains, I would suggest using a meshing software like Gmsh for instance.

I do need subdomains in 3D. Thanks anyways