CentralDifferenceNoDamping.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.2 $
00022 // $Date: 2006/02/28 19:34:01 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/analysis/integrator/CentralDifferenceNoDamping.cpp,v $
00024 
00025 // Written: fmk 
00026 // Created: 11/98
00027 //
00028 // Description: This file contains the implementation of the CentralDifferenceNoDamping 
00029 // class.
00030 //
00031 // What: "@(#) CentralDifferenceNoDamping.C, revA"
00032 
00033 #include <CentralDifferenceNoDamping.h>
00034 #include <FE_Element.h>
00035 #include <LinearSOE.h>
00036 #include <AnalysisModel.h>
00037 #include <Vector.h>
00038 #include <DOF_Group.h>
00039 #include <DOF_GrpIter.h>
00040 #include <AnalysisModel.h>
00041 #include <Channel.h>
00042 #include <FEM_ObjectBroker.h>
00043 
00044 CentralDifferenceNoDamping::CentralDifferenceNoDamping()
00045 :TransientIntegrator(INTEGRATOR_TAGS_CentralDifferenceNoDamping),
00046  updateCount(0), 
00047  U(0), Udot(0), Udotdot(0), deltaT(0)
00048 {
00049     
00050 }
00051 
00052 CentralDifferenceNoDamping::~CentralDifferenceNoDamping()
00053 {
00054   // clean up the memory created
00055   if (U != 0)
00056     delete U;
00057   if (Udot != 0)
00058     delete Udot;
00059   if (Udotdot != 0)
00060     delete Udotdot;
00061 }
00062 
00063 int
00064 CentralDifferenceNoDamping::newStep(double _deltaT)
00065 {
00066   updateCount = 0;
00067   
00068   deltaT = _deltaT;
00069 
00070   if (deltaT <= 0.0) {
00071     opserr << "CentralDifference::newStep() - error in variable\n";
00072     opserr << "dT = " << deltaT << endln;
00073     return -2;  
00074   }
00075 
00076   AnalysisModel *theModel = this->getAnalysisModelPtr();
00077   double time = theModel->getCurrentDomainTime();
00078   theModel->applyLoadDomain(time);
00079 
00080   return 0;
00081 }
00082 
00083 int
00084 CentralDifferenceNoDamping::formEleTangent(FE_Element *theEle)
00085 {
00086   theEle->zeroTangent();
00087   theEle->addMtoTang();
00088 
00089   return 0;
00090 }    
00091 
00092 int
00093 CentralDifferenceNoDamping::formNodTangent(DOF_Group *theDof)
00094 {
00095   theDof->zeroTangent();
00096   theDof->addMtoTang();
00097   return(0);
00098 }    
00099 
00100 int
00101 CentralDifferenceNoDamping::formEleResidual(FE_Element *theEle)
00102 {
00103   theEle->zeroResidual();
00104   theEle->addRtoResidual();
00105   return 0;
00106 }    
00107 
00108 int
00109 CentralDifferenceNoDamping::formNodUnbalance(DOF_Group *theDof)
00110 {
00111   theDof->zeroUnbalance();
00112   theDof->addPtoUnbalance();
00113   return 0;
00114 }    
00115 
00116 
00117 int 
00118 CentralDifferenceNoDamping::domainChanged()
00119 {
00120   AnalysisModel *myModel = this->getAnalysisModelPtr();
00121   LinearSOE *theLinSOE = this->getLinearSOEPtr();
00122   const Vector &x = theLinSOE->getX();
00123   int size = x.Size();
00124   
00125   // create the new Vector objects
00126   if (U == 0 || U->Size() != size) {
00127 
00128     // delete the old
00129     if (U != 0)
00130       delete U;
00131     if (Udot != 0)
00132       delete Udot;
00133     if (Udotdot != 0)
00134       delete Udotdot;
00135 
00136     // create the new
00137     U = new Vector(size);
00138     Udot = new Vector(size);
00139     Udotdot = new Vector(size);
00140 
00141     // cheack we obtained the new
00142     if (U == 0 || U->Size() != size ||
00143         Udot == 0 || Udot->Size() != size ||
00144         Udotdot == 0 || Udotdot->Size() != size) {
00145       
00146       opserr << "CentralDifferenceNoDamping::domainChanged - ran out of memory\n";
00147 
00148       // delete the old
00149       if (U != 0)
00150         delete U;
00151       if (Udot != 0)
00152         delete U;
00153       if (Udotdot != 0)
00154         delete Udot;
00155 
00156       U = 0; Udot = 0; Udotdot = 0;
00157       return -1;
00158     }
00159   }        
00160     
00161   // now go through and populate U and Udot by iterating through
00162   // the DOF_Groups and getting the last committed velocity and accel
00163 
00164   DOF_GrpIter &theDOFs = myModel->getDOFs();
00165   DOF_Group *dofPtr;
00166     
00167   while ((dofPtr = theDOFs()) != 0) {
00168     const ID &id = dofPtr->getID();
00169     int idSize = id.Size();
00170     int i;
00171     const Vector &disp = dofPtr->getCommittedDisp();    
00172     for (i=0; i < idSize; i++)  {
00173       int loc = id(i);
00174       if (loc >= 0)  {
00175         (*U)(loc) = disp(i);            
00176       }
00177     }
00178     
00179     const Vector &vel = dofPtr->getCommittedVel();
00180     for (i=0; i < idSize; i++)  {
00181       int loc = id(i);
00182       if (loc >= 0)  {
00183         (*Udot)(loc) = vel(i);
00184       }
00185     }
00186   }    
00187   
00188   return 0;
00189 }
00190 
00191 
00192 int
00193 CentralDifferenceNoDamping::update(const Vector &X)
00194 {
00195   updateCount++;
00196   if (updateCount > 1) {
00197     opserr << "ERROR CentralDifferenceNoDamping::update() - called more than once -";
00198     opserr << " Central Difference integraion schemes require a LINEAR solution algorithm\n";
00199     return -1;
00200   }
00201   
00202   AnalysisModel *theModel = this->getAnalysisModelPtr();
00203 
00204   if (theModel == 0) {
00205     opserr << "ERROR CentralDifferenceNoDamping::update() - no AnalysisModel set\n";
00206     return -2;
00207   }     
00208   
00209   // check domainChanged() has been called, i.e. Ut will not be zero
00210   if (U == 0) {
00211     opserr << "WARNING CentralDifferenceNoDamping::update() - domainChange() failed or not called\n";
00212     return -2;
00213   }     
00214 
00215   // check deltaU is of correct size
00216   if (X.Size() != U->Size()) {
00217     opserr << "WARNING CentralDifferenceNoDamping::update() - Vectors of incompatable size ";
00218     opserr << " expecting " << U->Size() << " obtained " << X.Size() << endln;
00219     return -3;
00220   }
00221 
00222   //  determine the acceleration at time t 
00223   (*Udotdot) = X;
00224 
00225   //  determine the vel at t+ 0.5 * delta t 
00226   Udot->addVector(1.0, X, deltaT);
00227   
00228   //  determine the displacement at t+delta t 
00229   U->addVector(1.0, *Udot, deltaT);
00230 
00231   // update the disp & responses at the DOFs
00232   theModel->setDisp(*U);
00233   theModel->updateDomain();
00234 
00235   return 0;
00236 }    
00237 
00238 int
00239 CentralDifferenceNoDamping::commit(void)
00240 {
00241   AnalysisModel *theModel = this->getAnalysisModelPtr();
00242   if (theModel == 0) {
00243     opserr << "WARNING CentralDifferenceNoDamping::commit() - no AnalysisModel set\n";
00244     return -1;
00245   }       
00246   
00247   // update time in Domain to T + deltaT & commit the domain
00248   double time = theModel->getCurrentDomainTime() + deltaT;
00249   theModel->setCurrentDomainTime(time);
00250 
00251   return theModel->commitDomain();
00252 
00253   return 0;
00254 }
00255 
00256 int
00257 CentralDifferenceNoDamping::sendSelf(int cTag, Channel &theChannel)
00258 {
00259   return 0;
00260 }
00261 
00262 int
00263 CentralDifferenceNoDamping::recvSelf(int cTag, Channel &theChannel, FEM_ObjectBroker &theBroker)
00264 {
00265     return 0;
00266 }
00267 
00268 void
00269 CentralDifferenceNoDamping::Print(OPS_Stream &s, int flag)
00270 {
00271     AnalysisModel *theModel = this->getAnalysisModelPtr();
00272     if (theModel != 0) {
00273         double currentTime = theModel->getCurrentDomainTime();
00274         s << "\t CentralDifferenceNoDamping - currentTime: " << currentTime;
00275     } else 
00276         s << "\t CentralDifferenceNoDamping - no associated AnalysisModel\n";
00277 }
00278 

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