NOX::Epetra::Group Class Reference

Concrete implementation of NOX::Abstract::Group for Trilinos/Epetra. More...

#include <NOX_Epetra_Group.H>

Inheritance diagram for NOX::Epetra::Group:

[legend]
Collaboration diagram for NOX::Epetra::Group:
[legend]
List of all members.

Public Types

enum  OperatorType {
  None, EpetraOperator, EpetraRowMatrix, NoxOperator,
  NoxFiniteDifferenceRowMatrix, NoxMatrixFreeOperator
}
 List of types of operators that can be used for the Jacobian and/or Preconditioner. More...

Public Member Functions

 Group (NOX::Parameter::List &printingParams, NOX::Parameter::List &linearSolverParams, NOX::Epetra::Interface &i, Epetra_Vector &x, Epetra_Operator &J)
 Constructor with Jacobian Operator only.
 Group (NOX::Parameter::List &printingParams, NOX::Parameter::List &linearSolverParams, NOX::Epetra::Interface &i, NOX::Epetra::Vector &x, Epetra_Operator &J)
 Constructor with Jacobian Operator only.
 Group (NOX::Parameter::List &printingParams, NOX::Parameter::List &linearSolverParams, NOX::Epetra::Interface &i, Epetra_Vector &x, Epetra_Operator &J, Epetra_Operator &M)
 Group (NOX::Parameter::List &printingParams, NOX::Parameter::List &linearSolverParams, NOX::Epetra::Interface &i, NOX::Epetra::Vector &x, Epetra_Operator &J, Epetra_Operator &M)
 Group (const NOX::Epetra::Group &source, NOX::CopyType type=NOX::DeepCopy)
 Copy constructor. If type is DeepCopy, takes ownership of valid shared Jacobian and shared preconditioning matrix.
virtual ~Group ()
 Destructor.
virtual NOX::Abstract::Groupoperator= (const NOX::Abstract::Group &source)
 Copies the source group into this group.
virtual NOX::Abstract::Groupoperator= (const NOX::Epetra::Group &source)
 See operator=(const NOX::Abstract::Group&);.
virtual NOX::Abstract::Groupclone (CopyType type=DeepCopy) const
virtual NOX::Epetra::SharedOperatorgetSharedJacobian ()
 Return the SharedJacobian.
virtual NOX::Epetra::SharedOperatorgetSharedPreconditioner ()
 Return the SharedPreconditioner.
virtual NOX::Epetra::InterfacegetUserInterface ()
 Return the userInterface.
virtual void setLinearSolveScaling (NOX::Epetra::Scaling &scalingObject)
 Sets the diagonal scaling vector(s) used in scaling the linear system. See NOX::Epetra::Scaling for details on how to specify scaling of the linear system.
virtual OperatorType getOperatorType (const Epetra_Operator &o)
 Returns the type of operator that is passed into the group constructors.
"Compute" functions.
virtual void setX (const NOX::Epetra::Vector &y)
virtual void setX (const NOX::Abstract::Vector &y)
 Set the solution vector x to y.
virtual void computeX (const NOX::Epetra::Group &grp, const NOX::Epetra::Vector &d, double step)
virtual void computeX (const NOX::Abstract::Group &grp, const NOX::Abstract::Vector &d, double step)
 Compute x = grp.x + step * d.
virtual NOX::Abstract::Group::ReturnType computeF ()
 Compute and store F(x).
virtual NOX::Abstract::Group::ReturnType computeJacobian ()
 Compute and store Jacobian.
virtual NOX::Abstract::Group::ReturnType computeGradient ()
 Compute and store gradient.
virtual NOX::Abstract::Group::ReturnType computeNewton (NOX::Parameter::List &params)
 Compute the Newton direction, using parameters for the linear solve.
Jacobian operations.
Operations using the Jacobian matrix. These may not be defined in matrix-free scenarios.

virtual NOX::Abstract::Group::ReturnType applyJacobian (const NOX::Epetra::Vector &input, NOX::Epetra::Vector &result) const
virtual NOX::Abstract::Group::ReturnType applyJacobian (const NOX::Abstract::Vector &input, NOX::Abstract::Vector &result) const
 Applies Jacobian to the given input vector and puts the answer in the result.
