NOX
Development
|
Observer that controls when to update the preconditioner for the Thyra interface. More...
#include <NOX_Observer_ReusePreconditioner.hpp>
Public Types | |
using | Scalar = double |
Public Member Functions | |
Initialization methods | |
void | setOperatorsAndFactory (const Teuchos::RCP<::Thyra::PreconditionerBase< Scalar >> &precOperator, const Teuchos::RCP<::Thyra::PreconditionerFactoryBase< Scalar >> &precFactory) |
Setup the preconditioner objects used to update the preconditioner. | |
void | updateAtStartOfSolve () |
Enables updating the preconditioner at the start of each nonlinear solve. | |
void | updateAfterNNonlinearSolves (const int num_nonlinear_solves_for_update, const bool reset_nonlinear_solve_count_on_failed_solve=true) |
Enables updating of the preconditioner after a set number of nonlinear solves. More... | |
void | updateAfterNIterations (const int num_iterations_for_update) |
Enables updating of the preconditioner after a set number of nonlinear iterations. More... | |
void | updateOnLinearSolverStall (const int max_linear_iterations, const int max_count) |
Enables updating of preconditioner if the observer detects a stall or failure in the linear solver. More... | |
Methods derived from NOX::Observer | |
void | runPreSolve (const NOX::Solver::Generic &solver) override |
User defined method that will be executed at the start of a call to NOX::Solver::Generic::solve(). | |
void | runPreIterate (const NOX::Solver::Generic &solver) override |
User defined method that will be executed at the start of a call to NOX::Solver::Generic::step(). | |
void | runPostIterate (const NOX::Solver::Generic &solver) override |
User defined method that will be executed at the end of a call to NOX::Solver::Generic::step(). | |
void | runPostSolve (const NOX::Solver::Generic &solver) override |
User defined method that will be executed at the end of a call to NOX::Solver::Generic::solve(). | |
Query methods used in unit testing | |
size_t | getNumPreconditionerUpdates () const |
Return the number of times the preconditioner has been updated. | |
size_t | getNumNonlinearSolvesCount () const |
Return the number of nonlinear solves that have been run. | |
Public Member Functions inherited from NOX::Observer | |
Observer () | |
Constructor. | |
virtual | ~Observer () |
Destructor. | |
virtual void | runPreSolutionUpdate (const NOX::Abstract::Vector &, const NOX::Solver::Generic &) |
User defined method that will be executed prior to the update of the solution vector during a call to NOX::Solver::Generic::step(). This is intended to allow users to adjust the direction before the solution update, typically based on knowledge of the problem formulation. The direction is const as we can't guarantee that changes to the direction won't violate assumptions of the solution algorithm. Users can change the update/direciton after a const cast, but NOX may not function as expected. Use at your own risk! More... | |
virtual void | runPostSolutionUpdate (const NOX::Solver::Generic &) |
User defined method that will be executed after the update of the solution vector during a call to NOX::Solver::Generic::step(). This is intended to allow users to adjust the direction after the solution update, typically based on knowledge of the problem formulation (e.g. clipping negative mass fractions). The direction is const as we can't guarantee that changes to the direction won't violate assumptions of the solution algorithm. Users can change the update/direciton after a const cast, but NOX may not function as expected. Use at your own risk! More... | |
virtual void | runPreLineSearch (const NOX::Solver::Generic &) |
User defined method that will be executed before a call to NOX::LineSearch::Generic::compute(). Only to be used in NOX::Solver::LineSearchBased! | |
virtual void | runPostLineSearch (const NOX::Solver::Generic &) |
User defined method that will be executed after a call to NOX::LineSearch::Generic::compute(). Only to be used in NOX::Solver::LineSearchBased! | |
Observer that controls when to update the preconditioner for the Thyra interface.
The preconditioner can be updated at the start of each new nonlinear solve and/or when convergence stalls out.
void NOX::ObserverReusePreconditioner::updateAfterNIterations | ( | const int | num_iterations_for_update | ) |
Enables updating of the preconditioner after a set number of nonlinear iterations.
[in] | num_iterations_for_update | (int) Updates the preconditioner after this number of nonlinear iterations. |
void NOX::ObserverReusePreconditioner::updateAfterNNonlinearSolves | ( | const int | num_nonlinear_solves_for_update, |
const bool | reset_nonlinear_solve_count_on_failed_solve = true |
||
) |
Enables updating of the preconditioner after a set number of nonlinear solves.
This is intended to reuse a preconditioner across all stages of an RK method in a single time step. The parameter should be set to the number of RK stages. If a nonlinear solve fails
[in] | num_nonlinear_solves_for_update | (int) Updates the preconditioner after this number of nonlinear iterations. |
[in] | reset_nonlinear_solve_count_on_faile_solve | (bool) If set to true, when a nonlinear solve fails, the nonlinear solve count will be reset. When a nonlinear solve fails in the middle of an RK stage, we assume a new time step will start for the next nonlinear solve. |
void NOX::ObserverReusePreconditioner::updateOnLinearSolverStall | ( | const int | max_linear_iterations, |
const int | max_count | ||
) |
Enables updating of preconditioner if the observer detects a stall or failure in the linear solver.
This algorithm tries to assess a stalled computation due to reusing the preconditioner. It will always recompute for a failed linear solve. It will also recompute if the last max_count number of iterations each had linear solves that took more iterations than max_linear_iterations.
[in] | max_linear_iterations | (int) Declare a stalled iteraiton if the number of linear solver iterations is above this value |
[in] | max_count | (int) Recompute the preconditioner after this many stalled iterations |