Subfunction assignment does not work in parallel with a MixedFunctionSpace

Issue #192 duplicate
Patrick Farrell created an issue

This example (modified from the sub-function-assignment demo)

from dolfin import *

# Create mesh and define function spaces
mesh = UnitSquareMesh(256, 256)
V = VectorFunctionSpace(mesh, "CG", 2)
P = FunctionSpace(mesh, "CG", 1)
Z = MixedFunctionSpace([V, P])

# Define function
v0 = Expression(("sin(2*pi*x[0])*sin(2*pi*x[1])", "cos(2*pi*x[0])*cos(2*pi*x[1])"))
q0 = Expression("cos(x[0])")

z = Function(Z)

u0 = Function(V)
u0.interpolate(v0)
p0 = Function(P)
p0.interpolate(q0)

assign(z, [u0, p0])

works nicely in serial:

[pef@aislinn:/tmp]$ python assign.py 
[pef@aislinn:/tmp]$

but crashes in parallel:

[pef@aislinn:/tmp]$ mpiexec -n 2 python assign.py
Process 0: Number of global vertices: 66049
Process 0: Number of global cells: 131072
Traceback (most recent call last):
  File "assign.py", line 20, in <module>
    assign(z, [u0, p0])
  File "/usr/lib/python2.7/dist-packages/dolfin/cpp/function.py", line 1927, in assign
    return _function.assign(*args)
RuntimeError: 

*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***
***     fenics@fenicsproject.org
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------------------------------------------------------------------------
*** Error:   Unable to create function assigner.
*** Reason:  The receiving and assigning spaces do not have the same number of dofs per space.
*** Where:   This error was encountered inside FunctionAssigner.cpp.
*** Process: 0
*** 
*** DOLFIN version: 1.3.0
*** Git changeset:  unknown
*** -------------------------------------------------------------------------

Traceback (most recent call last):
  File "assign.py", line 20, in <module>
    assign(z, [u0, p0])
  File "/usr/lib/python2.7/dist-packages/dolfin/cpp/function.py", line 1927, in assign
    return _function.assign(*args)
RuntimeError: 

*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***
***     fenics@fenicsproject.org
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------------------------------------------------------------------------
*** Error:   Unable to create function assigner.
*** Reason:  The receiving and assigning spaces do not have the same number of dofs per space.
*** Where:   This error was encountered inside FunctionAssigner.cpp.
*** Process: 1
*** 
*** DOLFIN version: 1.3.0
*** Git changeset:  unknown
*** -------------------------------------------------------------------------

This is with the 1.3 package from the PPA on Ubuntu precise.

Comments (2)

  1. Log in to comment