virtual NOX::Abstract::Group::ReturnType applyJacobianTranspose (const NOX::Epetra::Vector &input, NOX::Epetra::Vector &result) const
virtual NOX::Abstract::Group::ReturnType applyJacobianTranspose (const NOX::Abstract::Vector &input, NOX::Abstract::Vector &result) const
 Applies Jacobian-Transpose to the given input vector and puts the answer in the result.
virtual NOX::Abstract::Group::ReturnType applyJacobianInverse (NOX::Parameter::List &params, const NOX::Epetra::Vector &input, NOX::Epetra::Vector &result) const
virtual NOX::Abstract::Group::ReturnType applyJacobianInverse (NOX::Parameter::List &params, const NOX::Abstract::Vector &input, NOX::Abstract::Vector &result) const
 Applies the inverse of the Jacobian matrix to the given input vector and puts the answer in result.
virtual NOX::Abstract::Group::ReturnType applyRightPreconditioning (bool useTranspose, NOX::Parameter::List &params, const NOX::Epetra::Vector &input, NOX::Epetra::Vector &result) const
virtual NOX::Abstract::Group::ReturnType applyRightPreconditioning (bool useTranspose, NOX::Parameter::List &params, const NOX::Abstract::Vector &input, NOX::Abstract::Vector &result) const
 Apply right preconditiong to the given input vector.
"Is" functions
Checks to see if various objects have been computed. Returns true if the corresponding "compute" function has been called since the last update to the solution vector (via instantiation or computeX).

virtual bool isF () const
 Return true if F is valid.
virtual bool isJacobian () const
 Return true if the Jacobian is valid.
virtual bool isGradient () const
 Return true if the gradient is valid.
virtual bool isNewton () const
 Return true if the Newton direction is valid.
virtual bool isNormNewtonSolveResidual () const
 Returns true if the value of the Norm of the linear model for a full Newton step ||Js + f|| is valid with respect to the current solution vector.
virtual bool isPreconditioner () const
 Returns true if an explicitly constructed preconditioner exists (i.e. one that is computed and saved for further use in multiple calls to applyRightPreconditioner).
"Get" functions
Note that these function do not check whether or not the vectors are valid. Must use the "Is" functions for that purpose.

virtual const NOX::Abstract::VectorgetX () const
 Return solution vector.
virtual const NOX::Abstract::VectorgetF () const
 Return F(x).
virtual double getNormF () const
 Return 2-norm of F(x).
virtual const NOX::Abstract::VectorgetGradient () const
 Return gradient.
virtual const NOX::Abstract::VectorgetNewton () const
 Return Newton direction.
virtual NOX::Abstract::Group::ReturnType getNormLastLinearSolveResidual (double &residual) const
 Returns the 2-norm of the residual of the linear model used in the Newton solve computation, ||Js+f||. This does not account for line search adjustments to the step length!

Protected Types

enum  PrecConstructionType { ExplicitConstruction, ImplicitConstruction }
 Types that define how the construction of the preconditioner should be handled during a call to createPreconditioner(). More...

Protected Member Functions

virtual void resetIsValid ()
 resets the isValid flags to false
"Linear Solver" functions
virtual void setAztecOptions (const NOX::Parameter::List &params, AztecOO &aztec) const
 Set any required Aztec options. NOTE: This does not handle all aztec options. They will be added as needed.
virtual bool checkOperatorConsistency ()
 Checks to make sure that the supplied operators are valid for the requested preconditioning options.
virtual bool createPreconditioner (PrecConstructionType c, NOX::Parameter::List &p) const
 Computes a precoditioning matrix based on the current solution vector. It then sets the correct preconditioning object (Operator or Epetra_RowMatrix) in the AztecOO solver object. The first argument tells the method whether or not to enforce explicit construction of the preconditioner so that it is saved for reuse.
virtual bool createIfpackPreconditioner (NOX::Parameter::List &p) const
 Allocates the objects required for using ifpack preconditioners (NOX::Epetra::Group::ifpackGraph and NOX::Epetra::Group::ifpackPreconditioner). This is called from NOX::Epetra::Group::computePreconditioner().
virtual bool destroyPreconditioner () const
 Deletes all objects associated with the chosen preconditioner. This is called during linear solves and when the solution vector changes to reset the preconditioner.
