00001 // $Id: NOX_Direction_Broyden.H,v 1.11 2007/06/21 16:22:46 rhoope Exp $ 00002 // $Source: /space/CVS/Trilinos/packages/nox/src/NOX_Direction_Broyden.H,v $ 00003 00004 //@HEADER 00005 // ************************************************************************ 00006 // 00007 // NOX: An Object-Oriented Nonlinear Solver Package 00008 // Copyright (2002) Sandia Corporation 00009 // 00010 // LOCA: Library of Continuation Algorithms Package 00011 // Copyright (2005) Sandia Corporation 00012 // 00013 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00014 // license for use of this work by or on behalf of the U.S. Government. 00015 // 00016 // This library is free software; you can redistribute it and/or modify 00017 // it under the terms of the GNU Lesser General Public License as 00018 // published by the Free Software Foundation; either version 2.1 of the 00019 // License, or (at your option) any later version. 00020 // 00021 // This library is distributed in the hope that it will be useful, but 00022 // WITHOUT ANY WARRANTY; without even the implied warranty of 00023 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00024 // Lesser General Public License for more details. 00025 // 00026 // You should have received a copy of the GNU Lesser General Public 00027 // License along with this library; if not, write to the Free Software 00028 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00029 // USA 00030 // 00031 // Questions? Contact Roger Pawlowski (rppawlo@sandia.gov) or 00032 // Eric Phipps (etphipp@sandia.gov), Sandia National Laboratories. 00033 // ************************************************************************ 00034 // CVS Information 00035 // $Source: /space/CVS/Trilinos/packages/nox/src/NOX_Direction_Broyden.H,v $ 00036 // $Author: rhoope $ 00037 // $Date: 2007/06/21 16:22:46 $ 00038 // $Revision: 1.11 $ 00039 // ************************************************************************ 00040 //@HEADER 00041 00042 #ifndef NOX_DIRECTION_BROYDEN_H 00043 #define NOX_DIRECTION_BROYDEN_H 00044 00045 #include "NOX_Common.H" 00046 00047 #include "NOX_Direction_Generic.H" // base class 00048 #include "NOX_Direction_Utils_InexactNewton.H" // class data element 00049 #include "Teuchos_ParameterList.hpp" // class data element 00050 #include "Teuchos_RCP.hpp" // class data element 00051 00052 // Forward declaration 00053 namespace NOX { 00054 class Utils; 00055 namespace Solver { 00056 class LineSearchBased; 00057 } 00058 } 00059 00060 namespace NOX { 00061 namespace Direction { 00062 00064 00123 class Broyden : public Generic { 00124 00125 public: 00126 00127 //---------------------------------------------------------------------- 00128 // MemoryUnit helper class 00129 //---------------------------------------------------------------------- 00130 00141 class BroydenMemoryUnit { 00142 00143 public: 00144 00150 BroydenMemoryUnit(); 00151 00157 ~BroydenMemoryUnit(); 00158 00159 00171 void reset(const NOX::Abstract::Vector& d); 00172 00180 void setStep(double step); 00181 00183 Teuchos::RCP<const NOX::Abstract::Vector> sPtr() const; 00184 00186 double step() const; 00187 00189 double sNormSqr() const; 00190 00191 private: 00192 00194 Teuchos::RCP<NOX::Abstract::Vector> sptr; 00195 00202 double lambda; 00203 00205 double snormsqr; 00206 00207 }; 00208 00209 //---------------------------------------------------------------------- 00210 // Memory helper class 00211 //---------------------------------------------------------------------- 00212 00228 class BroydenMemory { 00229 00230 public: 00231 00233 00236 BroydenMemory(); 00237 00239 00242 ~BroydenMemory(); 00243 00245 00251 void reset(int m); 00252 00254 00257 void reset(); 00258 00260 00274 void push(const NOX::Abstract::Vector& d); 00275 00277 bool empty() const; 00278 00280 int size() const; 00281 00283 00287 BroydenMemoryUnit& operator[](int i); 00288 00289 private: 00290 00292 int mMax; 00293 00295 00303 vector<int> index; 00304 00306 00313 vector<BroydenMemoryUnit> memory; 00314 }; 00315 00316 //---------------------------------------------------------------------- 00317 // END HELPER CLASSES 00318 //---------------------------------------------------------------------- 00319 00320 public: 00321 00323 Broyden(const Teuchos::RCP<NOX::GlobalData>& gd, 00324 Teuchos::ParameterList& params); 00325 00327 virtual ~Broyden(); 00328 00329 // derived 00330 virtual bool reset(const Teuchos::RCP<NOX::GlobalData>& gd, 00331 Teuchos::ParameterList& params); 00332 00334 virtual bool compute(NOX::Abstract::Vector& dir, NOX::Abstract::Group& grp, 00335 const NOX::Solver::Generic& solver); 00336 00337 // derived 00338 virtual bool compute(NOX::Abstract::Vector& dir, NOX::Abstract::Group& grp, 00339 const NOX::Solver::LineSearchBased& solver); 00340 00341 private: 00342 00344 00355 void throwError(const string& functionName, const string& errorMsg); 00356 00358 00368 bool doRestart(NOX::Abstract::Group& soln, 00369 const NOX::Solver::LineSearchBased& solver); 00370 00371 private: 00372 00374 Teuchos::RCP<NOX::GlobalData> globalDataPtr; 00375 00377 Teuchos::RCP<NOX::Utils> utils; 00378 00380 00384 Teuchos::ParameterList* lsParamsPtr; 00385 00387 Teuchos::RCP<NOX::Abstract::Group> oldJacobianGrpPtr; 00388 00393 int cnt; 00394 00399 int cntMax; 00400 00402 double convRate; 00403 00405 double maxConvRate; 00406 00408 00409 int memorySizeMax; 00410 00412 BroydenMemory memory; 00413 00415 NOX::Direction::Utils::InexactNewton inexactNewtonUtils; 00416 00417 }; 00418 } // namespace Direction 00419 } // namespace NOX 00420 00421 #endif