Interpolation onto function spaces with periodic boundary conditions appears to be broken
Issue #18
invalid
Consider the following code:
from dolfin import *
mesh = RectangleMesh(0, 0, 1, 2, 50, 50)
class PeriodicBoundary(SubDomain):
def inside(self, x, on_boundary):
return abs(x[0]) < DOLFIN_EPS and on_boundary
def map(self, x, y):
y[0] = x[0] - 1
pbc = PeriodicBoundary()
V1 = FunctionSpace(mesh, "CG", 1)
V2 = FunctionSpace(mesh, "CG", 1, constrained_domain=pbc)
expr = Expression("x[1]")
func1 = interpolate(expr, V1); plot(func1, title="Without PBC")
func2 = interpolate(expr, V2); plot(func2, title="With PBC")
interactive()
I expected both of the plots to be the same: the function space is periodic in the x-boundary, and I've interpolated y. But they are not: there's an odd spike in the bottom-left corner, and the right-hand boundary has the wrong values.
Comments (5)
-
reporter -
Try
def map(self, x, y): y[0] = x[0] -1 y[1] = x[1]
That works for me
Mikael
-
reporter Ah, what a silly mistake. Thanks, Mikael. I'll add a check in PeriodicBoundaryComputation.cpp to make sure the user has set all of the necessary dimensions.
-
reporter - changed status to resolved
-
- changed status to invalid
- Log in to comment
This happens both with 1.2 and trunk.