InitialInterpolatedLineSearch.cpp

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 1999, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** ****************************************************************** */
00020 
00021 // $Revision: 1.3 $
00022 // $Date: 2003/04/02 22:02:33 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/analysis/algorithm/equiSolnAlgo/InitialInterpolatedLineSearch.cpp,v $
00024 
00025 // Written: fmk 
00026 // Created: 11/01
00027 // 
00028 // What: "@(#)InitialInterpolatedLineSearch.h, revA"
00029 
00030 #include <InitialInterpolatedLineSearch.h>
00031 #include <IncrementalIntegrator.h>
00032 #include <LinearSOE.h>
00033 #include <Channel.h>
00034 #include <FEM_ObjectBroker.h>
00035 #include <Vector.h>
00036 #include <math.h>
00037 
00038 
00039 InitialInterpolatedLineSearch::InitialInterpolatedLineSearch(double tol, int mIter, double mnEta,
00040                                                              double mxEta, int pFlag)
00041 :LineSearch(LINESEARCH_TAGS_InitialInterpolatedLineSearch),
00042  x(0), tolerance(tol), maxIter(mIter), minEta(mnEta), maxEta(mxEta), printFlag(pFlag)
00043 {   
00044 
00045 }
00046 
00047 InitialInterpolatedLineSearch::~InitialInterpolatedLineSearch()
00048 {
00049   if (x != 0)
00050     delete x;
00051 }
00052 
00053 int 
00054 InitialInterpolatedLineSearch::newStep(LinearSOE &theSOE)
00055 {
00056   const Vector &dU = theSOE.getX();
00057 
00058   if (x == 0)
00059     x = new Vector(dU);
00060 
00061   if (x->Size() != dU.Size()) {
00062     delete x;
00063     x = new Vector(dU);
00064   }
00065 
00066   return 0;
00067 }
00068 
00069 int 
00070 InitialInterpolatedLineSearch::search(double s0, 
00071                                       double s1, 
00072                                       LinearSOE &theSOE, 
00073                                       IncrementalIntegrator &theIntegrator)
00074 {
00075   double s = s1;
00076 
00077   //intialize r = ratio of residuals 
00078   double r0 = 0.0;
00079 
00080   if ( s0 != 0.0 ) 
00081     r0 = fabs( s / s0 );
00082         
00083   if  (r0 <= tolerance )
00084     return 0; // Line Search Not Required Residual Decrease Less Than Tolerance
00085 
00086   double eta = 1.0;     //initial value of line search parameter
00087   double etaPrev = 1.0;
00088   double r = r0;
00089 
00090   const Vector &dU = theSOE.getX();
00091 
00092   int count = 0; //intial value of iteration counter 
00093 
00094   if (printFlag == 0) {
00095     opserr << "InitialInterpolated Line Search - initial       "
00096          << "    eta : " << eta 
00097          << " , Ratio |s/s0| = " << r0 << endln;
00098   }    
00099 
00100 
00101   // Solution procedure follows the one in Crissfields book.
00102   // (M.A. Crissfield, Nonlinear Finite Element Analysis of Solid and Structures, Wiley. 97).
00103   // NOTE: it is not quite linear interpolation/false-position/regula-falsi as eta(0) = 0.0
00104   // does not change. uses eta(i) = eta(i-1)*s0
00105   //                                -----------
00106   //                                s0 - s(i-1)  to compute eta(i)
00107 
00108 
00109   while ( r > tolerance  &&  count < maxIter ) {
00110 
00111     count++;
00112     
00113     eta *=  s0 / (s0 - s); 
00114 
00115     //-- want to put limits on eta(i)
00116     if (eta > maxEta)  eta = maxEta;
00117     if (r   > r0    )  eta =  1.0;
00118     if (eta < minEta)  eta = minEta;
00119    
00120     
00121     //dx = ( eta * dx0 ); 
00122     *x = dU;
00123     *x *= eta-etaPrev;
00124             
00125     if (theIntegrator.update(*x) < 0) {
00126       opserr << "WARNInG InitialInterpolatedLineSearch::search() -";
00127       opserr << "the Integrator failed in update()\n";  
00128       return -1;
00129     }
00130     
00131     if (theIntegrator.formUnbalance() < 0) {
00132       opserr << "WARNInG InitialInterpolatedLineSearch::search() -";
00133       opserr << "the Integrator failed in formUnbalance()\n";   
00134       return -2;
00135     }   
00136 
00137     //new residual
00138     const Vector &ResidI = theSOE.getB();
00139     
00140     //new value of s
00141     s = dU ^ ResidI;
00142 
00143     //new value of r 
00144     r = fabs( s / s0 ); 
00145 
00146     if (printFlag == 0) {
00147       opserr << "InitialInterpolated Line Search - iteration: " << count 
00148            << " , eta(j) : " << eta
00149            << " , Ratio |sj/s0| = " << r << endln;
00150     }    
00151 
00152     // reset the variables, also check not just hitting bounds over and over
00153     if (eta == etaPrev)
00154       count = maxIter;
00155     else
00156       etaPrev = eta;
00157 
00158   } //end while
00159 
00160   // set X in the SOE for the revised dU, needed for convergence tests
00161   *x = dU;
00162   *x *= eta;
00163   theSOE.setX(*x);
00164 
00165   return 0;
00166 }
00167 
00168 
00169 int
00170 InitialInterpolatedLineSearch::sendSelf(int cTag, Channel &theChannel)
00171 {
00172   return 0;
00173 }
00174 
00175 int
00176 InitialInterpolatedLineSearch::recvSelf(int cTag, 
00177                                         Channel &theChannel, 
00178                                         FEM_ObjectBroker &theBroker)
00179 {
00180   return 0;
00181 }
00182 
00183 
00184 void
00185 InitialInterpolatedLineSearch::Print(OPS_Stream &s, int flag)
00186 {
00187   if (flag == 0) 
00188     s << "InitialInterpolatedLineSearch :: Line Search Tolerance = " << tolerance << endln; 
00189 }
00190 
00191 
00192 
00193 
00194 
00195 
00196 
00197 
00198 

Generated on Mon Oct 23 15:04:57 2006 for OpenSees by doxygen 1.5.0