SOFA API  cb3b2882
Open source framework for multi-physics simuation
sofa::component::odesolver::backward::newton_raphson::BaseNonLinearFunction Class Referenceabstract

#include <NonLinearFunction.h>

Inheritance diagram for sofa::component::odesolver::backward::newton_raphson::BaseNonLinearFunction:

Detailed Description

Base class of a representation of a nonlinear function in the context of the resolution of a nonlinear (system of) equation(s) with the Newton-Raphson method.

In the objective to be very generic, the computations required by the Newton-Raphson are defined inside @BaseNonLinearFunction. For example, a Newton iteration requires to solve a linear equation that can be solved using a linear solver in the case of a system of equations, or by a scalar inversion in the case of a scalar equation. The only required interaction with the outside is the squared norm of the last evaluation.

If r is the nonlinear function, a Newton iteration leads to the following linear equation: J_r (x^{i+1} - x^i) = -r(x^i) where J_r is the Jacobian of r and x^i is the current guess of r at iteration i.

Public Member Functions

virtual ~BaseNonLinearFunction ()=default
 
virtual void startNewtonIteration ()
 
virtual void endNewtonIteration ()
 
virtual void evaluateCurrentGuess ()=0
 
virtual SReal squaredNormLastEvaluation ()=0
 
virtual void computeGradientFromCurrentGuess ()=0
 
virtual void solveLinearEquation ()=0
 
virtual void updateGuessFromLinearSolution (SReal alpha)=0
 
virtual SReal squaredNormDx ()=0
 
virtual SReal squaredLastEvaluation ()=0
 

Constructor details

◆ ~BaseNonLinearFunction()

virtual sofa::component::odesolver::backward::newton_raphson::BaseNonLinearFunction::~BaseNonLinearFunction ( )
virtualdefault

Function details

◆ computeGradientFromCurrentGuess()

virtual void sofa::component::odesolver::backward::newton_raphson::BaseNonLinearFunction::computeGradientFromCurrentGuess ( )
pure virtual

Compute the gradient internally. It is not necessary to share this gradient with the outside

Implemented in sofa::component::odesolver::backward::StaticResidualFunction, and sofa::component::odesolver::backward::ResidualFunction.

◆ endNewtonIteration()

virtual void sofa::component::odesolver::backward::newton_raphson::BaseNonLinearFunction::endNewtonIteration ( )
inlinevirtual

◆ evaluateCurrentGuess()

virtual void sofa::component::odesolver::backward::newton_raphson::BaseNonLinearFunction::evaluateCurrentGuess ( )
pure virtual

Evaluation of the function where the input is the current guess. If the function is called for the first time, then it is called on the initial guess. The evaluation is computed internally. It is not necessary to share this evaluation with the outside.

Implemented in sofa::component::odesolver::backward::StaticResidualFunction, and sofa::component::odesolver::backward::ResidualFunction.

◆ solveLinearEquation()

virtual void sofa::component::odesolver::backward::newton_raphson::BaseNonLinearFunction::solveLinearEquation ( )
pure virtual

Solve the linear equation from a Newton iteration, i.e. it computes (x^{i+1}-x^i). It is solved internally. It is not necessary to share the result with the outside

Implemented in sofa::component::odesolver::backward::StaticResidualFunction, and sofa::component::odesolver::backward::ResidualFunction.

◆ squaredLastEvaluation()

virtual SReal sofa::component::odesolver::backward::newton_raphson::BaseNonLinearFunction::squaredLastEvaluation ( )
pure virtual

◆ squaredNormDx()

virtual SReal sofa::component::odesolver::backward::newton_raphson::BaseNonLinearFunction::squaredNormDx ( )
pure virtual

◆ squaredNormLastEvaluation()

virtual SReal sofa::component::odesolver::backward::newton_raphson::BaseNonLinearFunction::squaredNormLastEvaluation ( )
pure virtual

Returns the squared norm of the last evaluation of the function

Implemented in sofa::component::odesolver::backward::StaticResidualFunction, and sofa::component::odesolver::backward::ResidualFunction.

◆ startNewtonIteration()

virtual void sofa::component::odesolver::backward::newton_raphson::BaseNonLinearFunction::startNewtonIteration ( )
inlinevirtual

◆ updateGuessFromLinearSolution()

virtual void sofa::component::odesolver::backward::newton_raphson::BaseNonLinearFunction::updateGuessFromLinearSolution ( SReal  alpha)
pure virtual

Once (x^{i+1}-x^i) has been computed, the result is used internally to update the current guess. It computes x^{i+1} += alpha * dx, where dx is the result of the linear system. It is not necessary to share the result with the Newton-Raphson method.

Implemented in sofa::component::odesolver::backward::StaticResidualFunction, and sofa::component::odesolver::backward::ResidualFunction.