Python nonlinear solvers interface memory management
Issue #814
new
NonlinearProblem
and NewtonSolver
contain virtual methods that
- take tensor arguments by reference
- are supposed to be overloaded by user in Python
SWIG directors create no-deleter shared pointers from references. This is not good.
Possible solutions:
-
Implement a check into SWIG directors checking that user did not store the pointers.
-
Change
NonlinearProblem
andNewtonSolver
C++ interface to take shared pointers instead of references. Note alsoNewtonSolver::solve(GenericVector& x)
would need to be change into shared ptr, becausex
is then passed to other Python methods.
This issue can be solved in concert with #556 which may introduce interface changes too.