virtual bool destroyAztecSolver () const
virtual bool computeNormNewtonSolveResidual ()
 Computes the 2-norm of the residual of the linear model used in the Newton solve computation, ||Js+f||.

Protected Attributes

const NOX::Utils utils
 Printing Utilities object.
double normRHS
 2-Norm of RHS
double normNewtonSolveResidual
 2-Norm of the Newton solve residual: ||Js+f||
NOX::Epetra::InterfaceuserInterface
 Reference to the user supplied interface functions.
OperatorType jacobianOperatorType
 Flag that tells the code how the Jacobian operator is implemented.
OperatorType preconditionerOperatorType
 Flag that tells the code how the Preconditioning operator is implemented.
string preconditioner
 Determines how the preconditioning is handled.
AztecOO * aztecSolver
 Aztec solver object used for preconditioning.
Ifpack_IlukGraph * ifpackGraph
 If using an IFPACK preconditioner, we must store the IFpack graph. This is mutable since the applyRightPreconditioner() is a const member.
Ifpack_CrsRiluk * ifpackPreconditioner
 If using an IFPACK preconditioner, we must store the IFpack preconditioner.
NOX::Epetra::Scalingscaling
 Scaling object supplied by the user.
Vectors
NOX::Epetra::VectorxVectorPtr
 Solution vector pointer.
NOX::Epetra::VectorxVector
 Solution vector.
NOX::Epetra::VectorRHSVectorPtr
 Right-hand-side vector (function evaluation).
NOX::Epetra::VectorRHSVector
 Right-hand-side vector pointer (function evaluation).
NOX::Epetra::VectorgradVectorPtr
 Gradient vector pointer(steepest descent vector).
NOX::Epetra::VectorgradVector
 Gradient vector (steepest descent vector).
NOX::Epetra::VectorNewtonVectorPtr
 Newton direction vector pointer.
NOX::Epetra::VectorNewtonVector
 Newton direction vector.
Epetra_VectortmpVectorPtr
 An extra temporary vector, only allocated if needed.
IsValid flags
True if the current solution is up-to-date with respect to the currect xVector.

bool isValidRHS
bool isValidJacobian
bool isValidGrad
bool isValidNewton
bool isValidNormNewtonSolveResidual
bool isValidPreconditioner
Shared Operators
NOX::Epetra::SharedOperatorsharedJacobianPtr
 Pointer to shared Jacobian matrix.
NOX::Epetra::SharedOperatorsharedJacobian
 Reference to shared Jacobian matrix.
NOX::Epetra::SharedOperatorsharedPreconditionerPtr
 Pointer to shared Preconditioning matrix.
NOX::Epetra::SharedOperatorsharedPreconditioner
 Reference to shared Preconditioning matrix. If a Group constructor is used that only supplies a Jacobian (i.e. no separate preconditioning matrix is supplied) then this will point to the Jacobian!

Detailed Description

Concrete implementation of NOX::Abstract::Group for Trilinos/Epetra.

This group is set up to use the linear algebra services provided through the Trilinos/Epetra package with AztecOO for the linear solver.

Supplying a Jacobian Operator

A linear solve using this class requires at a minimum that the user supply a Jacobian object derived from the pure virtual Epetra_Operator class. This does not have to be an explicit matrix since Newton-Krylov methods only require the action of the Jacobian on a vector (Jy). The user has five options for providing the Epetra_Operator Jacobian. This operator is passed in to through the group constructor. Depending on the type of object, the user may have to implement additional functions in the NOX::Epetra::Interface object (the user must always implement the computeF() function) to actually fill/evaluate the object at the current solution. Any additional functions are listed below:

"Linear %Solver" sublist parameters

A NOX::ParameterList is supplied in the constructor and during calls to the NOX::Epetra::Group::computeNewton() and NOX::Epetra::Group::applyJacobianInverse(). This parameter list is the "Linear %Solver" sublist. The following parameters can be set in the linear Solver sublist for NOX::Epetra::Groups

"Output" sublist

The parameter list passed into the group during a computeNewton() or ApplyJacobianInverse() will have an "Output" sublist created that contains the following parameters:


Member Enumeration Documentation

enum NOX::Epetra::Group::OperatorType
 

List of types of operators that can be used for the Jacobian and/or Preconditioner.

