Newton-Raphson#

Header: <pressio/solvers_nonlinear_newton.hpp>

API#

namespace pressio{

template<class SystemType, class LinearSolverType>
#ifdef PRESSIO_ENABLE_CXX20
  requires nonlinearsolvers::RealValuedNonlinearSystemFusingResidualAndJacobian<SystemType>
  && (Traits<typename SystemType::state_type>::rank    == 1)
  && (Traits<typename SystemType::residual_type>::rank == 1)
  && (Traits<typename SystemType::jacobian_type>::rank == 2)
  && requires(typename SystemType::state_type    & a,
	      typename SystemType::state_type    & b,
	      typename SystemType::state_type    & c,
	      typename SystemType::residual_type & r,
	      typename SystemType::jacobian_type & J,
	      nonlinearsolvers::scalar_of_t<SystemType> alpha,
	      nonlinearsolvers::scalar_of_t<SystemType> beta,
	      nonlinearsolvers::scalar_of_t<SystemType> gamma,
	      LinearSolverType && linSolver)
  {
    { ::pressio::ops::norm2(std::as_const(a)) }
      -> std::same_as< nonlinearsolvers::scalar_of_t<SystemType> >;
    { ::pressio::ops::norm2(std::as_const(r)) }
      -> std::same_as< nonlinearsolvers::scalar_of_t<SystemType> >;

    { ::pressio::ops::deep_copy(b, std::as_const(a)) };
    { ::pressio::ops::scale (a, alpha) };
    { ::pressio::ops::update(a,	alpha, std::as_const(b), beta) };
    { ::pressio::ops::update(a,	alpha, std::as_const(b), beta, std::as_const(c), gamma) };

    { linSolver.solve(std::as_const(J), std::as_const(r), a) };
  }
#endif
auto create_newton_solver(const SystemType & system,
			  LinearSolverType && linSolver)

} //end namespace pressio

Parameters#

system

instance of your problem

linSolver

linear solver to use within each nonlinear iteration

Constraints#

Concepts are documented here. Note: constraints are enforced via proper C++20 concepts when PRESSIO_ENABLE_CXX20 is enabled, otherwise via SFINAE and static asserts.

Examples#

Demos

  1. full demo