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

Is it possible to define periodic boundary conditions for two facets marked by a MeshFunction?

+1 vote

Almost all questions I've seen so far deal with unit squares or cubes and explicitly use a priori knowledge of the facet locations to implement periodic boundary conditions. I'd like to know if one can come up with a more generalized version of a PeriodicBC class.

More specifically: Given a D-dimensional Mesh mesh and a MeshFunction facets (that obviously marks the (D-1)-dimensional facets), I would like to write a PeriodicBC to map facet1 to facet2, but I'm somewhat lost in the specs/doc to find out the bits and pieces I need for that. Any help would be appreciated!

class PeriodicBC(SubDomain):
    def __init__(self, facet1, facet2):
        self.facet1 = facet1
        self.facet2 = facet2

    # Check that `x` is element of boundary `facet1`.
    def inside(self, x, on_boundary):
        # ?

    # Map point `y` on `facet2` onto point `x` on `facet1`.
    # This is probably much more complicated and may as
    # well involve facet normal vectors.
    def map(self, x, y):
        y[0] = ?
        y[1] = ?
        # y[2] = ?  # if 3D mesh
asked Oct 25, 2016 by smiter FEniCS Novice (190 points)
...