NOX Development
Loading...
Searching...
No Matches
NOX::Solver::SingleStep Class Reference

Light wrapper over linear solver, executes exactly one iteration. More...

#include <NOX_Solver_SingleStep.H>

Inheritance diagram for NOX::Solver::SingleStep:
Collaboration diagram for NOX::Solver::SingleStep:

Public Member Functions

 SingleStep (const Teuchos::RCP< NOX::Abstract::Group > &grp, const Teuchos::RCP< Teuchos::ParameterList > &params)
virtual void reset ()
 Resets the solver for another solve. This resets the counters and status only. Uses the final solution from the last solve as the initial guess for the next solve.
virtual void reset (const NOX::Abstract::Vector &initial_guess)
 Resets the solver and sets a new initial guess.
virtual void reset (const NOX::Abstract::Vector &initial_guess, const Teuchos::RCP< NOX::StatusTest::Generic > &test)
 Resets the solver, sets a new status test, and sets a new initial guess.
virtual NOX::StatusTest::StatusType step ()
 Do one nonlinear step in the iteration sequence and return status.
virtual NOX::StatusTest::StatusType solve ()
 Solve the nonlinear problem and return final status.
virtual const NOX::Abstract::GroupgetSolutionGroup () const
 Return a reference to the current solution group.
virtual Teuchos::RCP< const NOX::Abstract::GroupgetSolutionGroupPtr () const
 Return a RCP to the solution group.
virtual const NOX::Abstract::GroupgetPreviousSolutionGroup () const
 Return a reference to the previous solution group.
virtual Teuchos::RCP< const NOX::Abstract::GroupgetPreviousSolutionGroupPtr () const
 Return a RCP to the previous solution group.
virtual NOX::StatusTest::StatusType getStatus () const
 Returns the current status of the solver.
virtual int getNumIterations () const
 Get number of iterations.
virtual const Teuchos::ParameterList & getList () const
 Return a reference to the solver parameters.
virtual Teuchos::RCP< const Teuchos::ParameterList > getListPtr () const
 Return a RCP to the solver parameters.
virtual Teuchos::RCP< const NOX::SolverStatsgetSolverStatistics () const
 Return a RCP to the solver statistics.
Public Member Functions inherited from NOX::Solver::Generic
 Generic ()
 Constructor (does nothing).
virtual ~Generic ()
 Destructor (does nothing).

Protected Member Functions

virtual void init ()
 Print out initialization information and calcuation the RHS.
virtual void printUpdate ()
 Prints some status information.
bool check (Abstract::Group::ReturnType ret, const std::string &task)
 Prints some status information.
bool try_step ()
 Prints some status information.

Protected Attributes

Teuchos::RCP< NOX::GlobalDataglobalDataPtr
 Pointer to the global data object.
Teuchos::RCP< NOX::UtilsutilsPtr
 Utils.
Teuchos::RCP< NOX::Abstract::GroupsolnPtr
 Current solution.
Teuchos::RCP< NOX::Abstract::GroupoldSolnPtr
 Previous solution pointer.
Teuchos::RCP< Teuchos::ParameterList > paramsPtr
 Input parameters.
int nIter
 Number of nonlinear iterations.
NOX::StatusTest::StatusType status
 Status of nonlinear solver.
Teuchos::RCP< NOX::Observerobserver
 Pointer to a user defined NOX::Observer object.
bool ignoreLinearSolverFailures
 If set to true, the return status of the linear solver is ignored, step is declared a success.
bool updateJacobian
 If set to true, the Jacobian is computed at the beginning of each nonlinear iteration.
bool printNorms
 Print the norms of residual (F) and update (dx).
bool computeRelativeNorm
 If print norms is enabled, this will also compute the relative norm, $||F||/||F_0||$.
double normF_0
 Initial residual norm used for computing the relative norm.
Teuchos::RCP< NOX::Abstract::GroupfrozenJacobianPtr
 Group that contains the "frozen Jacobian" if updateJacobian is false.

Detailed Description

Light wrapper over linear solver, executes exactly one iteration.

This class exists to support applications which always instantiate a NOX Nonlinear solver via the NOX::Solver::Factory, but may be used to solve known linear problems. In that case, it is convenient to create a NOX::Solver object which requires no status tests and simply executes the linear solver.

Valid parameters in the ParameterList are:

