#include <NOX_Epetra_MatrixFree.H>
Public Types | |
enum | DifferenceType { Forward, Backward, Centered } |
Define types for use of the perturbation parameter ![]() | |
Public Member Functions | |
MatrixFree (Teuchos::ParameterList &printParams, const Teuchos::RCP< NOX::Epetra::Interface::Required > &i, const NOX::Epetra::Vector &cloneVector, bool useNewPerturbation=false) | |
Constructor. | |
virtual | ~MatrixFree () |
Pure virtual destructor. | |
virtual int | SetUseTranspose (bool UseTranspose) |
If set true, transpose of this operator will be applied. | |
virtual int | Apply (const Epetra_MultiVector &X, Epetra_MultiVector &Y) const |
Returns the result of a Epetra_Operator applied to a Epetra_MultiVector X in Y. | |
virtual int | ApplyInverse (const Epetra_MultiVector &X, Epetra_MultiVector &Y) const |
Returns the result of a Epetra_Operator inverse applied to an Epetra_MultiVector X in Y. | |
virtual double | NormInf () const |
Returns the infinity norm of the global matrix. | |
virtual const char * | Label () const |
Returns a character string describing the operator. | |
virtual bool | UseTranspose () const |
Returns the current UseTranspose setting. | |
virtual bool | HasNormInf () const |
Returns true if the this object can provide an approximate Inf-norm, false otherwise. | |
virtual const Epetra_Comm & | Comm () const |
Returns a reference to the Epetra_Comm communicator associated with this operator. | |
virtual const Epetra_Map & | OperatorDomainMap () const |
Returns the Epetra_BlockMap object associated with the domain of this matrix operator. | |
virtual const Epetra_Map & | OperatorRangeMap () const |
Returns the Epetra_BlockMap object associated with the range of this matrix operator. | |
virtual bool | computeJacobian (const Epetra_Vector &x, Epetra_Operator &Jac) |
Compute Jacobian given the specified input vector, x. Returns true if computation was successful. | |
virtual void | setDifferenceMethod (DifferenceType type) |
Set the type of perturbation method used (default is Forward). | |
void | setLambda (double lambda_) |
Allows the user to change the value of ![]() | |
void | setComputePerturbation (bool bVal) |
Flag that toggles whether MatrixFree should compute the perturbation parameter ![]() | |
void | setPerturbation (double eta_) |
Set the perturbation parameter ![]() | |
double | getPerturbation () const |
Returns the most recently used value of the perturbation parameter ![]() | |
void | setGroupForComputeF (const NOX::Abstract::Group &group) |
Clone a NOX::Abstract::Group derived object and use the computeF() method of that group for the perturbation instead of the NOX::Epetra::Interface::Required::computeF() method. This is required for LOCA to get the operators correct during homotopy. | |
Protected Attributes | |
string | label |
Label for matrix. | |
Teuchos::RCP < NOX::Epetra::Interface::Required > | interface |
User provided interface function. | |
NOX::Epetra::Vector | currentX |
The current solution vector. | |
NOX::Epetra::Vector | perturbX |
Perturbed solution vector. | |
NOX::Epetra::Vector | fo |
Function evaluation at currentX. | |
NOX::Epetra::Vector | fp |
Function evaluation at perturbX. | |
Teuchos::RCP< NOX::Epetra::Vector > | fmPtr |
Optional pointer to function evaluation at -perturbX - needed only for centered finite differencing. | |
Teuchos::RCP< const Epetra_Map > | epetraMap |
Epetra_Map object used in the returns of the Epetra_Operator derived methods. | |
DifferenceType | diffType |
Define types for use of the perturbation parameter ![]() | |
double | lambda |
Scale factor for eta calculation. | |
double | eta |
Perturbation value to use in the directional derivative. | |
double | userEta |
User specified perturbation value to use in the directional derivative. Set by setPerturbation(). | |
bool | computeEta |
Flag that determines if we should calculate eta or use a value set by the user. | |
bool | useGroupForComputeF |
Flag to enables the use of a group instead of the interface for the computeF() calls in the directional difference calculation. | |
bool | useNewPerturbation |
A new perturbation formulation developed by C. T. Kelley and A. G. Salinger can be used by the constructor flag useNewPerturbation = true. | |
Teuchos::RCP < NOX::Abstract::Group > | groupPtr |
Pointer to the group for possible use in computeF() calls. | |
NOX::Utils | utils |
Printing utilities. |
Matrix-Free Newton-Krylov is a method that takes advantage of the fact the Newton Krylov solvers do not require an explicit Jacobian matrix. Newton-Krylov solvers only require the matrix-vector product in the iteration sequence. This product can approximated by the following:
where is the Jacobian,
is the function evaluation,
is the solution vector,
is the vector to be operated on, and
is a scalar perturbation calculated by:
where .
Definition at line 84 of file NOX_Epetra_MatrixFree.H.
Define types for use of the perturbation parameter .
Definition at line 90 of file NOX_Epetra_MatrixFree.H.
MatrixFree::MatrixFree | ( | Teuchos::ParameterList & | printParams, | |
const Teuchos::RCP< NOX::Epetra::Interface::Required > & | i, | |||
const NOX::Epetra::Vector & | cloneVector, | |||
bool | useNewPerturbation = false | |||
) |
Constructor.
The vector x
is used to clone the solution vector.
Definition at line 54 of file NOX_Epetra_MatrixFree.C.
References currentX, epetraMap, fo, fp, NOX::Epetra::Vector::getEpetraVector(), NOX::Epetra::Vector::init(), and perturbX.
MatrixFree::~MatrixFree | ( | ) | [virtual] |
int MatrixFree::SetUseTranspose | ( | bool | UseTranspose | ) | [virtual] |
If set true, transpose of this operator will be applied.
This flag allows the transpose of the given operator to be used implicitly. Setting this flag affects only the Apply() and ApplyInverse() methods. If the implementation of this interface does not support transpose use, this method should return a value of -1.
UseTranspose | -If true, multiply by the transpose of operator, otherwise just use operator. |
Definition at line 100 of file NOX_Epetra_MatrixFree.C.
References NOX::Utils::out(), and utils.
int MatrixFree::Apply | ( | const Epetra_MultiVector & | X, | |
Epetra_MultiVector & | Y | |||
) | const [virtual] |
Returns the result of a Epetra_Operator applied to a Epetra_MultiVector X in Y.
X | - A Epetra_MultiVector of dimension NumVectors to multiply with matrix. | |
Y | -A Epetra_MultiVector of dimension NumVectors containing result. |
Definition at line 110 of file NOX_Epetra_MatrixFree.C.
References computeEta, NOX::Epetra::Vector::CreateView, currentX, diffType, eta, fmPtr, fo, fp, NOX::Epetra::Vector::getEpetraVector(), NOX::Epetra::Vector::getVectorSpace(), groupPtr, interface, lambda, NOX::Epetra::Interface::Required::MF_Res, NOX::Epetra::Vector::norm(), perturbX, NOX::Epetra::Vector::scale(), useGroupForComputeF, useNewPerturbation, and userEta.
int MatrixFree::ApplyInverse | ( | const Epetra_MultiVector & | X, | |
Epetra_MultiVector & | Y | |||
) | const [virtual] |
Returns the result of a Epetra_Operator inverse applied to an Epetra_MultiVector X in Y.
X | - A Epetra_MultiVector of dimension NumVectors to solve for. | |
Y | -A Epetra_MultiVector of dimension NumVectors containing result. |
Definition at line 217 of file NOX_Epetra_MatrixFree.C.
References NOX::Utils::out(), and utils.
double MatrixFree::NormInf | ( | ) | const [virtual] |
Returns the infinity norm of the global matrix.
Definition at line 225 of file NOX_Epetra_MatrixFree.C.
References NOX::Utils::out(), and utils.
const char * MatrixFree::Label | ( | ) | const [virtual] |
Returns a character string describing the operator.
Definition at line 234 of file NOX_Epetra_MatrixFree.C.
References label.
bool MatrixFree::UseTranspose | ( | ) | const [virtual] |
bool MatrixFree::HasNormInf | ( | ) | const [virtual] |
Returns true if the this object can provide an approximate Inf-norm, false otherwise.
Definition at line 244 of file NOX_Epetra_MatrixFree.C.
const Epetra_Comm & MatrixFree::Comm | ( | ) | const [virtual] |
Returns a reference to the Epetra_Comm communicator associated with this operator.
Definition at line 249 of file NOX_Epetra_MatrixFree.C.
References currentX, and NOX::Epetra::Vector::getEpetraVector().
const Epetra_Map & MatrixFree::OperatorDomainMap | ( | ) | const [virtual] |
Returns the Epetra_BlockMap object associated with the domain of this matrix operator.
Definition at line 253 of file NOX_Epetra_MatrixFree.C.
References epetraMap.
const Epetra_Map & MatrixFree::OperatorRangeMap | ( | ) | const [virtual] |
Returns the Epetra_BlockMap object associated with the range of this matrix operator.
Definition at line 258 of file NOX_Epetra_MatrixFree.C.
References epetraMap.
bool MatrixFree::computeJacobian | ( | const Epetra_Vector & | x, | |
Epetra_Operator & | Jac | |||
) | [virtual] |
Compute Jacobian given the specified input vector, x. Returns true if computation was successful.
Implements NOX::Epetra::Interface::Jacobian.
Definition at line 263 of file NOX_Epetra_MatrixFree.C.
References currentX, fo, NOX::Epetra::Vector::getEpetraVector(), groupPtr, interface, NOX::Epetra::Interface::Required::MF_Jac, and useGroupForComputeF.
void MatrixFree::setDifferenceMethod | ( | DifferenceType | type | ) | [virtual] |
Set the type of perturbation method used (default is Forward).
Definition at line 285 of file NOX_Epetra_MatrixFree.C.
References diffType.
void MatrixFree::setLambda | ( | double | lambda_ | ) |
Allows the user to change the value of in the perturbation calculation.
Definition at line 290 of file NOX_Epetra_MatrixFree.C.
References lambda.
void MatrixFree::setComputePerturbation | ( | bool | bVal | ) |
Flag that toggles whether MatrixFree should compute the perturbation parameter or use a value supplied by the user through setPerturbation().
Definition at line 295 of file NOX_Epetra_MatrixFree.C.
References computeEta.
void MatrixFree::setPerturbation | ( | double | eta_ | ) |
Set the perturbation parameter .
Definition at line 300 of file NOX_Epetra_MatrixFree.C.
References computeEta, and userEta.
double MatrixFree::getPerturbation | ( | ) | const |
Returns the most recently used value of the perturbation parameter .
Definition at line 306 of file NOX_Epetra_MatrixFree.C.
References eta.
void MatrixFree::setGroupForComputeF | ( | const NOX::Abstract::Group & | group | ) |
Clone a NOX::Abstract::Group derived object and use the computeF() method of that group for the perturbation instead of the NOX::Epetra::Interface::Required::computeF() method. This is required for LOCA to get the operators correct during homotopy.
Definition at line 311 of file NOX_Epetra_MatrixFree.C.
References NOX::Abstract::Group::clone(), groupPtr, and useGroupForComputeF.
string NOX::Epetra::MatrixFree::label [protected] |
Teuchos::RCP<NOX::Epetra::Interface::Required> NOX::Epetra::MatrixFree::interface [protected] |
User provided interface function.
Definition at line 187 of file NOX_Epetra_MatrixFree.H.
Referenced by Apply(), and computeJacobian().
NOX::Epetra::Vector NOX::Epetra::MatrixFree::currentX [protected] |
The current solution vector.
Definition at line 190 of file NOX_Epetra_MatrixFree.H.
Referenced by Apply(), Comm(), computeJacobian(), and MatrixFree().
NOX::Epetra::Vector NOX::Epetra::MatrixFree::perturbX [mutable, protected] |
Perturbed solution vector.
Definition at line 193 of file NOX_Epetra_MatrixFree.H.
Referenced by Apply(), and MatrixFree().
NOX::Epetra::Vector NOX::Epetra::MatrixFree::fo [mutable, protected] |
Function evaluation at currentX.
Definition at line 196 of file NOX_Epetra_MatrixFree.H.
Referenced by Apply(), computeJacobian(), and MatrixFree().
NOX::Epetra::Vector NOX::Epetra::MatrixFree::fp [mutable, protected] |
Function evaluation at perturbX.
Definition at line 199 of file NOX_Epetra_MatrixFree.H.
Referenced by Apply(), and MatrixFree().
Teuchos::RCP<NOX::Epetra::Vector> NOX::Epetra::MatrixFree::fmPtr [mutable, protected] |
Optional pointer to function evaluation at -perturbX - needed only for centered finite differencing.
Definition at line 202 of file NOX_Epetra_MatrixFree.H.
Referenced by Apply().
Teuchos::RCP<const Epetra_Map> NOX::Epetra::MatrixFree::epetraMap [protected] |
Epetra_Map object used in the returns of the Epetra_Operator derived methods.
If the user is using Epetra_BlockMaps, then NOX::Epetra::MatrixFree must create an equivalent Epetra_Map from the Epetra_BlockMap that can be used as the return object of the OperatorDomainMap() and OperatorRangeMap() methods.
Definition at line 207 of file NOX_Epetra_MatrixFree.H.
Referenced by MatrixFree(), OperatorDomainMap(), and OperatorRangeMap().
DifferenceType NOX::Epetra::MatrixFree::diffType [protected] |
Define types for use of the perturbation parameter .
Definition at line 210 of file NOX_Epetra_MatrixFree.H.
Referenced by Apply(), and setDifferenceMethod().
double NOX::Epetra::MatrixFree::lambda [protected] |
Scale factor for eta calculation.
Definition at line 213 of file NOX_Epetra_MatrixFree.H.
Referenced by Apply(), and setLambda().
double NOX::Epetra::MatrixFree::eta [mutable, protected] |
Perturbation value to use in the directional derivative.
Definition at line 216 of file NOX_Epetra_MatrixFree.H.
Referenced by Apply(), and getPerturbation().
double NOX::Epetra::MatrixFree::userEta [protected] |
User specified perturbation value to use in the directional derivative. Set by setPerturbation().
Definition at line 219 of file NOX_Epetra_MatrixFree.H.
Referenced by Apply(), and setPerturbation().
bool NOX::Epetra::MatrixFree::computeEta [protected] |
Flag that determines if we should calculate eta or use a value set by the user.
Definition at line 222 of file NOX_Epetra_MatrixFree.H.
Referenced by Apply(), setComputePerturbation(), and setPerturbation().
bool NOX::Epetra::MatrixFree::useGroupForComputeF [protected] |
Flag to enables the use of a group instead of the interface for the computeF() calls in the directional difference calculation.
Definition at line 225 of file NOX_Epetra_MatrixFree.H.
Referenced by Apply(), computeJacobian(), and setGroupForComputeF().
bool NOX::Epetra::MatrixFree::useNewPerturbation [protected] |
A new perturbation formulation developed by C. T. Kelley and A. G. Salinger can be used by the constructor flag useNewPerturbation = true.
Definition at line 228 of file NOX_Epetra_MatrixFree.H.
Referenced by Apply().
Teuchos::RCP<NOX::Abstract::Group> NOX::Epetra::MatrixFree::groupPtr [protected] |
Pointer to the group for possible use in computeF() calls.
Definition at line 231 of file NOX_Epetra_MatrixFree.H.
Referenced by Apply(), computeJacobian(), and setGroupForComputeF().
NOX::Utils NOX::Epetra::MatrixFree::utils [protected] |
Printing utilities.
Definition at line 234 of file NOX_Epetra_MatrixFree.H.
Referenced by ApplyInverse(), NormInf(), and SetUseTranspose().