I have a code that was working fine in version 1.4. I have now upgraded to version 1.5 and my code does not work anymore. I have narrowed it down to the following simple working example.
See the following example:
import dolfin
mesh = dolfin.UnitSquareMesh(2,2)
# Sub domain for Periodic boundary condition. Define periodic boundary conditions.
class PeriodicBoundary(dolfin.SubDomain):
# Left boundary is "target domain" G
def inside(self, x, on_boundary):
# return True if on left or bottom boundary AND NOT on one of the two corners (0, 1) and (1, 0)
return bool((dolfin.near(x[0], 0) or dolfin.near(x[1], 0)) and
(not ((dolfin.near(x[0], 0) and dolfin.near(x[1], 1)) or
(dolfin.near(x[0], 1) and dolfin.near(x[1], 0)))) and on_boundary)
def map(self, x, y):
if dolfin.near(x[0], 1) and dolfin.near(x[1], 1):
y[0] = x[0] - 1.
y[1] = x[1] - 1.
elif dolfin.near(x[0], 1):
y[0] = x[0] - 1.
y[1] = x[1]
else: # near(x[1], 1)
y[0] = x[0]
y[1] = x[1] - 1.
box_periodic_bc = PeriodicBoundary()
# define the two functional spaces that make up the mixed one
S = dolfin.FunctionSpace(mesh,'CG',1,constrained_domain=box_periodic_bc) # a scalar CG space
C = dolfin.FunctionSpace(mesh, "R", 0,constrained_domain=box_periodic_bc) # a real space
# construct the mixed function space
M = dolfin.MixedFunctionSpace([S,C])
# generate a function from the scalar CG space
psi = dolfin.Function(S)
print "Number of degrees of freedom in psi before assign: ", psi.vector().array().shape[0]
# generate a function from the mixed space
m = dolfin.Function(M)
# split the solutions
psi_mixed,c_mixed = m.split(deepcopy=True)
# assign the one from the mixed, they should be the same size
psi.assign(psi_mixed)
print "Number of degrees of freedom in psi before assign: ", psi.vector().array().shape[0]
Essentially, I have periodic boundary conditions and when I try to get one of the functions out of the mixed solution. Since I have periodic boundary conditions and this is a 2x2 mesh with CG of order one elements, I should get 4 dofs instead of the typical 9. This is the case for psi that is generated directly from S. Now, if I create a function from the mixed space and try to extract the psi part. This function has 9 dofs. Therefore if I do an assign my original psi will change the number of degrees of freedom. This was not happening before. Did something change? Or this is a bug?