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

Dirichlet condition with FacetNormal and a solution of another pde

0 votes

Hi all,
Given a FE-solution u, I want to solve another PDE by using u in the boundary condition for this PDE:

enter image description here
I can't handle the boundary condition, as I have to compute enter image description here and enter image description here .

The first problem is the computation of enter image description here :
Although there is no error message, I'm not sure, if using div(grad(u)) in the boundary condition is right, as I'm using FunctionSpace(mesh, 'Lagrange', 1) ?

The second problem is the computation of enter image description here:
Using dot(nabla_grad(u),n) as boundary condition provides an error: ufl.log.UFLException: Integral of type cell cannot contain a FacetNormal.
I found a solution by manually calculating the FacetNormal for 3D-meshes here, however, my problem is defined on a 2D-mesh. Is there a simple implementation in Fenics for this, or have I to compute the FacetNormal manually (maybe similar to the solution in the link)?

Here is the code providing the error message:

from dolfin import *
mesh = UnitSquareMesh(2,2)
V = FunctionSpace(mesh, 'Lagrange', 1)

# Let u be a FE-solution
def u0_boundary(x, on_boundary):
    return on_boundary

bc_u = DirichletBC(V, Constant(3.0) , u0_boundary)
u = TrialFunction(V)
v = TestFunction(V)
a = -inner(nabla_grad(u), nabla_grad(v))*dx
L = Constant(-6.0)*v*dx
u = Function(V)
solve(a == L, u, bc_u)

# define boundary conditions for new problem
n=FacetNormal(mesh)
bc=div(grad(u)) - (dot(nabla_grad(u),n)-Constant(1))
bc_w= DirichletBC(V, bc , u0_boundary)

# solve another PDE with special boundary condition
w = TrialFunction(V)
v1 = TestFunction(V)
a1 = inner(nabla_grad(w), nabla_grad(v1))*dx
L1 = Constant(-6.0)*v1*dx
w = Function(V)
solve(a1 == L1, w, bc_w)
asked May 19, 2015 by puffin FEniCS Novice (440 points)

1 Answer

0 votes

You can use the Nitsche's method to weakly impose the Dirichlet boundary condition.

See section 3.1 in
http://onlinelibrary.wiley.com/doi/10.1002/nme.2863/abstract

answered May 20, 2015 by umberto FEniCS User (6,440 points)
...