00001 //@HEADER 00002 // ************************************************************************ 00003 // 00004 // NOX: An Object-Oriented Nonlinear Solver Package 00005 // Copyright (2002) Sandia Corporation 00006 // 00007 // LOCA: Library of Continuation Algorithms Package 00008 // Copyright (2005) Sandia Corporation 00009 // 00010 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00011 // license for use of this work by or on behalf of the U.S. Government. 00012 // 00013 // This library is free software; you can redistribute it and/or modify 00014 // it under the terms of the GNU Lesser General Public License as 00015 // published by the Free Software Foundation; either version 2.1 of the 00016 // License, or (at your option) any later version. 00017 // 00018 // This library is distributed in the hope that it will be useful, but 00019 // WITHOUT ANY WARRANTY; without even the implied warranty of 00020 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00021 // Lesser General Public License for more details. 00022 // 00023 // You should have received a copy of the GNU Lesser General Public 00024 // License along with this library; if not, write to the Free Software 00025 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00026 // USA 00027 // 00028 // Questions? Contact Roger Pawlowski (rppawlo@sandia.gov) or 00029 // Eric Phipps (etphipp@sandia.gov), Sandia National Laboratories. 00030 // ************************************************************************ 00031 // CVS Information 00032 // $Source: /space/CVS/Trilinos/packages/nox/src-epetra/NOX_Epetra_MatrixFree.H,v $ 00033 // $Author: rhoope $ 00034 // $Date: 2007/06/21 16:22:49 $ 00035 // $Revision: 1.17 $ 00036 // ************************************************************************ 00037 //@HEADER 00038 00039 #ifndef NOX_EPETRA_MATRIXFREE_H 00040 #define NOX_EPETRA_MATRIXFREE_H 00041 00042 #include "Epetra_Comm.h" 00043 00044 #include "Epetra_Operator.h" // base class 00045 #include "NOX_Epetra_Interface_Jacobian.H" // base class 00046 #include "NOX_Utils.H" 00047 00048 #include "NOX_Common.H" 00049 #include "Epetra_Import.h" 00050 #include "NOX_Epetra_Vector.H" 00051 #include "Teuchos_RCP.hpp" 00052 00053 // Forward Declarations 00054 class Epetra_Comm; 00055 class Epetra_Map; 00056 00057 namespace NOX { 00058 namespace Abstract { 00059 class Group; 00060 } 00061 namespace Epetra { 00062 namespace Interface { 00063 class Required; 00064 } 00065 } 00066 } 00067 00068 namespace NOX { 00069 00070 namespace Epetra { 00071 00084 class MatrixFree : public Epetra_Operator, 00085 public virtual NOX::Epetra::Interface::Jacobian { 00086 00087 public: 00088 00090 enum DifferenceType {Forward, Backward, Centered}; 00091 00096 MatrixFree(Teuchos::ParameterList& printParams, 00097 const Teuchos::RCP<NOX::Epetra::Interface::Required>& i, 00098 const NOX::Epetra::Vector& cloneVector, 00099 bool useNewPerturbation = false); 00100 00102 virtual ~MatrixFree(); 00103 00105 00112 virtual int SetUseTranspose(bool UseTranspose); 00113 00115 00121 virtual int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const; 00122 00124 00133 virtual int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const; 00134 00136 /* Returns the quantity \f$ \| A \|_\infty\f$ such that 00137 \f[\| A \|_\infty = \max_{1\lei\lem} \sum_{j=1}^n |a_{ij}| \f]. 00138 00139 \warning This method must not be called unless HasNormInf() returns true. */ 00140 virtual double NormInf() const; 00141 00143 virtual const char* Label () const; 00144 00146 virtual bool UseTranspose() const; 00147 00149 virtual bool HasNormInf() const; 00150 00152 virtual const Epetra_Comm & Comm() const; 00153 00155 virtual const Epetra_Map& OperatorDomainMap () const; 00156 00158 virtual const Epetra_Map& OperatorRangeMap () const; 00159 00161 virtual bool computeJacobian(const Epetra_Vector& x, Epetra_Operator& Jac); 00162 00164 virtual void setDifferenceMethod( DifferenceType type ); 00165 00167 void setLambda(double lambda_); 00168 00170 void setComputePerturbation(bool bVal); 00171 00173 void setPerturbation(double eta_); 00174 00176 double getPerturbation() const; 00177 00179 void setGroupForComputeF(const NOX::Abstract::Group& group); 00180 00181 protected: 00182 00184 string label; 00185 00187 Teuchos::RCP<NOX::Epetra::Interface::Required> interface; 00188 00190 NOX::Epetra::Vector currentX; 00191 00193 mutable NOX::Epetra::Vector perturbX; 00194 00196 mutable NOX::Epetra::Vector fo; 00197 00199 mutable NOX::Epetra::Vector fp; 00200 00202 mutable Teuchos::RCP<NOX::Epetra::Vector> fmPtr; 00203 00205 00207 Teuchos::RCP<const Epetra_Map> epetraMap; 00208 00210 DifferenceType diffType; 00211 00213 double lambda; 00214 00216 mutable double eta; 00217 00219 double userEta; 00220 00222 bool computeEta; 00223 00225 bool useGroupForComputeF; 00226 00228 bool useNewPerturbation; 00229 00231 Teuchos::RCP<NOX::Abstract::Group> groupPtr; 00232 00234 NOX::Utils utils; 00235 00236 }; 00237 } // namespace Epetra 00238 } // namespace NOX 00239 00240 #endif /* NOX_EPETRA_MATRIXFREE_H */