Why does this direct solver appear to call a Krylov solver?


72
views
0
26 days ago by

In the following MWE (which I ran with a Docker container from quay.io/fenicsproject/stable), I intend to solve the Poisson problem with a direct solver:

import fenics


def boundary(x, on_boundary):

    return on_boundary
    
    
mesh = fenics.UnitSquareMesh(8, 8)

x = fenics.SpatialCoordinate(mesh)

exact_solution = 1. + x[0]**2 + 2.*x[1]**2

f = -6.

V = fenics.FunctionSpace(mesh, 'P', 2)
    
bc = fenics.DirichletBC(V, exact_solution, boundary)

u = fenics.TrialFunction(V)

v = fenics.TestFunction(V)

dot, grad = fenics.dot, fenics.grad

a = dot(grad(v), grad(u))*fenics.dx

L = v*f*fenics.dx

solution = fenics.Function(V)

fenics.set_log_level(fenics.DEBUG)

fenics.solve(a == L, solution, bc)

This outputs

Solving linear variational problem.
Matrix of size 289 x 289 has 3073 (3.67931%) nonzero entries.
Elapsed wall, usr, sys time: 0.0001026, 0, 0 (Build sparsity)
Elapsed wall, usr, sys time: 4.08e-05, 0, 0 (Init tensor)
Elapsed wall, usr, sys time: 8e-07, 0, 0 (Delete sparsity)
Elapsed wall, usr, sys time: 6.79e-05, 0, 0 (Assemble cells)
Elapsed wall, usr, sys time: 1.02e-05, 0, 0 (Apply (PETScMatrix))
Elapsed wall, usr, sys time: 1.8e-06, 0, 0 (Build sparsity)
Elapsed wall, usr, sys time: 2e-06, 0, 0 (Apply (PETScVector))
Elapsed wall, usr, sys time: 2.16e-05, 0, 0 (Init tensor)
Elapsed wall, usr, sys time: 8e-07, 0, 0 (Delete sparsity)
Elapsed wall, usr, sys time: 1.4e-06, 0, 0 (Apply (PETScVector))
Elapsed wall, usr, sys time: 4.43e-05, 0, 0 (Assemble cells)
Elapsed wall, usr, sys time: 1.8e-06, 0, 0 (Apply (PETScVector))
Computing sub domain markers for sub domain 0.
Elapsed wall, usr, sys time: 0.0002229, 0, 0 (DirichletBC init facets)
Elapsed wall, usr, sys time: 0.0002584, 0, 0 (DirichletBC compute bc)
Applying boundary conditions to linear system.
Elapsed wall, usr, sys time: 2.5e-06, 0, 0 (Apply (PETScVector))
Elapsed wall, usr, sys time: 4.2e-06, 0, 0 (Apply (PETScMatrix))
Elapsed wall, usr, sys time: 0.0003256, 0, 0 (DirichletBC apply)
Solving linear system of size 289 x 289 (PETSc LU solver, umfpack).
PETSc Krylov solver starting to solve 289 x 289 system.
Elapsed wall, usr, sys time: 0.0010557, 0, 0 (PETSc Krylov solver)
Elapsed wall, usr, sys time: 0.0011284, 0, 0 (LU solver)


Why is a Krylov solver being called?

Here's what I've looked at so far:

  • I only know the term "Krylov" in regards to Krylov subspace methods, which are iterative (not direct) methods.
  • I have spent some time reading up on UMFPACK and PETSc, and I'm not seeing anything that could explain this.
  • I also made a short attempt to catch with PDB where a Krylov solver is being called, so far with no success.
  • I am guessing that the actual log output comes from this source , which sure does look like a collection of Krylov subspace iterative (not direct) methods.
Community: FEniCS Project
1
If an iterative solver was being used, it would have shown some info of the iterations, which does not appear in your logs, so it is just using direct solver.
written 26 days ago by Praveen C  

1 Answer


5
26 days ago by
In PETSc, all linear solvers are Krylov solvers, with a direct solver being a 'pre-only' solver with a LU factorisation for the preconditioner. PETScLUSolver configures a PETScKrylovSolver to act as a direct solver.

Thanks!

I have a follow up question which may be most easily addressed here:


Is there a way to suppress that message and still invoke

fenics.set_log_level(fenics.PROGRESS)​

? (this log level indeed reproduces the message "PETSc Krylov solver starting to solve...")

Personally I find it misleading to print messages about a Krylov solver. I have been using that log level to report time progress in time-dependent problems per a tutorial I saw a while ago.

written 26 days ago by Alexander G. Zimmerman  
Could you register an issue of the last point on Bitbucket?
written 26 days ago by Garth Wells  
Done: https://bitbucket.org/fenics-project/dolfin/issues/960/log-mentions-krylov-solver-when-using
written 26 days ago by Alexander G. Zimmerman  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »