Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
PhysicsSolverStrategy< VectorType > Class Template Referenceabstract

#include <physics_solver_strategy.h>

Inheritance diagram for PhysicsSolverStrategy< VectorType >:
[legend]

Public Member Functions

 PhysicsSolverStrategy (PhysicsSolver< VectorType > *physics_solver, const Parameters::NonLinearSolver &params)
 PhysicsSolverStrategy (PhysicsSolver< VectorType > *physics_solver)
virtual ~PhysicsSolverStrategy ()=default
virtual void solve ()=0
unsigned int get_current_newton_iteration () const

Protected Member Functions

bool skip_linear_solve_if_fresh_rhs_is_already_converged (const bool rhs_was_assembled_this_iteration, const double rescale_metric, double &current_res, double &last_res, double &global_res)

Protected Attributes

PhysicsSolver< VectorType > * physics_solver
Parameters::NonLinearSolver params
unsigned int outer_iteration

Detailed Description

template<typename VectorType>
class PhysicsSolverStrategy< VectorType >

Base class that works as an interface for all solver strategies (either non-linear or linear) for all systems of equations.

Definition at line 19 of file physics_solver_strategy.h.

Constructor & Destructor Documentation

◆ PhysicsSolverStrategy() [1/2]

template<typename VectorType>
PhysicsSolverStrategy< VectorType >::PhysicsSolverStrategy ( PhysicsSolver< VectorType > * physics_solver,
const Parameters::NonLinearSolver & params )

Constructor for the non-linear solver strategies.

Parameters
[in]physics_solverA pointer to the physics solver to which the solving strategy is attached.
[in]paramNon-linear solver parameters as specified in the simulation parameter file.

Definition at line 126 of file physics_solver_strategy.h.

References outer_iteration, params, and physics_solver.

◆ PhysicsSolverStrategy() [2/2]

template<typename VectorType>
PhysicsSolverStrategy< VectorType >::PhysicsSolverStrategy ( PhysicsSolver< VectorType > * physics_solver)

Constructor for the linear solver strategy.

Parameters
[in]physics_solverA pointer to the physics solver to which the solving strategy is attached.

Definition at line 135 of file physics_solver_strategy.h.

References physics_solver.

◆ ~PhysicsSolverStrategy()

template<typename VectorType>
virtual PhysicsSolverStrategy< VectorType >::~PhysicsSolverStrategy ( )
virtualdefault

Destructor.

Member Function Documentation

◆ get_current_newton_iteration()

template<typename VectorType>
unsigned int PhysicsSolverStrategy< VectorType >::get_current_newton_iteration ( ) const
inline

Get the current newton iteration.

Returns
Iteration number.

Definition at line 65 of file physics_solver_strategy.h.

References outer_iteration.

◆ skip_linear_solve_if_fresh_rhs_is_already_converged()

template<typename VectorType>
bool PhysicsSolverStrategy< VectorType >::skip_linear_solve_if_fresh_rhs_is_already_converged ( const bool rhs_was_assembled_this_iteration,
const double rescale_metric,
double & current_res,
double & last_res,
double & global_res )
protected

Skip the inner linear solve when the current Newton evaluation already produced a freshly assembled RHS whose residual is below the nonlinear tolerance.

This shortcut is only valid when the RHS was assembled for the current evaluation point. Otherwise the residual may still correspond to an older state and skipping the solve would incorrectly reuse stale information.

Solvers must opt into this behavior explicitly through allow_skip_linear_solve_when_residual_is_below_tolerance(). The shortcut is always safe on Newton iteration 0 because the RHS is assembled unconditionally there. On later Newton iterations, it requires force_rhs_calculation so that the converged residual comes from a fresh RHS assembled at the current Newton evaluation point.

Parameters
[in]rhs_was_assembled_this_iterationWhether the current Newton iteration assembled the RHS at the current evaluation point.
[in]rescale_metricResidual rescaling factor used by the nonlinear solver strategy.
[in,out]current_resCurrent matrix residual norm.
[in,out]last_resLast accepted matrix residual norm.
[in,out]global_resCurrent nonlinear residual reported by the physics solver.
Returns
true if the linear solve was skipped and the Newton state was advanced consistently, false otherwise.

Definition at line 142 of file physics_solver_strategy.h.

References PhysicsSolver< VectorType >::allow_skip_linear_solve_when_residual_is_below_tolerance(), PhysicsSolver< VectorType >::get_current_residual(), PhysicsSolver< VectorType >::get_evaluation_point(), PhysicsSolver< VectorType >::get_newton_update(), PhysicsSolver< VectorType >::get_present_solution(), PhysicsSolver< VectorType >::get_system_rhs(), outer_iteration, params, and physics_solver.

◆ solve()

Member Data Documentation

◆ outer_iteration

template<typename VectorType>
unsigned int PhysicsSolverStrategy< VectorType >::outer_iteration
protected

Number of current Newton iteration.

Definition at line 122 of file physics_solver_strategy.h.

◆ params

Non linear solver parameters.

Definition at line 116 of file physics_solver_strategy.h.

◆ physics_solver

template<typename VectorType>
PhysicsSolver<VectorType>* PhysicsSolverStrategy< VectorType >::physics_solver
protected

Physics solver for which we need a non-linear solver.

Definition at line 110 of file physics_solver_strategy.h.


The documentation for this class was generated from the following file: