![]() |
OGS
|
|
Find a solution to a nonlinear equation using the Newton-Raphson method.
Definition at line 69 of file NonlinearSolver.h.
#include <NonlinearSolver.h>
Public Types | |
| using | System = NonlinearSystem<NonlinearSolverTag::Newton> |
| Type of the nonlinear equation system to be solved. | |
Public Member Functions | |
| NonlinearSolver (GlobalLinearSolver &linear_solver, int const maxiter, int const recompute_jacobian=1, double const damping=1.0, std::optional< double > const damping_reduction=std::nullopt) | |
| ~NonlinearSolver () | |
| void | setEquationSystem (System &eq, ConvergenceCriterion &conv_crit) |
| void | calculateNonEquilibriumInitialResiduum (std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, int const process_id) override |
| NonlinearSolverStatus | solve (std::vector< GlobalVector * > &x, std::vector< GlobalVector * > const &x_prev, std::function< void(int, bool, std::vector< GlobalVector * > const &)> const &postIterationCallback, int const process_id) override |
| void | compensateNonEquilibriumInitialResiduum (bool const value) |
| Public Member Functions inherited from NumLib::NonlinearSolverBase | |
| virtual | ~NonlinearSolverBase ()=default |
Private Attributes | |
| GlobalLinearSolver & | _linear_solver |
| System * | _equation_system = nullptr |
| ConvergenceCriterion * | _convergence_criterion = nullptr |
| int const | _maxiter |
| maximum number of iterations | |
| int const | _recompute_jacobian = 1 |
| double const | _damping |
| std::optional< double > const | _damping_reduction |
| GlobalVector * | _r_neq = nullptr |
| non-equilibrium initial residuum. | |
| std::size_t | _res_id = 0u |
| ID of the residual vector. | |
| std::size_t | _J_id = 0u |
| ID of the Jacobian matrix. | |
| std::size_t | _minus_delta_x_id = 0u |
| ID of the \( -\Delta x\) vector. | |
| std::size_t | _x_new_id |
| ID of the vector storing \( x - (-\Delta x) \). | |
| std::size_t | _r_neq_id = 0u |
| bool | _compensate_non_equilibrium_initial_residuum = false |
| using NumLib::NonlinearSolver< NonlinearSolverTag::Newton >::System = NonlinearSystem<NonlinearSolverTag::Newton> |
Type of the nonlinear equation system to be solved.
Definition at line 74 of file NonlinearSolver.h.
|
inlineexplicit |
Constructs a new instance.
| linear_solver | the linear solver used by this nonlinear solver. |
| maxiter | the maximum number of iterations used to solve the equation. |
| recompute_jacobian | recompute jacobian for the follow-up steps |
| damping | A positive damping factor. |
| damping_reduction | A parameter that reduces damping |
Definition at line 87 of file NonlinearSolver.h.
References _damping, _damping_reduction, _linear_solver, _maxiter, and _recompute_jacobian.
Referenced by ~NonlinearSolver(), calculateNonEquilibriumInitialResiduum(), and solve().
Definition at line 630 of file NonlinearSolver.cpp.
References NonlinearSolver(), _r_neq, and NumLib::GlobalVectorProvider::provider.
|
overridevirtual |
Implements NumLib::NonlinearSolverBase.
Definition at line 315 of file NonlinearSolver.cpp.
References NonlinearSolver(), _compensate_non_equilibrium_initial_residuum, _equation_system, _r_neq, _r_neq_id, MathLib::LinAlg::finalizeAssembly(), INFO(), and NumLib::GlobalVectorProvider::provider.
|
inline |
Definition at line 123 of file NonlinearSolver.h.
References _compensate_non_equilibrium_initial_residuum.
|
inline |
Set the nonlinear equation system that will be solved. TODO doc
Definition at line 105 of file NonlinearSolver.h.
References _convergence_criterion, and _equation_system.
|
overridevirtual |
Assemble and solve the equation system.
| x | in: the initial guess, out: the solution. |
| x_prev | previous time step solution. |
| postIterationCallback | called after each iteration if set. |
| process_id | usually used in staggered schemes. |
| true | if the equation system could be solved |
| false | otherwise |
Implements NumLib::NonlinearSolverBase.
Definition at line 344 of file NonlinearSolver.cpp.
References NonlinearSolver(), _convergence_criterion, _damping, _damping_reduction, _equation_system, _J_id, _linear_solver, _maxiter, _minus_delta_x_id, _r_neq, _recompute_jacobian, _res_id, _x_new_id, BaseLib::MPI::anyOf(), MathLib::LinAlg::axpy(), MathLib::LinAlg::copy(), BaseLib::RunTime::elapsed(), ERR(), NumLib::FAILURE, INFO(), NumLib::GlobalMatrixProvider::provider, NumLib::GlobalVectorProvider::provider, MathLib::RECOMPUTE_AND_STORE, NumLib::REPEAT_ITERATION, MathLib::REUSE, BaseLib::RunTime::start(), and NumLib::SUCCESS.
|
private |
Enables computation of the non-equilibrium initial residuum \( r_{\rm neq} \) before the first time step. The forces are zero if the external forces are in equilibrium with the initial state/initial conditions. During the simulation the new residuum reads \( \tilde r = r - r_{\rm neq} \).
Definition at line 163 of file NonlinearSolver.h.
Referenced by calculateNonEquilibriumInitialResiduum(), and compensateNonEquilibriumInitialResiduum().
|
private |
Definition at line 133 of file NonlinearSolver.h.
Referenced by setEquationSystem(), and solve().
|
private |
A positive damping factor. The default value 1.0 gives a non-damped Newton method. Common values are in the range 0.5 to 0.7 for somewhat conservative method and seldom become smaller than 0.2 for very conservative approach.
Definition at line 142 of file NonlinearSolver.h.
Referenced by NonlinearSolver(), and solve().
|
private |
A parameter that reduces the damping by iteration / _damping_reduction If the expression is smaller than zero, then damping is the same for all iterations. If the expression is bigger than one it is clamped by one.
Definition at line 147 of file NonlinearSolver.h.
Referenced by NonlinearSolver(), and solve().
|
private |
Definition at line 130 of file NonlinearSolver.h.
Referenced by calculateNonEquilibriumInitialResiduum(), setEquationSystem(), and solve().
|
private |
|
private |
Definition at line 129 of file NonlinearSolver.h.
Referenced by NonlinearSolver(), and solve().
|
private |
maximum number of iterations
Definition at line 134 of file NonlinearSolver.h.
Referenced by NonlinearSolver(), and solve().
|
private |
ID of the \( -\Delta x\) vector.
Definition at line 152 of file NonlinearSolver.h.
Referenced by solve().
|
private |
non-equilibrium initial residuum.
Definition at line 149 of file NonlinearSolver.h.
Referenced by ~NonlinearSolver(), calculateNonEquilibriumInitialResiduum(), and solve().
|
private |
ID of the non-equilibrium initial residuum vector.
Definition at line 155 of file NonlinearSolver.h.
Referenced by calculateNonEquilibriumInitialResiduum().
|
private |
Definition at line 136 of file NonlinearSolver.h.
Referenced by NonlinearSolver(), and solve().
|
private |
|
private |
ID of the vector storing \( x - (-\Delta x) \).
Definition at line 153 of file NonlinearSolver.h.
Referenced by solve().