Function(space, vector) constructor is ill-defined in parallel

Issue #339 resolved
Jan Blechta created an issue

Creating function from an already initialized vector (which may have no knowledge of DOF map, hence not having ghosts) ensures none of the following:

  • ghosts are additionally prepared
  • error is raised when ghosts are missing

Following code demonstrates the problem:

from dolfin import *

mesh = UnitCubeMesh(6, 6, 6)
V = FunctionSpace(mesh, "CG", 1)
v = TestFunction(V)
while True:
    x = assemble(v*dx)
    u = Function(V, x)
    print assemble(u*dx)

With debugging-enabled PETSc it raises PETSC_ERR_ARG_OUTOFRANGE 63 but computes random rubish with production builds.

Note: C++ documentation says *Warning: This constructor is intended for internal library use only*. This is apparently not reflected in python version.

Note: The example above also demonstrates that there is left some debugging print statement somewhere in the code resulting in the output like Local size, dim: 165, 343.

Comments (4)

  1. Log in to comment