PetScKrylovSolver sometimes crashes in parallel
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
DOLFIN |
Won't Fix
|
Undecided
|
Unassigned |
Bug Description
When I run the unit test test/unit/
Warning -- row partitioning does not line up! Partitioning incomplete!
[2]PETSC ERROR: MatHYPRE_
[2]PETSC ERROR: PCSetUp_HYPRE() line 112 in src/ksp/
[2]PETSC ERROR: PCSetUp() line 795 in src/ksp/
[2]PETSC ERROR: KSPSetUp() line 237 in src/ksp/
[2]PETSC ERROR: KSPSolve() line 353 in src/ksp/
[2]PETSC ERROR: PCDestroy_HYPRE() line 204 in src/ksp/
[2]PETSC ERROR: PCDestroy() line 83 in src/ksp/
[2]PETSC ERROR: KSPDestroy() line 695 in src/ksp/
or with this message:
Inconsistent partitioning -- HYPRE_IJVectorC
[2]PETSC ERROR: VecHYPRE_
[2]PETSC ERROR: PCSetUp_HYPRE() line 118 in src/ksp/
[2]PETSC ERROR: PCSetUp() line 795 in src/ksp/
[2]PETSC ERROR: KSPSetUp() line 237 in src/ksp/
[2]PETSC ERROR: KSPSolve() line 353 in src/ksp/
[2]PETSC ERROR: PCDestroy_HYPRE() line 201 in src/ksp/
[2]PETSC ERROR: PCDestroy() line 83 in src/ksp/
[2]PETSC ERROR: KSPDestroy() line 695 in src/ksp/
Note that this happens only in about 10% of the runs, so there seems to be a race condition somewhere.
The following code (which is essentially a part of the unit test) reproduces the bug on my computer (Ubuntu 12.04 with PetSc installed through apt-get) when run with
mpirun -np 3 python KrylovSolver.py
from dolfin import *
# Assemble system
mesh = UnitSquare(32, 32)
V = FunctionSpace(mesh, 'CG', 1)
bc = DirichletBC(V, Constant(0.0), lambda x, on_boundary: on_boundary)
u = TrialFunction(V); v = TestFunction(V);
u1 = Function(V)
# Forms
a, L = inner(grad(u), grad(v))*dx, Constant(1.0)*v*dx
a_L = inner(grad(u1), grad(v))*dx
# Assemble linear algebra objects
A = assemble(a)
b = assemble(L)
bc.apply(A, b)
# Get solution vector
tmp = Function(V)
x = tmp.vector()
# Get solution vector
x_petsc = down_cast(x)
# With PETScPreconditioner interface
solver = PETScKrylovSolv
solver.solve(A, x_petsc, down_cast(b))
I think that this is a bug in the Ubuntu PETSc package.