linear solver parameters not recognized

Asked by Nico Schlömer

I would like to solve a linear system with CG, and did the following

====================== *snip* ======================
from dolfin import *

# Create mesh and define function space
mesh = UnitSquareMesh(32, 32)
V = FunctionSpace(mesh, "Lagrange", 1)

# Define boundary condition
bc = DirichletBC(V, Constant(0.0), 'on_boundary')

# Define variational problem
u = TrialFunction(V)
v = TestFunction(V)
a = inner(grad(u), grad(v)) * dx
L = Constant(1.0) * v * dx

# Compute solution
u = Function(V)

set_log_level(PROGRESS)

solve(a == L, u, bc,
      solver_parameters={"linear_solver": "cg"})
====================== *snap* ======================

The output of this script is

====================== *snip* ======================
[...]
  Solving linear system of size 1089 x 1089 (PETSc LU solver, umfpack).
====================== *snap* ======================

so I'm guessing I'm making a mistake. Where is it?

Question information

Language:
English Edit question
Status:
Solved
For:
FEniCS Project Edit question
Assignee:
No assignee Edit question
Solved by:
Nico Schlömer
Solved:
Last query:
Last reply:
Revision history for this message
Johan Hake (johan-hake) said :
#1

try:
  solve(a == L, u, bc, solver_parameters={\
      "linear_solver": "iterative",
      "symmetric":True})

But I give you that it is not very intuitive or well documented. I had
to go to the source. Note that it differ from the pure linear algebra
solve, which takes "cg" as an argument. One can also pass any string to
the linear_solver argument and anything not "iterative" will give a
direct solver. We should probable settle on "iterative" and "direct"
being the only possible options.

Consider reporting a bug or even better. A bug together with a patch :)

Johan

On 01/15/2013 10:21 PM, Nico Schlömer wrote:
> New question #219272 on FEniCS Project:
> https://answers.launchpad.net/fenics/+question/219272
>
> I would like to solve a linear system with CG, and did the following
>
> ====================== *snip* ======================
> from dolfin import *
>
> # Create mesh and define function space
> mesh = UnitSquareMesh(32, 32)
> V = FunctionSpace(mesh, "Lagrange", 1)
>
> # Define boundary condition
> bc = DirichletBC(V, Constant(0.0), 'on_boundary')
>
> # Define variational problem
> u = TrialFunction(V)
> v = TestFunction(V)
> a = inner(grad(u), grad(v)) * dx
> L = Constant(1.0) * v * dx
>
> # Compute solution
> u = Function(V)
>
> set_log_level(PROGRESS)
>
> solve(a == L, u, bc,
> solver_parameters={"linear_solver": "cg"})
> ====================== *snap* ======================
>
> The output of this script is
>
> ====================== *snip* ======================
> [...]
> Solving linear system of size 1089 x 1089 (PETSc LU solver, umfpack).
> ====================== *snap* ======================
>
> so I'm guessing I'm making a mistake. Where is it?
>

Revision history for this message
Nico Schlömer (nschloe) said :
#2

Done and done.