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

Subdomains in C++

+1 vote

Hello,
I am looking to move to using Fenics in C++ and am trying to figure out how to define a weak form that integrates over a portion of the domain instead of the whole domain, in particular a portion of the boundary. I know I can define the form in the .ufl file using something like

u = TrialFunction(element)
v = TestFunction(element)
f = Coefficient(element)
a = inner(grad(u), grad(v))*dx + f*ds(1) + f*ds(2)

(this is just example code, I realize this doesn't actually correspond to a weak form that makes any sense).

My question then is how do I define what portion of the boundary is defined by the measure ds(1) and ds(2)? I'm assuming this is done in the C++ code along with defining the boundary conditions and the mesh, but I don't know how. Thank you in advance for any help you can give.

asked Jun 9, 2016 by jbcolli2 FEniCS Novice (210 points)

Maybe this demo can be helpful for you. In particular, take a look to the Linear form in the ufl code and to the lines 194-196 of the cpp code.

Thanks, that looks like exactly the kind of example I was looking for.

...