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

Assemble over boundary faces

+1 vote

I am having problems assembling an integral over the boundary faces of a mesh. The form of the integral is
$$\int_{\partial \Omega} ((\nabla\times \mathbf{A})\times \mathbf{B})\cdot \mathbf{\hat{n}}\,dS$$

I have tried the following

bmesh = BoundaryMesh(mesh, 'exterior')
facet_domains = FacetFunction('size_t',mesh)
mapping = bmesh.entity_map(2)
boundary_facets = [ Facet(mesh, mapping[cell.index()])
                for cell in cells(bmesh) ]
for facet in boundary_facets:
    facet_domains[facet] = 42

n = FacetNormal(bmesh)

dsb = Measure('dx', domain=mesh)[facet_domains]
assemble(dot(cross(curl(A),B),n)*dsb,exterior_facet_domain=facet_domains)

I am getting errors like

 FLException: An Integral without a Domain is now illegal.

or trying with some minor changes,

UFLException: Integral of type cell cannot contain a FacetNormal.
asked Nov 27, 2014 by luftiq FEniCS Novice (560 points)
edited Nov 28, 2014 by luftiq

1 Answer

+2 votes
 
Best answer

Try replacing the 'dx' in

dsb = Measure('dx')[facet_domains]

with 'ds'

answered Nov 28, 2014 by Marie E. Rognes FEniCS User (5,380 points)
selected Nov 28, 2014 by luftiq

Seems to help but should the normal be
n=FacetNormal(mesh)
or
n=FacetNormal(bmesh)

n = FacetNormal(mesh)
...