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

How can I use a FacetNormal in a conditional part of a form?

0 votes

I'm working on a 2d heat conduction problem with a deforming boundary. The material is exposed to a constant heat flux vector. My problem is that as the material deforms, part of the "exposed" boundary points away from the heat flux and is thus shielded from it. I tried using a conditional statement in the form:

n = FacetNormal(mesh)
q = conditional(gt(n[1], 0), dot(q_vector, n), Constant(0.0))
L = q*v*ds

When I look at the compile.log file I get errors saying that form header file is using undeclared identifiers 'n1' and 'n2'.

Does this idea make any sense? Is there something wrong with my implementation of it? I could remark the boundaries at every time step, but that seems excessive. Thanks.

asked Mar 27, 2015 by mcb FEniCS Novice (310 points)

Hi, what DOLFIN version are you running? With the code below I can't repreduce the error you mentioned

from dolfin import *

mesh = UnitSquareMesh(10, 10)

V = FunctionSpace(mesh, 'CG', 1)
v = TestFunction(V)

n = FacetNormal(mesh)
q_vector = Expression(('x[0]', 'x[1]'))
q = conditional(gt(n[1], 0), dot(q_vector, n), Constant(0.0))
# q = conditional(gt(dot(n, Constant((1, 0))), 0), dot(n, q_vector), Constant(0))
L = q*v*ds  
...