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

Integration over lines (entities of codimension 2)

0 votes

Hello everybody!

I have seen that using dx and ds (and dx(i), ds(i), suitably marking the mesh via MeshfFunction) it is possible to integrate over entities of codimension 0 and 1, respectively.
I wonder if there is a way of integrating over entities of codimension 2 (set of points in 2D, lines in 3D).

I know that it is possible to mark lines, and even points, via EdgeFunction and VertexFunction, but it seems to me that there is no chance to pass this information to a Form, since only
Form::set_cell_domains (codimension 0)
Form::set_exterior_facet_domains (codimension 1)
Form::set_interior_facet_domains (codimension 1)
are available.

The following (C++) 2D code snippet might be useful to explain what I mean.

class TopBoundary : public dolfin::SubDomain
{ 
    bool inside (const dolfin::Array<double>& x, bool on_boundary) const
    { return on_boundary && dolfin::near(x[1],0); }
};

class ExtremaOfTopBoundary: public dolfin::SubDomain
{
    bool inside (const dolfin::Array<double>& x, bool on_boundary) const
    { return on_boundary && dolfin::near(x[1],0) 
        && ( dolfin::near(x[0],0) || dolfin::near(x[0],1) ); }
};

int main(int argc, char* argv[])
{
    dolfin::UnitSquareMesh mesh(10,10);

    // working (codimension 1)
    dolfin::EdgeFunction<std::size_t> boundaryFunction (mesh);
    boundaryFunction.set_all(0);
    TopBoundary topBoundary;
    topBoundary.mark(boundaryFunction,1);
    elsewhereDefinedForm.set_exterior_facet_domains(boundaryFunction);
            // employable in a form via ds(1)

    // aim of the question (codimension 2)
    dolfin::VertexFunction<std::size_t> pointsFunction (mesh);
    pointsFunction.set_all(0);
    ExtremaOfTopBoundary extrema;
    extrema.mark(pointsFunction,2);
    elsewhereDefinedForm.WHAT_TO_PUT_HERE(pointsFunction);
            // longing to be employed in a form via something like ds(2)

    // some other stuff
    return 0;
}

Thank you in advance,

Ivan

asked Mar 16, 2015 by ivanfumagalli FEniCS Novice (120 points)

Hi, for 2d dP might be of some help, see here and here. As far as I know integrating over lines in 3d is not supported yet but you can always set up a function space on a line living in 3d, interpolate from 3d to this space and then integrate there as you please.

...