Parameters
[in]Ignore Linear Solver Failure(bool) - If set to true, ignore the linear solver status. This is used for iterative methods where the requested tolerance was not explicitly met, but the solve might still be good enough to use. Defaults to false.
[in]Update Jacobian- If set to true, the Jacobian is computed at the beginning of each nonlinear iteration. In some use cases, we may want to reuse the Jacobian matrix (i.e. only the RHS is changing). Defaults to true.
[in]Print Norms- If set to true, the step output will print the residual norm and update norm.
[in]Print Relative Norm- If set to true, this will cache the initial residual norm and if "Print Norms" is enabled, will also print the ratio of initial to final norm for the step.

Member Function Documentation

◆ check()

bool NOX::Solver::SingleStep::check ( Abstract::Group::ReturnType ret,
const std::string & task )
protected

Prints some status information.

References NOX::Utils::Error, NOX::Abstract::Group::Ok, and utilsPtr.

Referenced by try_step().

◆ getList()

const Teuchos::ParameterList & NOX::Solver::SingleStep::getList ( ) const
virtual

Return a reference to the solver parameters.

Implements NOX::Solver::Generic.

References paramsPtr.

◆ getListPtr()

Teuchos::RCP< const Teuchos::ParameterList > NOX::Solver::SingleStep::getListPtr ( ) const
virtual

Return a RCP to the solver parameters.

Implements NOX::Solver::Generic.

References paramsPtr.

◆ getNumIterations()

int NOX::Solver::SingleStep::getNumIterations ( ) const
virtual

Get number of iterations.

Implements NOX::Solver::Generic.

References nIter.

◆ getPreviousSolutionGroup()

const NOX::Abstract::Group & NOX::Solver::SingleStep::getPreviousSolutionGroup ( ) const
virtual

Return a reference to the previous solution group.

Implements NOX::Solver::Generic.

References oldSolnPtr.

◆ getPreviousSolutionGroupPtr()

Teuchos::RCP< const NOX::Abstract::Group > NOX::Solver::SingleStep::getPreviousSolutionGroupPtr ( ) const
virtual

Return a RCP to the previous solution group.

Implements NOX::Solver::Generic.

References oldSolnPtr.

◆ getSolutionGroup()

const NOX::Abstract::Group & NOX::Solver::SingleStep::getSolutionGroup ( ) const
virtual

Return a reference to the current solution group.

Implements NOX::Solver::Generic.

References solnPtr.

◆ getSolutionGroupPtr()

Teuchos::RCP< const NOX::Abstract::Group > NOX::Solver::SingleStep::getSolutionGroupPtr ( ) const
virtual

Return a RCP to the solution group.

Implements NOX::Solver::Generic.

References solnPtr.

◆ getSolverStatistics()

Teuchos::RCP< const NOX::SolverStats > NOX::Solver::SingleStep::getSolverStatistics ( ) const
virtual

Return a RCP to the solver statistics.

Implements NOX::Solver::Generic.

References globalDataPtr.

◆ getStatus()

NOX::StatusTest::StatusType NOX::Solver::SingleStep::getStatus ( ) const
virtual

Returns the current status of the solver.

Implements NOX::Solver::Generic.

References status.

◆ init()

void NOX::Solver::SingleStep::init ( )
protectedvirtual

Print out initialization information and calcuation the RHS.

References NOX::Utils::fill(), globalDataPtr, nIter, NOX::Utils::Parameters, paramsPtr, status, NOX::StatusTest::Unconverged, and utilsPtr.

◆ printUpdate()

void NOX::Solver::SingleStep::printUpdate ( )
protectedvirtual

◆ reset() [1/3]

void NOX::Solver::SingleStep::reset ( )
virtual

Resets the solver for another solve. This resets the counters and status only. Uses the final solution from the last solve as the initial guess for the next solve.

NOTE: All NOX solvers will call reset() automatically at teh beginning of the solve() method. We add the reset() method to the solver interface for the application to call in case the application needs to reset counters and status manually before the next call to solve() is made.

Implements NOX::Solver::Generic.

References globalDataPtr, nIter, status, and NOX::StatusTest::Unconverged.

Referenced by solve().

◆ reset() [2/3]

void NOX::Solver::SingleStep::reset ( const NOX::Abstract::Vector & initial_guess)
virtual

Resets the solver and sets a new initial guess.

Implements NOX::Solver::Generic.

