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

CellFunction and CGAL subdomains

0 votes

In dolfin 1.5.0 with CGAL support I can generate a 2D mesh with subdomain, for example:

from dolfin import *
domain = Circle(0,0,1.0)
domain.set_subdomain(1, Circle(0,0.8,0.05))
mesh = Mesh(domain,40)
V = FunctionSpace(mesh, 'Lagrange',1)

Now I want to define f=CellFunction("size_t",mesh) and set this function to 1 inside subdomain and 0 otherwise. I can test that I'm inside subdomain just geometrically like distance((0.8,0),x)<0.05, but I suppose there must exist a method for marking subdomains based on the initial CGAL construction, which can work on arbitrary subdomains inside a mesh.

asked Sep 4, 2015 by begemotv2718 FEniCS Novice (380 points)

1 Answer

+1 vote
 
Best answer

Hi, CGAL/mesh generation functionality has been moved from dolfin into the package mshr. Using mshr your problem is solved as follows

from dolfin import *
from mshr import *

domain = Circle(Point(0, 0), 1.0)
domain.set_subdomain(1, Circle(Point(0, 0.8), 0.05))
mesh = generate_mesh(domain, 40)
cell_f = MeshFunction("size_t", mesh, 2, mesh.domains())

plot(cell_f, interactive=True) 
answered Sep 5, 2015 by MiroK FEniCS Expert (80,920 points)
selected Sep 9, 2015 by johannr
...