# SNES solver failing

391

views

1

I have code solve a PDE using the default Newton solver but would like to transition to using SNES. However, I'm having trouble tweaking my code to do so. This code

gives me the (correct) result:

However adding the options

Gives the error

Does anyone know what I'm doing wrong?

auto F = std::make_shared<StressBalance::LinearForm>(space);

auto J = std::make_shared<StressBalance::JacobianForm>(space, space);

// set Expressions/Functions/Constants for F and J

auto prob = std::make_shared<dfn::NonlinearVariationalProblem>(F, u, std::vector<std::shared_ptr<const dfn::DirichletBC> >(1, dirichlet), J);

auto solver = std::make_shared<dfn::NonlinearVariationalSolver>(prob);

solver->solve();

gives me the (correct) result:

Solving nonlinear variational problem.

Newton iteration 0: r (abs) = 2.230e-04 (tol = 1.000e-10) r (rel) = 1.000e+00 (tol = 1.000e-09)

Newton iteration 1: r (abs) = 3.098e-06 (tol = 1.000e-10) r (rel) = 1.389e-02 (tol = 1.000e-09)

Newton iteration 2: r (abs) = 3.961e-09 (tol = 1.000e-10) r (rel) = 1.777e-05 (tol = 1.000e-09)

Newton iteration 3: r (abs) = 5.240e-14 (tol = 1.000e-10) r (rel) = 2.350e-10 (tol = 1.000e-09)

Newton solver finished in 3 iterations and 3 linear solver iterations.

However adding the options

solver->parameters["nonlinear_solver"] = "snes";

solver->parameters("snes_solver")["report"] = true;

solver->parameters("snes_solver")["maximum_iterations"] = (int)maxIt;

solver->parameters("snes_solver")["relative_tolerance"] = tol;

solver->parameters("snes_solver")["relative_tolerance"] = tol;

solver->parameters("snes_solver")["error_on_nonconvergence"] = false;

solver->parameters("snes_solver")["line_search"] = "bt";

Gives the error

Solving nonlinear variational problem.

unknown file: Failure

C++ exception with description "

*** -------------------------------------------------------------------------

*** DOLFIN encountered an error. If you are not able to resolve this issue

*** using the information listed below, you can ask for help at

***

*** fenics-support@googlegroups.com

***

*** Remember to include the error message listed below and, if possible,

*** include a *minimal* running example to reproduce the error.

***

*** -------------------------------------------------------------------------

*** Error: Unable to successfully call PETSc function 'SNESSetFromOptions'.

*** Reason: PETSc error code is: 73 (Object is in wrong state).

*** Where: This error was encountered inside /Users/andy/software/fenics/dolfin/dolfin/nls/PETScSNESSolver.cpp.

*** Process: 0

***

*** DOLFIN version: 2017.1.0.dev0

*** Git changeset: 241684bbf19fc2dd9d035d1e7c1d16a14dfeade2

*** -------------------------------------------------------------------------

" thrown in the test body.

Does anyone know what I'm doing wrong?

Please login to add an answer/comment or follow this question.

params.add("nonlinear_solver", "snes");

to the 'nonlinear_possion' demo gives me the same error. Perhaps I need to compile Petsc with different options?