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

Modifying PeriodicBoundary3 class to be periodic in x, y, z

0 votes

Hello,
I have been using the following DOLFIN class (which I found at https://bitbucket.org/fenics-project/dolfin/pull-requests/4/adding-test-for/diff) to allow my 3D meshes (e.g. a cube mesh) to be periodic in the x direction.

class PeriodicBoundary3(SubDomain):
    def inside(self, x, on_boundary):
        return bool(x[0] < DOLFIN_EPS and x[0] > -DOLFIN_EPS and on_boundary)

    def map(self, x, y):
        y[0] = x[0] - 1.0
        y[1] = x[1]
        y[2] = x[2]

I would like to know how to modify this class to make my mesh periodic in all three directions (x, y and z).
Thank you in advance for your help!

asked Jul 18, 2016 by nlpitre FEniCS Novice (120 points)
closed Aug 10, 2016 by nlpitre

You may find this answer to an old question useful.

That's great - thank you!

...