Class SUNNonLinSolWrapper

Inheritance Relationships

Derived Types

Class Documentation

class amici::SUNNonLinSolWrapper

A RAII wrapper for SUNNonLinearSolver structs which solve the nonlinear system F (y) = 0 or G(y) = y.

Subclassed by amici::SUNNonLinSolFixedPoint, amici::SUNNonLinSolNewton

Public Functions

explicit SUNNonLinSolWrapper(SUNNonlinearSolver sol)

SUNNonLinSolWrapper from existing SUNNonlinearSolver.

Parameters

sol

virtual ~SUNNonLinSolWrapper()
SUNNonLinSolWrapper(const SUNNonLinSolWrapper &other) = delete

Copy constructor.

Parameters

other

SUNNonLinSolWrapper(SUNNonLinSolWrapper &&other) noexcept

Move constructor.

Parameters

other

SUNNonLinSolWrapper &operator=(const SUNNonLinSolWrapper &other) = delete

Copy assignment.

Parameters

other

Returns

SUNNonLinSolWrapper &operator=(SUNNonLinSolWrapper &&other) noexcept

Move assignment.

Parameters

other

Returns

SUNNonlinearSolver get() const

Get the wrapped SUNNonlinearSolver.

Returns

SUNNonlinearSolver

SUNNonlinearSolver_Type getType() const

Get type ID of the solver.

Returns

int setup(N_Vector y, void *mem)

Setup solver.

Parameters
  • y – the initial iteration passed to the nonlinear solver.

  • mem – the sundials integrator memory structure.

Returns

int Solve(N_Vector y0, N_Vector y, N_Vector w, realtype tol, bool callLSetup, void *mem)

Solve the nonlinear system F (y) = 0 or G(y) = y.

Parameters
  • y0 – the initial iterate for the nonlinear solve. This must remain unchanged throughout the solution process.

  • y – the solution to the nonlinear system

  • w – the solution error weight vector used for computing weighted error norms.

  • tol – the requested solution tolerance in the weighted root-mean- squared norm.

  • callLSetup – a flag indicating that the integrator recommends for the linear solver setup function to be called.

  • mem – the sundials integrator memory structure.

Returns

int setSysFn(SUNNonlinSolSysFn SysFn)

Set function to evaluate the nonlinear residual function F(y) = 0 or the fixed point function G(y) = y.

Parameters

SysFn

Returns

int setLSetupFn(SUNNonlinSolLSetupFn SetupFn)

Set linear solver setup function.

Parameters

SetupFn

Returns

int setLSolveFn(SUNNonlinSolLSolveFn SolveFn)

Set linear solver solve function.

Parameters

SolveFn

Returns

int setConvTestFn(SUNNonlinSolConvTestFn CTestFn, void *ctest_data)

Set function to test for convergence.

Parameters
  • CTestFn

  • ctest_data

Returns

int setMaxIters(int maxiters)

Set maximum number of non-linear iterations.

Parameters

maxiters

Returns

long int getNumIters() const

getNumIters

Returns

int getCurIter() const

getCurIter

Returns

long int getNumConvFails() const

getNumConvFails

Returns

Protected Functions

void initialize()

initialize

Protected Attributes

SUNNonlinearSolver solver = nullptr

the wrapper solver