References globalDataPtr, nIter, solnPtr, status, and NOX::StatusTest::Unconverged.

◆ reset() [3/3]

void NOX::Solver::SingleStep::reset ( const NOX::Abstract::Vector & initial_guess,
const Teuchos::RCP< NOX::StatusTest::Generic > & test )
virtual

Resets the solver, sets a new status test, and sets a new initial guess.

Implements NOX::Solver::Generic.

References globalDataPtr, nIter, solnPtr, status, and NOX::StatusTest::Unconverged.

◆ solve()

NOX::StatusTest::StatusType NOX::Solver::SingleStep::solve ( )
virtual

Solve the nonlinear problem and return final status.

By "solve", we call iterate() until the NOX::StatusTest value is either NOX::StatusTest::Converged or NOX::StatusTest::Failed.

Implements NOX::Solver::Generic.

References observer, reset(), status, and step().

◆ step()

NOX::StatusTest::StatusType NOX::Solver::SingleStep::step ( )
virtual

Do one nonlinear step in the iteration sequence and return status.

Implements NOX::Solver::Generic.

References NOX::StatusTest::Converged, NOX::StatusTest::Failed, globalDataPtr, nIter, observer, oldSolnPtr, printUpdate(), solnPtr, status, and try_step().

Referenced by solve().

◆ try_step()

bool NOX::Solver::SingleStep::try_step ( )
protected

Member Data Documentation

◆ computeRelativeNorm

bool NOX::Solver::SingleStep::computeRelativeNorm
protected

If print norms is enabled, this will also compute the relative norm, $||F||/||F_0||$.

Referenced by printUpdate(), and try_step().

◆ frozenJacobianPtr

Teuchos::RCP<NOX::Abstract::Group> NOX::Solver::SingleStep::frozenJacobianPtr
protected

Group that contains the "frozen Jacobian" if updateJacobian is false.

Referenced by try_step().

◆ globalDataPtr

Teuchos::RCP<NOX::GlobalData> NOX::Solver::SingleStep::globalDataPtr
protected

Pointer to the global data object.

Referenced by getSolverStatistics(), init(), reset(), reset(), reset(), step(), and try_step().

◆ ignoreLinearSolverFailures

bool NOX::Solver::SingleStep::ignoreLinearSolverFailures
protected

If set to true, the return status of the linear solver is ignored, step is declared a success.

Referenced by try_step().

◆ nIter

int NOX::Solver::SingleStep::nIter
protected

Number of nonlinear iterations.

Referenced by getNumIterations(), init(), reset(), reset(), reset(), and step().

◆ normF_0

double NOX::Solver::SingleStep::normF_0
protected

Initial residual norm used for computing the relative norm.

Referenced by printUpdate(), and try_step().

◆ observer

Teuchos::RCP<NOX::Observer> NOX::Solver::SingleStep::observer
protected

Pointer to a user defined NOX::Observer object.

Referenced by solve(), step(), and try_step().

◆ oldSolnPtr

Teuchos::RCP<NOX::Abstract::Group> NOX::Solver::SingleStep::oldSolnPtr
protected

Previous solution pointer.

Referenced by getPreviousSolutionGroup(), getPreviousSolutionGroupPtr(), step(), and try_step().

◆ paramsPtr

Teuchos::RCP<Teuchos::ParameterList> NOX::Solver::SingleStep::paramsPtr
protected

Input parameters.

Referenced by getList(), getListPtr(), init(), and try_step().

◆ printNorms

bool NOX::Solver::SingleStep::printNorms
protected

Print the norms of residual (F) and update (dx).

Referenced by printUpdate().

◆ solnPtr

Teuchos::RCP<NOX::Abstract::Group> NOX::Solver::SingleStep::solnPtr
protected

◆ status

NOX::StatusTest::StatusType NOX::Solver::SingleStep::status
protected

Status of nonlinear solver.

Referenced by getStatus(), init(), printUpdate(), reset(), reset(), reset(), solve(), and step().

◆ updateJacobian

bool NOX::Solver::SingleStep::updateJacobian
protected

If set to true, the Jacobian is computed at the beginning of each nonlinear iteration.

Referenced by try_step().

◆ utilsPtr

Teuchos::RCP<NOX::Utils> NOX::Solver::SingleStep::utilsPtr
protected

Utils.

Referenced by check(), init(), and printUpdate().


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