#include <NOX_Petsc_Group.H>
Public Member Functions | |
Group (Interface &i, Vec &x, Mat &J) | |
Constructor. | |
Group (const Group &source, CopyType type=DeepCopy) | |
Copy constructor. If type is DeepCopy, takes ownership of valid shared Jacobian. | |
virtual | ~Group () |
Destructor. | |
virtual Abstract::Group & | operator= (const NOX::Abstract::Group &source) |
Copies the source group into this group. | |
virtual Abstract::Group & | operator= (const Group &source) |
See above. | |
virtual Teuchos::RCP < NOX::Abstract::Group > | clone (CopyType type=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. | |
"Compute" functions. | |
virtual void | setX (const Vector &y) |
virtual void | setX (const Abstract::Vector &y) |
See above. | |
virtual void | computeX (const Group &grp, const Vector &d, double step) |
virtual void | computeX (const Abstract::Group &grp, const Abstract::Vector &d, double step) |
See above. | |
virtual Abstract::Group::ReturnType | computeF () |
Compute and store F(x). | |
virtual Abstract::Group::ReturnType | computeJacobian () |
Compute and store Jacobian. | |
virtual Abstract::Group::ReturnType | computeGradient () |
Compute and store gradient. | |
virtual Abstract::Group::ReturnType | computeNewton (Teuchos::ParameterList ¶ms) |
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 Abstract::Group::ReturnType | applyJacobian (const Vector &input, Vector &result) const |
virtual Abstract::Group::ReturnType | applyJacobian (const Abstract::Vector &input, Abstract::Vector &result) const |
See above. | |
virtual Abstract::Group::ReturnType | applyJacobianTranspose (const Vector &input, Vector &result) const |
virtual Abstract::Group::ReturnType | applyJacobianTranspose (const Abstract::Vector &input, Abstract::Vector &result) const |
See above. | |
virtual Abstract::Group::ReturnType | applyRightPreconditioning (const Vector &input, Vector &result) const |
Preconditions a vector using one of the available methods in Petsc. | |
virtual Abstract::Group::ReturnType | applyRightPreconditioning (Teuchos::ParameterList &, const Abstract::Vector &input, Abstract::Vector &result) const |
See above. | |
"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 | isPreconditioner () const |
"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 Abstract::Vector & | getX () const |
Return solution vector. | |
virtual const Abstract::Vector & | getF () const |
Return F(x). | |
virtual double | getNormF () const |
Return 2-norm of F(x). | |
virtual const Abstract::Vector & | getGradient () const |
Return gradient. | |
virtual const Abstract::Vector & | getNewton () const |
Return Newton direction. | |
Protected Member Functions | |
virtual void | resetIsValid () |
resets the isValid flags to false | |
Protected Attributes | |
double | normRHS |
Norm of RHS. | |
SharedJacobian * | sharedJacobianPtr |
Pointer to shared Jacobian matrix. | |
SharedJacobian & | sharedJacobian |
Reference to shared Jacobian matrix. | |
string | jacType |
Specification of Jacobian Type. | |
Interface & | userInterface |
Reference to the user supplied interface functions. | |
Vectors | |
Vector | xVector |
Solution vector. | |
Vector | RHSVector |
Right-hand-side vector (function evaluation). | |
Vector | gradVector |
Gradient vector (steepest descent vector). | |
Vector | NewtonVector |
Newton direction vector. | |
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 | isValidPreconditioner |
Definition at line 67 of file NOX_Petsc_Group.H.
Group::Group | ( | Interface & | i, | |
Vec & | x, | |||
Mat & | J | |||
) |
Constructor.
Definition at line 57 of file NOX_Petsc_Group.C.
References resetIsValid(), and NOX::ShapeCopy.
Copy constructor. If type is DeepCopy, takes ownership of valid shared Jacobian.
Definition at line 70 of file NOX_Petsc_Group.C.
References NOX::DeepCopy, NOX::Petsc::SharedJacobian::getJacobian(), normRHS, resetIsValid(), NOX::ShapeCopy, and sharedJacobian.
Group::~Group | ( | ) | [virtual] |
Destructor.
Reimplemented from NOX::Abstract::Group.
Definition at line 108 of file NOX_Petsc_Group.C.
References sharedJacobianPtr.
Abstract::Group & Group::operator= | ( | const NOX::Abstract::Group & | source | ) | [virtual] |
Copies the source group into this group.
Implements NOX::Abstract::Group.
Definition at line 131 of file NOX_Petsc_Group.C.
Abstract::Group & Group::operator= | ( | const Group & | source | ) | [virtual] |
See above.
Definition at line 137 of file NOX_Petsc_Group.C.
References NOX::Petsc::SharedJacobian::getJacobian(), gradVector, NewtonVector, normRHS, RHSVector, sharedJacobian, and xVector.
void Group::setX | ( | const Abstract::Vector & | y | ) | [virtual] |
void Group::computeX | ( | const Abstract::Group & | grp, | |
const Abstract::Vector & | d, | |||
double | step | |||
) | [virtual] |
Abstract::Group::ReturnType Group::computeF | ( | ) | [virtual] |
Compute and store F(x).
Implements NOX::Abstract::Group.
Definition at line 205 of file NOX_Petsc_Group.C.
References NOX::Petsc::Interface::computeF(), NOX::Petsc::Vector::getPetscVector(), isF(), NOX::Petsc::Vector::norm(), normRHS, NOX::Abstract::Group::Ok, RHSVector, userInterface, and xVector.
Abstract::Group::ReturnType Group::computeJacobian | ( | ) | [virtual] |
Compute and store Jacobian.
Recall that
The Jacobian is denoted by and defined by
Reimplemented from NOX::Abstract::Group.
Definition at line 228 of file NOX_Petsc_Group.C.
References NOX::Petsc::Interface::computeJacobian(), NOX::Petsc::SharedJacobian::getJacobian(), NOX::Petsc::Vector::getPetscVector(), isJacobian(), jacType, NOX::Abstract::Group::Ok, sharedJacobian, userInterface, and xVector.
Abstract::Group::ReturnType Group::computeGradient | ( | ) | [virtual] |
Compute and store gradient.
We can pose the nonlinear equation problem as an optimization problem as follows:
In that case, the gradient (of ) is defined as
Reimplemented from NOX::Abstract::Group.
Definition at line 263 of file NOX_Petsc_Group.C.
References NOX::Petsc::SharedJacobian::getJacobian(), NOX::Petsc::Vector::getPetscVector(), gradVector, isF(), isGradient(), isJacobian(), NOX::Abstract::Group::Ok, RHSVector, and sharedJacobian.
Abstract::Group::ReturnType Group::computeNewton | ( | Teuchos::ParameterList & | params | ) | [virtual] |
Compute the Newton direction, using parameters for the linear solve.
The Newton direction is the solution, s, of
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
params
Reimplemented from NOX::Abstract::Group.
Definition at line 293 of file NOX_Petsc_Group.C.
References NOX::Petsc::SharedJacobian::getJacobian(), NOX::Petsc::Vector::getPetscVector(), isF(), isJacobian(), isNewton(), NewtonVector, NOX::Abstract::Group::Ok, RHSVector, NOX::Petsc::Vector::scale(), and sharedJacobian.
Abstract::Group::ReturnType Group::applyJacobian | ( | const Abstract::Vector & | input, | |
Abstract::Vector & | result | |||
) | const [virtual] |
See above.
Reimplemented from NOX::Abstract::Group.
Definition at line 371 of file NOX_Petsc_Group.C.
Abstract::Group::ReturnType Group::applyJacobianTranspose | ( | const Abstract::Vector & | input, | |
Abstract::Vector & | result | |||
) | const [virtual] |
See above.
Reimplemented from NOX::Abstract::Group.
Definition at line 447 of file NOX_Petsc_Group.C.
Abstract::Group::ReturnType Group::applyRightPreconditioning | ( | const Vector & | input, | |
Vector & | result | |||
) | const [virtual] |
Preconditions a vector using one of the available methods in Petsc.
Currently, the preconditioning method corresponds to whatever is available in the user's Petsc installation and is specified in the local .petscrc file. For example, a direct solve can be accomplished by specifying -pc_type lu (serial only), whereas diagonal scaling can be achieved via -pc_type jacobi.
Definition at line 406 of file NOX_Petsc_Group.C.
References NOX::Abstract::Group::BadDependency, NOX::Petsc::SharedJacobian::getJacobian(), NOX::Petsc::Vector::getPetscVector(), isJacobian(), NOX::Abstract::Group::Ok, and sharedJacobian.
Referenced by applyRightPreconditioning().
Abstract::Group::ReturnType Group::applyRightPreconditioning | ( | Teuchos::ParameterList & | params, | |
const Abstract::Vector & | input, | |||
Abstract::Vector & | result | |||
) | const [virtual] |
See above.
Definition at line 396 of file NOX_Petsc_Group.C.
References applyRightPreconditioning().
bool Group::isF | ( | ) | const [virtual] |
Return true if F is valid.
Implements NOX::Abstract::Group.
Definition at line 472 of file NOX_Petsc_Group.C.
Referenced by computeF(), computeGradient(), computeNewton(), getF(), and getNormF().
bool Group::isJacobian | ( | ) | const [virtual] |
Return true if the Jacobian is valid.
Reimplemented from NOX::Abstract::Group.
Definition at line 478 of file NOX_Petsc_Group.C.
References NOX::Petsc::SharedJacobian::isOwner(), and sharedJacobian.
Referenced by applyRightPreconditioning(), computeGradient(), computeJacobian(), and computeNewton().
bool Group::isGradient | ( | ) | const [virtual] |
Return true if the gradient is valid.
Reimplemented from NOX::Abstract::Group.
Definition at line 484 of file NOX_Petsc_Group.C.
Referenced by computeGradient(), and getGradient().
bool Group::isNewton | ( | ) | const [virtual] |
Return true if the Newton direction is valid.
Reimplemented from NOX::Abstract::Group.
Definition at line 490 of file NOX_Petsc_Group.C.
Referenced by computeNewton(), and getNewton().
const Abstract::Vector & Group::getX | ( | ) | const [virtual] |
Return solution vector.
Implements NOX::Abstract::Group.
Definition at line 502 of file NOX_Petsc_Group.C.
References xVector.
const Abstract::Vector & Group::getF | ( | ) | const [virtual] |
double Group::getNormF | ( | ) | const [virtual] |
Return 2-norm of F(x).
In other words,
Implements NOX::Abstract::Group.
Definition at line 519 of file NOX_Petsc_Group.C.
const Abstract::Vector & Group::getGradient | ( | ) | const [virtual] |
Return gradient.
Implements NOX::Abstract::Group.
Definition at line 530 of file NOX_Petsc_Group.C.
References gradVector, and isGradient().
const Abstract::Vector & Group::getNewton | ( | ) | const [virtual] |
Return Newton direction.
Implements NOX::Abstract::Group.
Definition at line 541 of file NOX_Petsc_Group.C.
References isNewton(), and NewtonVector.
Teuchos::RCP< NOX::Abstract::Group > Group::clone | ( | CopyType | type = 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.
Implements NOX::Abstract::Group.
Definition at line 123 of file NOX_Petsc_Group.C.
void Group::resetIsValid | ( | ) | [protected, virtual] |
resets the isValid flags to false
Definition at line 113 of file NOX_Petsc_Group.C.
Referenced by Group().
Vector NOX::Petsc::Group::xVector [protected] |
Solution vector.
Definition at line 194 of file NOX_Petsc_Group.H.
Referenced by computeF(), computeJacobian(), getX(), and operator=().
Vector NOX::Petsc::Group::RHSVector [protected] |
Right-hand-side vector (function evaluation).
Definition at line 196 of file NOX_Petsc_Group.H.
Referenced by computeF(), computeGradient(), computeNewton(), getF(), and operator=().
Vector NOX::Petsc::Group::gradVector [protected] |
Gradient vector (steepest descent vector).
Definition at line 198 of file NOX_Petsc_Group.H.
Referenced by computeGradient(), getGradient(), and operator=().
Vector NOX::Petsc::Group::NewtonVector [protected] |
Newton direction vector.
Definition at line 200 of file NOX_Petsc_Group.H.
Referenced by computeNewton(), getNewton(), and operator=().
double NOX::Petsc::Group::normRHS [protected] |
Norm of RHS.
Definition at line 216 of file NOX_Petsc_Group.H.
Referenced by computeF(), getNormF(), Group(), and operator=().
SharedJacobian* NOX::Petsc::Group::sharedJacobianPtr [protected] |
Pointer to shared Jacobian matrix.
Definition at line 219 of file NOX_Petsc_Group.H.
Referenced by ~Group().
SharedJacobian& NOX::Petsc::Group::sharedJacobian [protected] |
Reference to shared Jacobian matrix.
Definition at line 222 of file NOX_Petsc_Group.H.
Referenced by applyRightPreconditioning(), computeGradient(), computeJacobian(), computeNewton(), Group(), isJacobian(), and operator=().
string NOX::Petsc::Group::jacType [protected] |
Specification of Jacobian Type.
Definition at line 225 of file NOX_Petsc_Group.H.
Referenced by computeJacobian().
Interface& NOX::Petsc::Group::userInterface [protected] |
Reference to the user supplied interface functions.
Definition at line 228 of file NOX_Petsc_Group.H.
Referenced by computeF(), and computeJacobian().