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

cell.normal(ufc_cell.local_facet) in Mixed formulation for Poisson equation demo

0 votes

https://fenicsproject.org/documentation/dolfin/1.2.0/python/demo/pde/mixed-poisson/python/documentation.html

Can anyone help me to understand 'n = cell.normal(ufc_cell.local_facet)' in this demo? I printed n[0], and the values are all zeros. But shouldn't some of them be 1 and -1, as n[0] is the x-component of the normal of given facet with respect to the cell?

Thank you.

asked Jul 14, 2016 by jhe FEniCS Novice (270 points)

1 Answer

0 votes
 
Best answer

The boundary function is used in a DirichletBC object as follows:

# Define essential boundary
def boundary(x):
    return x[1] < DOLFIN_EPS or x[1] > 1.0 - DOLFIN_EPS

bc = DirichletBC(W.sub(0), G, boundary)

Thus it will be evaluated only on top and bottom boundaries, where the normal is +/- (0, 1). If you also print n[1] you will see that it is nonzero.

answered Jul 14, 2016 by francesco.ballarin FEniCS User (4,070 points)
selected Jul 14, 2016 by jhe
...