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

No convergence for Laplace equation with constant boundary?

0 votes

(repost from Launchpad question - it seems Launchpad is no longer used?)

Hello,

I'm just beginning to use FEniCS, and I think I'm struggling with some basics. As a trivial test problem, I have tried to solve Laplace's equation in a sphere with constant boundary conditions:

$ cat test.py
#!/usr/bin/env python
from __future__ import division, print_function, absolute_import
import dolfin as df

ORDER=1

def u0_boundary(x, on_boundary):
    return on_boundary

mesh = df.UnitSphere(30)
V = df.FunctionSpace(mesh, 'Lagrange', ORDER)
u = df.TrialFunction(V)
v = df.TestFunction(V)
bc = df.DirichletBC(V, df.Constant('42'), u0_boundary)
a = df.inner(df.nabla_grad(u), df.nabla_grad(v)) * df.dx
L = df.Constant(0) * v * df.dx
psi = df.Function(V)
df.set_log_level(df.PROGRESS)
df.solve(a == L, psi, bc,
         solver_parameters = {'linear_solver': 'cg',
                              'preconditioner': 'ilu'})

However, this fails with

$ python test.py
Solving linear variational problem.
  Applying boundary conditions to linear system.
  Solving linear system of size 29791 x 29791 (PETSc Krylov solver).
  PETSc Krylov solver starting to solve 29791 x 29791 system.
Traceback (most recent call last):
  File "test.py", line 21, in <module>
    'preconditioner': 'ilu'})
  File "/usr/lib/python2.7/dist-packages/dolfin/fem/solving.py", line 250, in solve
    _solve_varproblem(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/dolfin/fem/solving.py", line 273, in _solve_varproblem
    solver.solve()
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
***
*** https://answers.launchpad.net/dolfin
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------------------------------------------------------------------------
*** Error: Unable to solve linear system using PETSc Krylov solver.
*** Reason: Solution failed to converge in 3 iterations (PETSc reason DIVERGED_INDEFINITE_PC, norm 2.779098e+03).
*** Where: This error was encountered inside PETScKrylovSolver.cpp.
*** -------------------------------------------------------------------------

However, if I replace the boundary condition with 0 instead of 42, things seem to work. Confusingly, it also works if I replace the UnitSphere mesh with a UnitCube mesh.

Am I doing something wrong?

I am using FEniCS 1.0.0.

Thanks!

asked Jan 9, 2014 by Nikolaus Rath FEniCS User (2,100 points)
edited Jan 9, 2014 by Nikolaus Rath

The UnitSphere provided in DOLFIN 1.0.0 is flawed. Try upgrade your FEniCS installation or try another mesh. You can also try a direct solver, "lu" instead of "cg".

1 Answer

0 votes
 
Best answer

As said by johanhake in his comment (thanks!), the explanation is that Dolfin's UnitSphere method is broken. I tried again with an externally generated spherical mesh, and it worked just fine. Turns out that recent Dolfin versions actually don't have a UnitSphere function anymore (I found this Launchpad bug)

answered Jan 10, 2014 by Nikolaus Rath FEniCS User (2,100 points)

It's now called SphereMesh. It's declared in dolfin/generation/EllipsoidMesh.h.

...