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

Error when creating restricted function space ("'Restriction' object has no attribute 'mpi_comm')

+7 votes

With dolfin 1.4 the following code worked to create a restricted function space:

import dolfin as df

# Create a unit cube mesh
mesh = df.UnitCubeMesh(10, 10, 10)

# Create a cell function to mark a region
# consisting of the left half of the mesh
region_markers = df.CellFunction('size_t', mesh)

class Domain(df.SubDomain):
    def inside(self, pt, on_boundary):
        return pt[0] <= 0.5

subdomain = Domain()
subdomain.mark(region_markers, 1)

# Create a restricted function space
restriction = df.Restriction(region_markers, 1)
V_restr = df.VectorFunctionSpace(restriction, 'CG', 1, dim=3)

This fails with dolfin 1.5 with the following traceback:

AttributeError                            Traceback (most recent call last)
<ipython-input-26-90fabc673435> in <module>()
----> 1 V_restr = df.VectorFunctionSpace(restriction, 'CG', 1, dim=3)

/usr/lib/python2.7/dist-packages/dolfin/functions/functionspace.pyc in __init__(self, mesh, family, degree, dim, form_degree, constrained_domain, restriction)
    626         # Initialize base class
    627         FunctionSpaceBase.__init__(self, mesh, element,
--> 628                                    constrained_domain=constrained_domain)
    629 
    630 class TensorFunctionSpace(FunctionSpaceBase):

/usr/lib/python2.7/dist-packages/dolfin/functions/functionspace.pyc in __init__(self, mesh, element, constrained_domain)
    151 
    152         # JIT-compile element to get ufc_element and ufc_dofmap
--> 153         ufc_element, ufc_dofmap = jit(self._ufl_element, mpi_comm=mesh.mpi_comm())
    154 
    155         # Instantiate DOLFIN FiniteElement and DofMap

AttributeError: 'Restriction' object has no attribute 'mpi_comm'

The docstring for df.Restriction does not mention anything about MPI communicators, so I don't know how to pass a communicator when creating a Restriction. What is the right way to do this and fix the above piece of code for dolfin 1.5?

asked Jan 30, 2015 by Maximilian Albert FEniCS User (1,750 points)

1 Answer

0 votes
 
Best answer

Restriction has been removed temporarily from the Dofmap class, see link.

answered Feb 5, 2015 by mikael-mortensen FEniCS Expert (29,340 points)
selected Feb 5, 2015 by Maximilian Albert

Thanks! I had missed this. It should probably be mentioned in the release notes, too. I'll add a comment on the Bitbucket issue.

Btw, are you aware of any alternative that I could use to achieve the same/similar functionality? Some of my code has stopped working because of the removal of Restriction. Do I have to wait for the next release until MeshView is available, or is there a workaround?

...