Enumeration values:
None  No operator was supplied (used only for preconditioner).
EpetraOperator  the user implements an Epetra_Operator derived object.
EpetraRowMatrix  the user implements an Epetra_RowMatrix derived object.
NoxOperator  the user implements a NOX::Epetra::Operator derived object.
NoxFiniteDifferenceRowMatrix  the operator is a NOX::Epetra::FiniteDifference object that is derived from an Epetra_CrsMatrix. The compute() function evaluates the Jacobian using finite differencing.
NoxMatrixFreeOperator  The operator is a NOX::Epetra::MatrixFree object that derives from the Epetra_Operator class. The compute() function evaluates the Jacobian.

enum NOX::Epetra::Group::PrecConstructionType [protected]
 

Types that define how the construction of the preconditioner should be handled during a call to createPreconditioner().

Preconditioners are used in two methods: (1) during linear solves in applyJacobianInverse() and (2) for the method applyRightPreconditioner(). For the applyJacobianInverse() the preconditioner is created and destroyed "implicitly" in the linear solver. The correct operator need only be set in the AztecOO solver and the solver will take care of creation and destruction internally. The opposite is true for applyRightPreconditioner(). Here we must force an "explicit" construction and retention of the preconditioner since there will be multple calls to applyRightPreconditioner() that reuses the same preconditioner. This flag type is used to specify the construction type.


Constructor & Destructor Documentation

NOX::Epetra::Group::Group NOX::Parameter::List printingParams,
NOX::Parameter::List linearSolverParams,
NOX::Epetra::Interface i,
Epetra_Vector x,
Epetra_Operator J
 

Constructor with Jacobian Operator only.

Either there is no preconditioning or the Jacobian will be used for preconditioning. An Epetra_Operator must be supplied for the Jacobian even in Matrix-Free mode. linearSolverParams is the "Linear Solver" sublist of parameter list.

NOX::Epetra::Group::Group NOX::Parameter::List printingParams,
NOX::Parameter::List linearSolverParams,
NOX::Epetra::Interface i,
NOX::Epetra::Vector x,
Epetra_Operator J
 

Constructor with Jacobian Operator only.

Either there is no preconditioning or the Jacobian will be used for preconditioning. An Epetra_Operator must be supplied for the Jacobian even in Matrix-Free mode. linearSolverParams is the "Linear Solver" sublist of parameter list.

NOX::Epetra::Group::Group NOX::Parameter::List printingParams,
NOX::Parameter::List linearSolverParams,
NOX::Epetra::Interface i,
Epetra_Vector x,
Epetra_Operator J,
Epetra_Operator M
 

Constructor with a separate Jacobian (J) and Preconditioner (M). linearSolverParams is the "Linear %Solver" sublist of parameter list.

NOX::Epetra::Group::Group NOX::Parameter::List printingParams,
NOX::Parameter::List linearSolverParams,
NOX::Epetra::Interface i,
NOX::Epetra::Vector x,
Epetra_Operator J,
Epetra_Operator M
 

Constructor with a separate Jacobian (J) and Preconditioner (M). linearSolverParams is the "Linear %Solver" sublist of parameter list.


Member Function Documentation

Abstract::Group::ReturnType Group::applyJacobian const NOX::Abstract::Vector input,
NOX::Abstract::Vector result
const [virtual]
 

Applies Jacobian to the given input vector and puts the answer in the result.

Computes

\[ v = J u, \]

where $J$ is the Jacobian, $u$ is the input vector, and $v$ is the result vector.

Returns:

Reimplemented from NOX::Abstract::Group.

Abstract::Group::ReturnType Group::applyJacobianInverse NOX::Parameter::List params,
const NOX::Abstract::Vector input,
NOX::Abstract::Vector result
const [virtual]
 

Applies the inverse of the Jacobian matrix to the given input vector and puts the answer in result.

Computes

\[ v = J^{-1} u, \]

where $J$ is the Jacobian, $u$ is the input vector, and $v$ is the result vector.

The "Tolerance" parameter specifies that the solution should be such that

\[ \frac{\| J v - u \|_2}{\max \{ 1, \|u\|_2\} } < \mbox{Tolerance} \]

Returns:
The parameter "Tolerance" may be added/modified in the list of parameters - this is the ideal solution tolerance for an iterative linear solve.

