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)