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

Complex mixed boundary conditions

0 votes

In Fenics, the usual way to write the Dirichlet boundary condition $u = u_0$ and $v = v_0$ on the $boundary parts$ (u, v are unknown) is:

V1 = FunctionSpace(mesh, 'CG', 2)
V2 = FunctionSpace(mesh, 'CG', 2)
V = MixedFunctionSpace([V1, V2])
bc1 = DirichletBC(V.sub(0), u0, boundary_parts)
bc2 = DirichletBC(V.sub(1), v0, boundary_parts)

What if I want to write down something like this: $u + 2v = 1$ on the boundary?

Thanks.

asked Oct 11, 2015 by newuser FEniCS Novice (650 points)
edited Oct 11, 2015 by newuser

1 Answer

0 votes

Hi,

First of all, if you are solving an elliptic problem you will need a second boundary condition to make the problem well posed.

In order to impose the boundary condition $u + 2v = 1$, you can use either:
1) Lagrange multiplier methods
2) A penalization method.

The latter is by far the simpler to implement. You will basically have to add a variational form otf the type

beta = 1e5
weak_bc_lhs = beta*(u + 2v)*u_test*dss + beta*(u + 2v)*v_test*dss
weak_bc_rhs = beta*1*u_test*dss + beta*1*v_test*dss

where
beta is the penalization parameter
u, V the trail functions
u_test, v_test the test functions
dss the measure of the boundary where you want to impose such condition.

answered Oct 12, 2015 by umberto FEniCS User (6,440 points)
...