NOX Development
Public Member Functions | Protected Member Functions | Protected Attributes
NOX::Thyra::Group Class Reference

A simple example of a group structure, based on Thyra. More...

#include <NOX_Thyra_Group.H>

Inheritance diagram for NOX::Thyra::Group:
Inheritance graph
[legend]
Collaboration diagram for NOX::Thyra::Group:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Group (const NOX::Thyra::Vector &initial_guess, const Teuchos::RCP< const ::Thyra::ModelEvaluator< double > > &model)
 Constructor.
 Group (const NOX::Thyra::Group &source, NOX::CopyType type=DeepCopy)
 Copy constructor.
 ~Group ()
 Destructor.
NOX::Abstract::Groupoperator= (const NOX::Abstract::Group &source)
 Copies the source group into this group.
NOX::Abstract::Groupoperator= (const NOX::Thyra::Group &source)
 See above.
Teuchos::RCP< const
::Thyra::VectorBase< double > > 
get_current_x () const
 
Teuchos::RCP
< ::Thyra::LinearOpWithSolveBase
< double > > 
getNonconstJacobian ()
 
Teuchos::RCP< const
::Thyra::LinearOpWithSolveBase
< double > > 
getJacobian () const
 
virtual Teuchos::RCP
< NOX::Abstract::Group
clone (NOX::CopyType type=NOX::DeepCopy) const
 Create a new Group of the same derived type as this one by cloning this one, and return a ref count pointer to the new group.
void print () const
 Print out the group.
"Compute" functions.
void setX (const NOX::Abstract::Vector &y)
 Set the solution vector x to y.
void setX (const NOX::Thyra::Vector &y)
 See above.
void computeX (const NOX::Abstract::Group &grp, const NOX::Abstract::Vector &d, double step)
 Compute x = grp.x + step * d.
void computeX (const NOX::Thyra::Group &grp, const NOX::Thyra::Vector &d, double step)
 See above.
NOX::Abstract::Group::ReturnType computeF ()
 Compute and store F(x).
NOX::Abstract::Group::ReturnType computeJacobian ()
 Compute and store Jacobian.
NOX::Abstract::Group::ReturnType computeGradient ()
 Compute and store gradient.
