NOX_TSF_Group.H
Go to the documentation of this file.
00001 // $Id$ 
00002 // $Source$ 
00003 
00004 //@HEADER
00005 // ************************************************************************
00006 // 
00007 //            NOX: An Object-Oriented Nonlinear Solver Package
00008 //                 Copyright (2002) 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 // Questions? Contact Tammy Kolda (tgkolda@sandia.gov) or Roger Pawlowski
00028 // (rppawlo@sandia.gov), Sandia National Laboratories.
00029 // 
00030 // ************************************************************************
00031 //@HEADER
00032 
00033 #ifndef NOX_TSF_GROUP_H
00034 #define NOX_TSF_GROUP_H
00035 
00036 #include "NOX_Abstract_Group.H" // base class
00037 #include "Teuchos_ParameterList.hpp"  // base class
00038 
00039 #include "NOX_Common.H"             // class data element (string)
00040 #include "NOX_TSF_Vector.H"     // class data element
00041 #include "TSFVectorType.hpp"
00042 #include "TSFVectorSpaceDecl.hpp"
00043 #include "TSFLinearSolverDecl.hpp"
00044 #include "TSFLinearOperatorDecl.hpp"
00045 #include "SundanceObjectWithVerbosity.hpp"
00046 #include "TSFNonlinearOperator.hpp" // nonlinear operator
00047 
00048 // Forward declares
00049 namespace Teuchos 
00050 {
00051   namespace Parameter 
00052   {
00053     class List;
00054   }
00055 }
00056 
00057 namespace NOX {
00058   namespace TSF {
00059 
00060     class Group : public virtual NOX::Abstract::Group,
00061     public TSFExtended::DefaultObjectWithVerbosity
00062     {
00063 
00064     public:
00065 
00066       /*! \brief Constructor.
00067        *
00068        * Construct a group given an initial condition, the nonlinear operator that 
00069        * describes the problem to be solved, and the linear solver
00070        */
00071       Group(const TSFExtended::Vector<double>& initcond, 
00072             const TSFExtended::NonlinearOperator<double>& nonlinOp,
00073             const TSFExtended::LinearSolver<double>& solver);
00074 
00075       /*! \brief Constructor.
00076        *
00077        * Construct a group given an initial condition and the nonlinear operator that 
00078        * describes the problem to be solved.
00079        */
00080       Group(const TSFExtended::NonlinearOperator<double>& nonlinOp,
00081             const TSFExtended::LinearSolver<double>& solver);
00082 
00083       /*! \brief Constructor.
00084        *
00085        * Construct a group given an initial condition, the nonlinear operator that 
00086        * describes the problem to be solved, the linear solver, and user-specified precision.
00087        */
00088       Group(const TSFExtended::Vector<double>& initcond, 
00089             const TSFExtended::NonlinearOperator<double>& nonlinOp,
00090             const TSFExtended::LinearSolver<double>& solver,
00091             int numdigits);
00092 
00093       /*! \brief Constructor.
00094        *
00095        * Construct a group given an initial condition, the nonlinear operator that 
00096        * describes the problem to be solved, and user-specified precision.
00097        */
00098       Group(const TSFExtended::NonlinearOperator<double>& nonlinOp,
00099             const TSFExtended::LinearSolver<double>& solver,
00100             int numdigits);
00101 
00102 
00103 
00104 
00105       /*! \brief Copy constructor
00106        *
00107        * Construct a new group given an existing group to copy from.
00108        */
00109       Group(const NOX::TSF::Group& source, NOX::CopyType type = DeepCopy);
00110 
00111       //! Destructor.
00112       ~Group();
00113 
00114 
00115       NOX::Abstract::Group& operator=(const NOX::Abstract::Group& source);
00116       //! See above.
00117       NOX::Abstract::Group& operator=(const NOX::TSF::Group& source);
00118 
00119       /** @name "Compute" functions. */
00120       //@{
00121 
00122       void setX(const NOX::Abstract::Vector& y);
00123       //! See above
00124       void setX(const NOX::TSF::Vector& y);
00125 
00126       void computeX(const NOX::Abstract::Group& grp, 
00127                     const NOX::Abstract::Vector& d, 
00128                     double step);
00129       //! See above.
00130       void computeX(const NOX::TSF::Group& grp, 
00131                     const NOX::TSF::Vector& d, 
00132                     double step);
00133 
00134       NOX::Abstract::Group::ReturnType computeF();
00135 
00136       NOX::Abstract::Group::ReturnType computeJacobian();
00137 
00138       NOX::Abstract::Group::ReturnType computeGradient();
00139 
00140       NOX::Abstract::Group::ReturnType computeNewton(Teuchos::ParameterList& params);
00141 
00142       //@}
00143 
00144       /** @name Jacobian operations.
00145        *
00146        * Operations using the Jacobian matrix. These may not be defined in
00147        * matrix-free scenarios. */
00148 
00149       //@{
00150   
00151       NOX::Abstract::Group::ReturnType 
00152       applyJacobian(const NOX::TSF::Vector& input, 
00153                     NOX::TSF::Vector& result) const;
00154 
00155       //! See above
00156       NOX::Abstract::Group::ReturnType 
00157       applyJacobian(const NOX::Abstract::Vector& input, 
00158                     NOX::Abstract::Vector& result) const;
00159 
00160       NOX::Abstract::Group::ReturnType 
00161       applyJacobianTranspose(const NOX::TSF::Vector& input, 
00162                              NOX::TSF::Vector& result) const;
00163 
00164       //! See above
00165       NOX::Abstract::Group::ReturnType 
00166       applyJacobianTranspose(const NOX::Abstract::Vector& input, 
00167                              NOX::Abstract::Vector& result) const;
00168 
00169       NOX::Abstract::Group::ReturnType 
00170       applyJacobianInverse(Teuchos::ParameterList& params, 
00171                            const NOX::TSF::Vector& input, 
00172                            NOX::TSF::Vector& result) const;
00173 
00174       NOX::Abstract::Group::ReturnType 
00175       applyJacobianInverse(Teuchos::ParameterList& params, 
00176                            const NOX::Abstract::Vector& input, 
00177                            NOX::Abstract::Vector& result) const;
00178   
00179       //@}
00180 
00181       /** @name "Is" functions
00182        *
00183        * Checks to see if various objects have been computed. Returns true
00184        * if the corresponding "compute" function has been called since the
00185        * last update to the solution vector (via instantiation or
00186        * computeX). */
00187       //@{
00188 
00189       bool isF() const;
00190       bool isJacobian() const;
00191       bool isGradient() const;
00192       bool isNewton() const;
00193 
00194       //@}
00195 
00196       /** @name "Get" functions 
00197        *
00198        * Note that these function do not check whether or not the vectors
00199        * are valid. Must use the "Is" functions for that purpose. */
00200       //@{
00201 
00202       const NOX::Abstract::Vector& getX() const;
00203 
00204       const NOX::Abstract::Vector& getF() const;
00205   
00206       double getNormF() const;
00207 
00208       const NOX::Abstract::Vector& getGradient() const;
00209 
00210       const NOX::Abstract::Vector& getNewton() const;
00211 
00212       //@}
00213 
00214 #ifdef TRILINOS_6
00215       virtual NOX::Abstract::Group* clone(NOX::CopyType type = NOX::DeepCopy) const;
00216 #else
00217       virtual RCP<NOX::Abstract::Group> clone(NOX::CopyType type = NOX::DeepCopy) const;
00218 #endif
00219 
00220       //! Print out the group
00221       void print() const;
00222 
00223     protected:
00224 
00225       //! resets all isValid flags to false
00226       void resetIsValid();
00227 
00228     protected:
00229 
00230       //! user-specified precision
00231       int precision; 
00232       
00233       /** @name Vectors */
00234       //@{
00235       //! Solution vector.
00236       NOX::TSF::Vector xVector;
00237       //! Right-hand-side vector (function evaluation).
00238       NOX::TSF::Vector fVector;
00239       //! Newton direction vector.
00240       NOX::TSF::Vector newtonVector;
00241       //! Gradient vector (steepest descent vector).
00242       NOX::TSF::Vector gradientVector;
00243       //@}
00244 
00245       //! Linear solver that will be used to solve J*step = resid
00246       mutable TSFExtended::LinearSolver<double> solver;
00247 
00248       //! Linear solver that will be used to solve J*step = resid
00249       TSFExtended::LinearOperator<double> jacobian;
00250 
00251 
00252       //! Problem interface: reference to nonlinear operator passed to group
00253       TSFExtended::NonlinearOperator<double> nonlinearOp;
00254 
00255       /** @name IsValid flags 
00256        *  
00257        * True if the current solution is up-to-date with respect to the
00258        * currect xVector. */
00259       //@{
00260       bool isValidF;
00261       bool isValidJacobian;
00262       bool isValidGradient;
00263       bool isValidNewton;
00264       //@}
00265   
00266       //! Norm of F
00267       double normF;
00268 
00269     };
00270 
00271   } // namespace TSF
00272 } // namespace NOX
00273 
00274 
00275 #endif

Site Contact