FunctionSpace.collapse() does not work with constrained_domain

Issue #989 new
Jørgen Dokken created an issue

As described in the title, this causes an error, minimal example:

from dolfin import *
class PeriodicBoundary(SubDomain):
    def inside(self, x, on_boundary):
        return x[0] == 0.0 and on_boundary

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

pbc = PeriodicBoundary()
mesh = RectangleMesh(Point(0, 0), Point(1, 2), 50, 50)


Vh = FiniteElement("CG", mesh.ufl_cell(), 2)
Ph = FiniteElement("CG", mesh.ufl_cell(), 1)

Z = FunctionSpace(mesh, MixedElement((Vh, Ph)),constrained_domain=pbc) 
V, P = Z.split()
Vs = V.collapse()

Produces

  File "/dolfin_repo/dolfin/python/dolfin/function/functionspace.py", line 195, in collapse
    cpp_space, dofs = self._cpp_object.collapse()

  cpp_space, dofs = self._cpp_object.collapse()
RuntimeError: 
*** -------------------------------------------------------------------------
*** Error:   Unable to complete call to function DofMap().
*** Reason:  Assertion global_dimension() == dofmap_view.global_dimension() failed.

Same example works with 2017.2.0.post0 with swig.

To get this example working, one has to copy/paste the split-functionality from the depricated site-packages/dolfin/function/functionspace.py into python/dolfin/function/functionspace.py:

  def split(self):
        """Split a mixed functionspace into its sub spaces"""
        return [self.sub(i) for i in range(self.num_sub_spaces())]

Comments (2)

  1. Log in to comment