NOX::Abstract::Group::ReturnType computeNewton (Teuchos::ParameterList &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.

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.
NOX::Abstract::Group::ReturnType applyJacobian (const NOX::Thyra::Vector &input, NOX::Thyra::Vector &result) const
NOX::Abstract::Group::ReturnType applyJacobianMultiVector (const NOX::Abstract::MultiVector &input, NOX::Abstract::MultiVector &result) const
 applyJacobian for multiple right-hand sides
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.
NOX::Abstract::Group::ReturnType applyJacobianTranspose (const NOX::Thyra::Vector &input, NOX::Thyra::Vector &result) const
NOX::Abstract::Group::ReturnType applyJacobianTransposeMultiVector (const NOX::Abstract::MultiVector &input, NOX::Abstract::MultiVector &result) const
 applyJacobianTranspose for multiple right-hand sides
NOX::Abstract::Group::ReturnType applyJacobianInverse (Teuchos::ParameterList &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.
NOX::Abstract::Group::ReturnType applyJacobianInverse (Teuchos::ParameterList &params, const NOX::Thyra::Vector &input, NOX::Thyra::Vector &result) const
NOX::Abstract::Group::ReturnType applyJacobianInverseMultiVector (Teuchos::ParameterList &params, const NOX::Abstract::MultiVector &input, NOX::Abstract::MultiVector &result) const
 applyJacobianInverse for multiple right-hand sides
"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).

bool isF () const
 Return true if F is valid.
bool isJacobian () const
 Return true if the Jacobian is valid.
bool isGradient () const
 Return true if the gradient is valid.
bool isNewton () const
 Return true if the Newton direction is valid.
"Get" functions

Note that these function do not check whether or not the vectors are valid. Must use the "Is" functions for that purpose.

const NOX::Abstract::VectorgetX () const
 Return solution vector.
const NOX::Abstract::VectorgetF () const
 Return F(x)
double getNormF () const
 Return 2-norm of F(x).
const NOX::Abstract::VectorgetGradient () const
 Return gradient.
const NOX::Abstract::VectorgetNewton () const
 Return Newton direction.
Teuchos::RCP< const
NOX::Abstract::Vector
getXPtr () const
 Return RCP to solution vector.
Teuchos::RCP< const
NOX::Abstract::Vector
getFPtr () const
 Return RCP to F(x)
Teuchos::RCP< const
NOX::Abstract::Vector
getGradientPtr () const
 Return RCP to gradient.
Teuchos::RCP< const
NOX::Abstract::Vector
getNewtonPtr () const
 Return RCP to Newton direction.

Protected Member Functions

void resetIsValidFlags ()
 resets the isValid flags to false
NOX::Abstract::Group::ReturnType applyJacobianInverseMultiVector (Teuchos::ParameterList &p, const ::Thyra::MultiVectorBase< double > &input,::Thyra::MultiVectorBase< double > &result) const
 Apply Jacobian inverse using Thyra objects.
::Thyra::ESolveMeasureNormType getThyraNormType (const string &name) const

Protected Attributes

Teuchos::RCP< const
::Thyra::ModelEvaluator
< double > > 
model_
 Problem interface.
Teuchos::RCP< NOX::Thyra::Vectorx_vec_
 Solution vector.
Teuchos::RCP< NOX::Thyra::Vectorf_vec_
 Residual vector.
Teuchos::RCP< NOX::Thyra::Vectornewton_vec_
 Newton direction vector.
Teuchos::RCP< NOX::Thyra::Vectorgradient_vec_
 Gradient direction vector.
Teuchos::RCP
< NOX::SharedObject
< ::Thyra::LinearOpWithSolveBase
< double >, NOX::Thyra::Group > > 
shared_jacobian_
 Shared Jacobian operator.
::Thyra::ModelEvaluatorBase::InArgs
< double > 
in_args_
 Residual InArgs.
::Thyra::ModelEvaluatorBase::OutArgs
< double > 
out_args_
 Residual OutArgs.
IsValid flags

True if the current solution is up-to-date with respect to the currect solution vector.

bool is_valid_f_
bool is_valid_jacobian_
bool is_valid_newton_dir_
bool is_valid_gradient_dir_

Detailed Description

A simple example of a group structure, based on Thyra.


Member Function Documentation

NOX::Abstract::Group::ReturnType NOX::Thyra::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.

References dyn_cast().

NOX::Abstract::Group::ReturnType NOX::Thyra::Group::applyJacobianInverse ( Teuchos::ParameterList 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.

References dyn_cast().

NOX::Abstract::Group::ReturnType NOX::Thyra::Group::applyJacobianInverseMultiVector ( Teuchos::ParameterList params,
const NOX::Abstract::MultiVector input,
NOX::Abstract::MultiVector result 
) const [virtual]

applyJacobianInverse for multiple right-hand sides

The default implementation here calls applyJacobianInverse() for each right hand side serially but should be overloaded if a block solver is available.

Reimplemented from NOX::Abstract::Group.

References Teuchos::dyn_cast(), and NOX::Thyra::MultiVector::getThyraMultiVector().

NOX::Abstract::Group::ReturnType NOX::Thyra::Group::applyJacobianMultiVector ( const NOX::Abstract::MultiVector input,
NOX::Abstract::MultiVector result 
) const [virtual]

applyJacobian for multiple right-hand sides

The default implementation here calls applyJacobian() for each right hand side serially but should be overloaded if a block method is available.

Reimplemented from NOX::Abstract::Group.

References Teuchos::dyn_cast(), Teuchos::RCP< T >::get(), NOX::Thyra::MultiVector::getThyraMultiVector(), NOX::Abstract::Group::Ok, and TEST_FOR_EXCEPTION.

NOX::Abstract::Group::ReturnType NOX::Thyra::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.

References dyn_cast().

NOX::Abstract::Group::ReturnType NOX::Thyra::Group::applyJacobianTransposeMultiVector ( const NOX::Abstract::MultiVector input,
NOX::Abstract::MultiVector result 
) const [virtual]

applyJacobianTranspose for multiple right-hand sides

The default implementation here calls applyJacobianTranspose() for each right hand side serially but should be overloaded if a block method is available.

Reimplemented from NOX::Abstract::Group.

References Teuchos::dyn_cast(), NOX::Abstract::Group::Failed, Teuchos::RCP< T >::get(), NOX::Thyra::MultiVector::getThyraMultiVector(), NOX::Abstract::Group::Ok, and TEST_FOR_EXCEPTION.

Teuchos::RCP< NOX::Abstract::Group > NOX::Thyra::Group::clone ( NOX::CopyType  type = NOX::DeepCopy) const [virtual]

Create a new Group of the same derived type as this one by cloning this one, and return a ref count pointer to the new group.

If type is NOX::DeepCopy, then we need to create an exact replica of "this". Otherwise, if type is NOX::ShapeCopy, we need only replicate the shape of "this" (only the memory is allocated, the values are not copied into the vectors and Jacobian). Returns NULL if clone is not supported.

Note:
Any shared data should have its ownership transfered to this group from the source for a NOX::DeepCopy.

Implements NOX::Abstract::Group.

Reimplemented in LOCA::Thyra::Group.

References Teuchos::rcp().

NOX::Abstract::Group::ReturnType NOX::Thyra::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::Thyra::Group.

References NOX::Abstract::Group::Failed, and NOX::Abstract::Group::Ok.

NOX::Abstract::Group::ReturnType NOX::Thyra::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.

References NOX::Abstract::Group::Failed, NOX::Abstract::Group::Ok, and TEST_FOR_EXCEPTION.

NOX::Abstract::Group::ReturnType NOX::Thyra::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::Thyra::Group.

References NOX::Abstract::Group::Failed, and NOX::Abstract::Group::Ok.

NOX::Abstract::Group::ReturnType NOX::Thyra::Group::computeNewton ( Teuchos::ParameterList 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 NOX::Thyra::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.

double NOX::Thyra::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.

bool NOX::Thyra::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 NOX::Thyra::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.

Referenced by Group().

bool NOX::Thyra::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.

NOX::Abstract::Group & NOX::Thyra::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::Thyra::Group.

Referenced by LOCA::Thyra::Group::operator=().

void NOX::Thyra::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.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends