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

Creating a rectangular domain with a circular hole

+1 vote

I want to simulate a composite material using FEniCS. Hard circular inclusion inside a rectangular matrix. Is there any way to define a different geometry and material properties inside the whole domain?

asked Jun 27, 2014 by Navid Mozaffari FEniCS Novice (510 points)

Have you checked CSG demo?

1 Answer

+5 votes

To the geometry, you can inspire in the following code:

from dolfin import *
# Define 2D geometry
domain = Rectangle(-2., -2., 2., 2.) 
domain.set_subdomain(1, Rectangle(-2., -2., 2., 2.))
domain.set_subdomain(2, Circle(0, 0, 1))
# Generate and plot mesh
mesh2d = Mesh(domain, 25)
plot(mesh2d, "2D mesh")
# Convert subdomains to mesh function for plotting
mf = MeshFunction("size_t", mesh2d, 2, mesh2d.domains())
plot(mf, "Subdomains")
interactive()

Before you should see 21. Poisson equation with multiple subdomains
I think that solves your problem

answered Jun 27, 2014 by ajaome FEniCS Novice (450 points)
How to define number of elements in DOLFIN_Dev

In the new version this only works with also issuing:

from mshr import*

...