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

Are periodic boundary conditions supported on manifolds?

0 votes

I would like to solve a poisson equation on a manifold. I would like to use periodic boundary conditions, but I am not sure they are supported in the version of dolfin I am using (1.6.0). For example, if I run the following code, which creates a function space on the boundary of the unit square,

from dolfin import *
# Sub domain for Periodic boundary condition
    class PeriodicBoundary(SubDomain):
    # Left boundary is "target domain" G
    def inside(self, x, on_boundary):
        print "The inside function has been called."
        return bool(x[0] < DOLFIN_EPS and x[0] > -DOLFIN_EPS and on_boundary)

    # Map right boundary (H) to left boundary (G)
    def map(self, x, y):
        print "The map function has been called."
        y[0] = x[0] - 1.0
        y[1] = x[1]

# Create mesh and finite element
mesh = UnitSquareMesh(32, 32)
periodic = PeriodicBoundary()
bmesh = BoundaryMesh(mesh,'exterior')
V = FunctionSpace(bmesh, "CG", 1, constrained_domain=periodic)

I do not see any print statements to say that the PeriodicBoundary class has been called -- it seems to be ignored. If I instead ask for a function on the original mesh (not the boundary mesh):
V = FunctionSpace(mesh, "CG", 1, constrained_domain=periodic)
I see lots of calls to the class.

Are periodic boundary conditions on manifolds simply not supported in dolfin as yet?

asked May 5, 2016 by johnrudge FEniCS Novice (120 points)

Did you get any answer to this? The example you give seems a bit strange anyway... presumably the real problem is a surface in 3D? I can't see a logical reason for it not to work, maybe it can be fixed.

I've had no answer, but I think I've worked out what the issue is. As Chris remarks, the example above is simplified one: the real problem I am interested in is indeed a surface in 3D.

I have managed to get my code to work, but only by editing the dolfin source code. The edit I made was to dolfin/mesh/PeriodicBoundaryComputation.cpp. On line 111 it states:

// Consider boundary entities only
const bool global_exterior_facet = (f->num_global_entities(tdim) == 1);
if (global_exterior_facet)
{

This means that only points on exterior facet boundaries get mapped. On my boundary mesh, none of the points are on exterior facet boundaries, and so no mapping occurs. I simply removed this if statement, and the code runs perfectly! I would suggest that this condition statement be removed from the dolfin source code, or allowed to be overrided. Users would then have a bit more flexibility in setting periodic boundary conditions.

OK, but for the real case (e.g. let's consider a UnitSquareMesh embedded in $R^3$), you would probably be matching real exterior facets to other exterior facets. Is your intention to map internal facets together?
If you think it is useful, maybe you can submit a pull request or create an issue on bitbucket.

...