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

Periodic boundaries and mixed formulation of poisson equation

0 votes

Is it possible to apply periodic boundary conditions in mixed dual formulation of Poisson equation? I.e. I want to replace $g$ in $-\sigma.n=g$ with a map, and try to handle singularity by setting $\int\ u\ dV=0$ via a Lagrange multiplier.

My first naive attempt at using constrained_domain in FunctionSpace failed with

Error: Unable to periodic boundary mapping.
*** Reason: Need to set coordinate 0 in sub_domain.map.

when trying to create a mixed function space.

asked Sep 3, 2014 by obm FEniCS Novice (680 points)

1 Answer

+2 votes
 
Best answer

Hi, the following works with DOLFIN version 1.4.0

from dolfin import *

# Sub domain for Periodic boundary condition
class PeriodicBoundary(SubDomain):

    # Left boundary is "target domain" G
    def inside(self, x, on_boundary):
        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):
        y[0] = x[0] - 1.0
        y[1] = x[1]

mesh = UnitSquareMesh(20, 20)
pb = PeriodicBoundary()

BDM = FunctionSpace(mesh, "BDM", 1, constrained_domain=pb)
DG = FunctionSpace(mesh, "DG", 0, constrained_domain=pb)
R = FunctionSpace(mesh, 'R', 0, constrained_domain=pb)
W = MixedFunctionSpace([BDM, DG, R])

(sigma, u, mu) = TrialFunctions(W)
(tau, v, nu) = TestFunctions(W)

# Define source function
f = Expression("10*exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)")

# Define variational form
a = (dot(sigma, tau) + div(tau)*u + div(sigma)*v)*dx - inner(u, nu)*dx - inner(mu, v)*dx 
L = - f*v*dx

uh = Function(W)
solve(a == L, uh)

sigma, u, mu = uh.split()

plot(u, interactive=True)
print assemble(u*dx)
answered Sep 3, 2014 by MiroK FEniCS Expert (80,920 points)
selected Sep 4, 2014 by obm

Thank you very much MiroK, I really appreciate the answer and the example as a beginner.

I am removing the comment I wrote about generalizing to 3D PBC, since finally I see why the PBC answer by mikael-mortensen maps the values to some arbitrary out of cell value. I would really appreciate if someone can point me to some reference why this is necessary though.

...