Reimplemented from NOX::Abstract::Group.

Abstract::Group::ReturnType Group::applyJacobianTranspose const NOX::Abstract::Vector input,
NOX::Abstract::Vector result
const [virtual]
 

Applies Jacobian-Transpose to the given input vector and puts the answer in the result.

Computes

\[ v = J^T u, \]

where $J$ is the Jacobian, $u$ is the input vector, and $v$ is the result vector.

Returns:

Reimplemented from NOX::Abstract::Group.

Abstract::Group::ReturnType Group::applyRightPreconditioning bool  useTranspose,
NOX::Parameter::List params,
const NOX::Abstract::Vector input,
NOX::Abstract::Vector result
const [virtual]
 

Apply right preconditiong to the given input vector.

Let $M$ be a right preconditioner for the Jacobian $J$; in other words, $M$ is a matrix such that

\[ JM \approx I. \]

Compute

\[ u = M^{-1} v, \]

where $u$ is the input vector and $v$ is the result vector.

If useTranspose is true, then the transpose of the preconditioner is applied:

\[ u = {M^{-1}}^T v, \]

The transpose preconditioner is currently only required for Tensor methods.

The "Tolerance" parameter specifies that the solution should be such that

\[ \frac{\| M v - u \|_2}{\max \{ 1, \|u\|_2\} } < \mbox{Tolerance} \]

Returns:
The parameters are from the "Linear %Solver" sublist of the "Direction" sublist that is passed to solver during construction.

Reimplemented from NOX::Abstract::Group.

Abstract::Group::ReturnType Group::computeF  )  [virtual]
 

Compute and store F(x).

Note:
It's generally useful to also compute and store the 2-norm of F(x) at this point for later access by the getNormF() function.
Returns:

Implements NOX::Abstract::Group.

Reimplemented in LOCA::Epetra::Group.

Abstract::Group::ReturnType Group::computeGradient  )  [virtual]
 

Compute and store gradient.

We can pose the nonlinear equation problem $F(x) = 0$ as an optimization problem as follows:

\[ \min f(x) \equiv \frac{1}{2} \|F(x)\|_2^2. \]

In that case, the gradient (of $f$) is defined as

\[ g \equiv J^T F. \]

Returns:

Reimplemented from NOX::Abstract::Group.

Abstract::Group::ReturnType Group::computeJacobian  )  [virtual]
 

Compute and store Jacobian.

Recall that

\[ F(x) = \left[ \begin{array}{c} F_1(x) \\ F_2(x) \\ \vdots \\ F_n(x) \\ \end{array} \right]. \]

The Jacobian is denoted by $J$ and defined by

\[ J_{ij} = \frac{\partial F_i}{\partial x_j} (x). \]

Note:
If this is a shared object, this group should taken ownership of the Jacobian before it computes it.
Returns:

Reimplemented from NOX::Abstract::Group.

Reimplemented in LOCA::Epetra::Group.

Abstract::Group::ReturnType Group::computeNewton NOX::Parameter::List params  )  [virtual]
 

Compute the Newton direction, using parameters for the linear solve.

The Newton direction is the solution, s, of

\[ J s = -F. \]

The parameters are from the "Linear %Solver" sublist of the "Direction" sublist that is passed to solver during construction.

The "Tolerance" parameter may be added/modified in the sublist of "Linear Solver" parameters that is passed into this function. The solution should be such that

\[ \frac{\| J s - (-F) \|_2}{\max \{ 1, \|F\|_2\} } < \mbox{Tolerance} \]

Returns:

Reimplemented from NOX::Abstract::Group.

void Group::computeX const NOX::Abstract::Group grp,
const NOX::Abstract::Vector d,
double  step
[virtual]
 

Compute x = grp.x + step * d.

Let $x$ denote this group's solution vector. Let $\hat x$ denote the result of grp.getX(). Then set

\[ x = \hat x + \mbox{step} \; d. \]

Note:
This should invalidate the function value, Jacobian, gradient, and Newton direction.

Throw an error if the copy fails.

Returns:
Reference to this object

Implements NOX::Abstract::Group.

bool Group::destroyAztecSolver  )  const [protected, virtual]
 

