SOFA API  83276a98
Open source framework for multi-physics simuation
sofa::component::odesolver::backward::ResidualFunction Struct Reference
Inheritance diagram for sofa::component::odesolver::backward::ResidualFunction:

Detailed Description

Represent the mathematical function to be solved by a Newton-Raphson solver. See documentation of @BaseNonLinearFunction

The function is r(x) = [r1(x), r2(x)] with x = [position, velocity] r_1(x) = \sum_{j=0}^s a_j \text{position}_j - h \sum_{j=0}^s b_j \text{velocity}_j r_2(x) = \sum_{j=0}^s a_j M \text{velocity}_j - h \sum_{j=0}^s b_j \text{force}_j

Public Attributes

std::size_t order = 1
 
sofa::type::vector< SReal > a_coef
 
sofa::type::vector< SReal > b_coef
 
SReal dt = 0
 
SReal rayleighStiffness = 0
 
SReal rayleighMass = 0
 
sofa::simulation::common::MechanicalOperationsmop
 
simulation::common::VectorOperationsvop
 
sofa::type::vector< core::MultiVecCoordIdposition
 
sofa::type::vector< core::MultiVecDerivIdvelocity
 
sofa::type::vector< core::MultiVecDerivIdforce
 
core::MultiVecDerivId r1
 
core::MultiVecDerivId r2
 
core::MultiVecDerivId dx
 
core::MultiVecDerivId dv
 
core::MultiVecDerivId rhs
 
core::behavior::LinearSolverlinearSolver { nullptr }
 

Public Member Functions

void evaluateCurrentGuess () override
 
SReal squaredNormLastEvaluation () override
 
void computeGradientFromCurrentGuess () override
 
void updateGuessFromLinearSolution (SReal alpha) override
 
void solveLinearEquation () override
 
void computeDxFromDv ()
 
SReal squaredNormDx () override
 
SReal squaredLastEvaluation () override
 
 ResidualFunction (sofa::simulation::common::MechanicalOperations &mop, simulation::common::VectorOperations &vop)
 
- Public Member Functions inherited from sofa::component::odesolver::backward::newton_raphson::BaseNonLinearFunction
virtual ~BaseNonLinearFunction ()=default
 
virtual void startNewtonIteration ()
 
virtual void endNewtonIteration ()
 

Attribute details

◆ a_coef

sofa::type::vector<SReal> sofa::component::odesolver::backward::ResidualFunction::a_coef

◆ b_coef

sofa::type::vector<SReal> sofa::component::odesolver::backward::ResidualFunction::b_coef

◆ dt

SReal sofa::component::odesolver::backward::ResidualFunction::dt = 0

◆ dv

core::MultiVecDerivId sofa::component::odesolver::backward::ResidualFunction::dv

◆ dx

core::MultiVecDerivId sofa::component::odesolver::backward::ResidualFunction::dx

◆ force

sofa::type::vector<core::MultiVecDerivId> sofa::component::odesolver::backward::ResidualFunction::force

◆ linearSolver

core::behavior::LinearSolver* sofa::component::odesolver::backward::ResidualFunction::linearSolver { nullptr }

◆ mop

sofa::simulation::common::MechanicalOperations& sofa::component::odesolver::backward::ResidualFunction::mop

◆ order

std::size_t sofa::component::odesolver::backward::ResidualFunction::order = 1

◆ position

sofa::type::vector<core::MultiVecCoordId> sofa::component::odesolver::backward::ResidualFunction::position

◆ r1

core::MultiVecDerivId sofa::component::odesolver::backward::ResidualFunction::r1

◆ r2

core::MultiVecDerivId sofa::component::odesolver::backward::ResidualFunction::r2

◆ rayleighMass

SReal sofa::component::odesolver::backward::ResidualFunction::rayleighMass = 0

◆ rayleighStiffness

SReal sofa::component::odesolver::backward::ResidualFunction::rayleighStiffness = 0

◆ rhs

core::MultiVecDerivId sofa::component::odesolver::backward::ResidualFunction::rhs

◆ velocity

sofa::type::vector<core::MultiVecDerivId> sofa::component::odesolver::backward::ResidualFunction::velocity

◆ vop

simulation::common::VectorOperations& sofa::component::odesolver::backward::ResidualFunction::vop

Constructor details

◆ ResidualFunction()

sofa::component::odesolver::backward::ResidualFunction::ResidualFunction ( sofa::simulation::common::MechanicalOperations mop,
simulation::common::VectorOperations vop 
)
inline

Function details

◆ computeDxFromDv()

void sofa::component::odesolver::backward::ResidualFunction::computeDxFromDv ( )
inline

◆ computeGradientFromCurrentGuess()

void sofa::component::odesolver::backward::ResidualFunction::computeGradientFromCurrentGuess ( )
inlineoverridevirtual

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

Implements sofa::component::odesolver::backward::newton_raphson::BaseNonLinearFunction.

◆ evaluateCurrentGuess()

void sofa::component::odesolver::backward::ResidualFunction::evaluateCurrentGuess ( )
inlineoverridevirtual

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.

Implements sofa::component::odesolver::backward::newton_raphson::BaseNonLinearFunction.

◆ solveLinearEquation()

void sofa::component::odesolver::backward::ResidualFunction::solveLinearEquation ( )
inlineoverridevirtual

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

Implements sofa::component::odesolver::backward::newton_raphson::BaseNonLinearFunction.

◆ squaredLastEvaluation()

SReal sofa::component::odesolver::backward::ResidualFunction::squaredLastEvaluation ( )
inlineoverridevirtual

◆ squaredNormDx()

SReal sofa::component::odesolver::backward::ResidualFunction::squaredNormDx ( )
inlineoverridevirtual

◆ squaredNormLastEvaluation()

SReal sofa::component::odesolver::backward::ResidualFunction::squaredNormLastEvaluation ( )
inlineoverridevirtual

Returns the squared norm of the last evaluation of the function

Implements sofa::component::odesolver::backward::newton_raphson::BaseNonLinearFunction.

◆ updateGuessFromLinearSolution()

void sofa::component::odesolver::backward::ResidualFunction::updateGuessFromLinearSolution ( SReal  alpha)
inlineoverridevirtual

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.

Implements sofa::component::odesolver::backward::newton_raphson::BaseNonLinearFunction.