reset_jacobian = False in NonlinearVariationalSolver crashes

Bug #1055645 reported by Marie Rognes
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
DOLFIN
Confirmed
Undecided
Unassigned

Bug Description

Setting the parameter "reset_jacobian" equal to False in a NonlinearVariationalSolver crashes unexpectedly.
For instance: this snippet:

--
from dolfin import *
mesh = UnitSquare(10, 10)
V = FunctionSpace(mesh, "CG", 1)
u = Function(V)
u.vector()[:] = 1.0
v = TestFunction(V)
f = Expression("x[0]*x[0]", degree=2)
F = u*u*v*dx - f*v*dx
pde = NonlinearVariationalProblem(F, u, J=derivative(F, u))
solver = NonlinearVariationalSolver(pde)
solver.parameters["reset_jacobian"] = False
solver.solve()
plot(u, interactive=True)
--

gives this error:

Solving nonlinear variational problem.
python: /usr/include/boost/smart_ptr/shared_ptr.hpp:418: T* boost::shared_ptr<T>::operator->() const [with T = dolfin::NewtonSolver]: Assertion `px != 0' failed.
[nyx:10986] *** Process received signal ***
[nyx:10986] Signal: Aborted (6)
[nyx:10986] Signal code: (-6)
[nyx:10986] [ 0] /lib/x86_64-linux-gnu/libpthread.so.0(+0xfcb0) [0x7f5f8ac38cb0]
[nyx:10986] [ 1] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x35) [0x7f5f89966445]
[nyx:10986] [ 2] /lib/x86_64-linux-gnu/libc.so.6(abort+0x17b) [0x7f5f89969bab]
[nyx:10986] [ 3] /lib/x86_64-linux-gnu/libc.so.6(+0x2f10e) [0x7f5f8995f10e]
[nyx:10986] [ 4] /lib/x86_64-linux-gnu/libc.so.6(+0x2f1b2) [0x7f5f8995f1b2]
[nyx:10986] [ 5] /home/meg/local/fenics/src/dolfin/trunk/build/dolfin/libdolfin.so.1.0(_ZN6dolfin26NonlinearVariationalSolver5solveEv+0xb9c) [0x7f5f84761bcc]
[nyx:10986] [ 6] /home/meg/local/fenics/src/dolfin/trunk/local/lib/python2.7/site-packages/dolfin/cpp/_fem.so(+0x41d8f) [0x7f5f6b673d8f]
[nyx:10986] [ 7] python(PyEval_EvalFrameEx+0x5985) [0x49d585]
[nyx:10986] [ 8] python(PyEval_EvalCodeEx+0x1a0) [0x49f1c0]
[nyx:10986] [ 9] python(PyRun_FileExFlags+0xe1) [0x4a9081]
[nyx:10986] [10] python(PyRun_SimpleFileExFlags+0x1d1) [0x4a9311]
[nyx:10986] [11] python(Py_Main+0x55d) [0x4aa8bd]
[nyx:10986] [12] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed) [0x7f5f8995176d]
[nyx:10986] [13] python() [0x41b9b1]
[nyx:10986] *** End of error message ***
Aborted (core dumped)

Revision history for this message
Felix Ospald (felix-ospald) wrote :

I can confirm the bug there is a "!" missing in NonlinearVariationalSolver::solve():

  // Create Newton solver and set parameters
  if (newton_solver || reset_jacobian)
  {
    // Create Newton solver and set parameters
    newton_solver = boost::shared_ptr<NewtonSolver>(new NewtonSolver(parameters["linear_solver"],
                                                        parameters["preconditioner"]));
  }

should be

  // Create Newton solver and set parameters
  if (!newton_solver || reset_jacobian)
  {
    // Create Newton solver and set parameters
    newton_solver = boost::shared_ptr<NewtonSolver>(new NewtonSolver(parameters["linear_solver"],
                                                        parameters["preconditioner"]));
  }

Johannes Ring (johannr)
Changed in dolfin:
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.