Problem with integration of exterior_facet

Asked by Renier Marchand

Hi,

I expect the following code to be equivalent to a line integral over the edge of the square domain. However it seems as if integration is actually happening in the cells that touch the edge of the domain. (This can be seen by the values for x and y printed out during the assembly)

Do I understand this correctly or is my implementation wrong?

import dolfin as D

mesh = D.UnitSquare(2,2)

V = D.FunctionSpace(mesh, 'N1curl', 1)

bd = D.DomainBoundary()

# mf = D.FacetFunction('uint', mesh)
mf = D.MeshFunction('uint', mesh, mesh.topology().dim()-1)
mf.set_all(0)

bd.mark(mf, 2)

dss = D.ds[mf]

print mf.array()

code = """
class MyFunc : public Expression
{
public:

    boost::shared_ptr<Mesh> mesh;

    MyFunc() : Expression(2), mesh(static_cast<Mesh* >(0)) {} // const Mesh& mesh

    void eval(Array<double>& values, const Array<double>& x, const ufc::cell& ufc_cell) const
    {
         assert(ufc_cell.local_facet >= 0);
         assert(mesh);
         Cell cell(*mesh, ufc_cell.index);
         Point n = cell.normal(ufc_cell.local_facet);
         printf ("x: %f, y: %f, n.x: %f, n.y: %f\\n", x[0], x[1], n.x(), n.y());
         values[0] = x[0];
         values[1] = x[1];
    }

};
"""

ex = D.Expression(code, element=V.ufl_element())
ex.mesh = mesh

v = D.TestFunction(V)

L = D.dot(v, ex)*dss(2)

b = D.assemble(L)

print b.array() # expect this to only have values for edge basis functions defined of the edges

Regards,

Renier Marchand

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Renier Marchand
Solved:
Last query:
Last reply:
Revision history for this message
Renier Marchand (renierm) said :
#1

This happens because the expression is first projected onto the basis function see answer to: https://bugs.launchpad.net/dolfin/+bug/1083092

I still don't know how to implement a tangential boundary function as asked in https://answers.launchpad.net/dolfin/+question/215295