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

Robin boundary conditions

+1 vote

Hello,

I consider an elliptic PDE with Robin boundary conditions:

$$ -\Delta u + u = f \quad on \; \Omega $$
$$ \frac{\partial u}{\partial n} + u = j \quad on \; \partial \Omega $$

My .ufl file looks as follows:

P1 = FiniteElement("Lagrange",triangle,1)
u = TrialFunction(P1)  
v = TestFunction(P1)
f = Coefficient(P1)   
j = Coefficient(P1)
a = inner(grad(u),grad(v))*dx + inner(u,v)*dx + u*v*ds
L = f*v*dx + j*v*ds
forms = [a,L]

My domain is $$ \Omega = [-1,1]x[-1,1].$$
I have defined $$ f $$ as a derived class from dolfin::Expression, i.e.

class MySource : public dolfin::Expression{
void eval(dolfin::Array<double>& value, const dolfin::Array<double>& x) const{
value[0] = 1.0;
}
};

Now I want to define $$j$$ such that j is constant =1 on the left side of the boundary, 2 in the bottom of the boundary, 3 on the right side of the boundary and 4 on the top of the boundary. Do you have any idea how I could implement this? (I am coding in C++)

I am very thankful for any suggestions!
frieder

asked Dec 2, 2016 by frieder FEniCS Novice (340 points)
retagged Dec 2, 2016 by frieder

1 Answer

0 votes

You can construct a measure, but for exterior facets, as shown here.

Then in the C++ you can set the facet domains from a FacetFunction using Form::set_exterior_facet_domains documented here.

answered Dec 2, 2016 by nate FEniCS Expert (17,050 points)
...