Deletes the AztecOO solver object. This is called when the solution vector for the group is changed. The preconditioner is no longer valid so the solver and preconditioner are destroyed by a call to this method.

double Group::getNormF  )  const [virtual]
 

Return 2-norm of F(x).

In other words,

\[ \sqrt{\sum_{i=1}^n F_i^2} \]

Implements NOX::Abstract::Group.

Group::OperatorType Group::getOperatorType const Epetra_Operator o  )  [virtual]
 

Returns the type of operator that is passed into the group constructors.

Uses dynamic casting to identify the underlying object type.

bool Group::isGradient  )  const [virtual]
 

Return true if the gradient is valid.

Note:
Default implementation in NOX::Abstract::Group returns false.

Reimplemented from NOX::Abstract::Group.

bool Group::isJacobian  )  const [virtual]
 

Return true if the Jacobian is valid.

Note:
Default implementation in NOX::Abstract::Group returns false.

Reimplemented from NOX::Abstract::Group.

bool Group::isNewton  )  const [virtual]
 

Return true if the Newton direction is valid.

Note:
Default implementation in NOX::Abstract::Group returns false.

Reimplemented from NOX::Abstract::Group.

Abstract::Group & Group::operator= const NOX::Abstract::Group source  )  [virtual]
 

Copies the source group into this group.

Note:
Any shared data owned by the source should have its ownership transfered to this group. This may result in a secret modification to the source object.

Implements NOX::Abstract::Group.

Reimplemented in LOCA::Epetra::Group.

void Group::setX const NOX::Abstract::Vector y  )  [virtual]
 

Set the solution vector x to y.

Note:
This should invalidate the function value, Jacobian, gradient, and Newton direction.

Throw an error if the copy fails.

Returns:
Reference to this object

Implements NOX::Abstract::Group.


Member Data Documentation

AztecOO* NOX::Epetra::Group::aztecSolver [mutable, protected]
 

Aztec solver object used for preconditioning.

If calling applyRightPreconditioning() and using an AztecOO solver, the AztecOO object must be saved. Previously we created and deleted this object during linear solves. The solver object must be stored so that we don't have to recompute the preconditioner for each call to applyRightPreconditioning(). We only need to recompute the preconditioner when the solution vector and it's corresponding preconditioning matrix is updated.

OperatorType NOX::Epetra::Group::jacobianOperatorType [protected]
 

Flag that tells the code how the Jacobian operator is implemented.

This flag is set in the constructor by calling the function getJacobianType().

string NOX::Epetra::Group::preconditioner [protected]
 

Determines how the preconditioning is handled.

This variable is set in the constructors from the "Preconditioning" parameter in the "Linear Solver" sublist.

Key in "Linear Solver" sublist: "Preconditioning"

Valid Options:

  • "None" - no precondtioning is used.

  • "AztecOO: Jacobian Matrix" - AztecOO preconditioner is used. This requires an explicit Jacobian Matrix. Therefore the Jacobian matrix must be an Epetra_RowMatrix or a NOX_FiniteDifference object.

  • "AztecOO: User RowMatrix" - AztecOO preconditioner is used. This requires an explicit Epetra_RowMatrix that is NOT the same as the Jacobian. This was specifically written for "Matrix-Free" mode when there is no explicit Matrix for the Jacobian.

  • "IFPACK: Jacobian Matrix" - IFPACK preconditioner is used. This requires an explicit Jacobian Matrix. Therefore the Jacobian matrix must be an Epetra_RowMatrix or a NOX_FiniteDifference object.

  • "IFPACK: User RowMatrix" - IFPACK preconditioner is used. This requires an explicit Epetra_RowMatrix that is NOT the same as the Jacobian. This was specifically written for "Matrix-Free" mode when there is no explicit Matrix for the Jacobian.

  • "User Supplied Preconditioner" - user supplied routine that computes the preconditioner and applies it to a vector. The user must implement the routine as an Epetra_Operator class such that the ApplyInverse() function preconditions the incoming vector.

OperatorType NOX::Epetra::Group::preconditionerOperatorType [protected]
 

Flag that tells the code how the Preconditioning operator is implemented.

This flag is set in the constructor by calling the function getPrecType().


The documentation for this class was generated from the following files:
Generated on Thu Sep 18 12:42:27 2008 for NOX by doxygen 1.3.9.1