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

facet.exterior() always False?

+2 votes

I am trying to specify a DirichletBC using boolean expression for the boundary facet midpoints, but DirichletBC only allows for discarding facets using the check_midpoint.

I tried to create a FacetFunction and marks facets using their midpoint, but I cannot see an equivalent to the on_boundary functionality.

If I run

from dolfin import *
mesh = RectangleMesh(0,0,1,1,5,5)
for facet in facets(mesh):
 #print [facet.midpoint().x(),facet.midpoint().y()]
 print facet.exterior()

I get False for all of the facets.

asked Dec 12, 2014 by KristianE FEniCS Expert (12,900 points)

1 Answer

+2 votes
 
Best answer

Hi, you need to initialize the connectivity between facets and cells first.

from dolfin import *
mesh = RectangleMesh(0,0,1,1,5,5)
tdim = mesh.topology().dim()
mesh.init(tdim-1, tdim)
for facet in facets(mesh):
    print facet.exterior()
answered Dec 12, 2014 by MiroK FEniCS Expert (80,920 points)
selected Dec 13, 2014 by KristianE
...