HHTGeneralized.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.1 $
00022 // $Date: 2005/12/19 22:39:21 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/analysis/integrator/HHTGeneralized.cpp,v $
00024 
00025 // Written: Andreas Schellenberg (andreas.schellenberg@gmx.net)
00026 // Created: 10/05
00027 // Revision: A
00028 //
00029 // Description: This file contains the implementation of the HHTGeneralized class.
00030 //
00031 // What: "@(#) HHTGeneralized.cpp, revA"
00032 
00033 #include <HHTGeneralized.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 
00045 HHTGeneralized::HHTGeneralized()
00046     : TransientIntegrator(INTEGRATOR_TAGS_HHTGeneralized),
00047     alphaI(1.0), alphaF(1.0),
00048     beta(0.0), gamma(0.0), deltaT(0.0),
00049     alphaM(0.0), betaK(0.0), betaKi(0.0), betaKc(0.0),
00050     c1(0.0), c2(0.0), c3(0.0),
00051     Ut(0), Utdot(0), Utdotdot(0), U(0), Udot(0), Udotdot(0),
00052     Ualpha(0), Ualphadot(0), Ualphadotdot(0)
00053 {
00054 
00055 }
00056 
00057 
00058 HHTGeneralized::HHTGeneralized(double _rhoInf)
00059     : TransientIntegrator(INTEGRATOR_TAGS_HHTGeneralized),
00060     alphaI((2.0-_rhoInf)/(1.0+_rhoInf)), alphaF(1.0/(1.0+_rhoInf)),
00061     beta(1.0/(1.0+_rhoInf)/(1.0+_rhoInf)), gamma(0.5*(3.0-_rhoInf)/(1.0+_rhoInf)),
00062     deltaT(0.0), alphaM(0.0), betaK(0.0), betaKi(0.0), betaKc(0.0),
00063     c1(0.0), c2(0.0), c3(0.0), 
00064     Ut(0), Utdot(0), Utdotdot(0), U(0), Udot(0), Udotdot(0),
00065     Ualpha(0), Ualphadot(0), Ualphadotdot(0)
00066 {
00067 
00068 }
00069 
00070 
00071 HHTGeneralized::HHTGeneralized(double _rhoInf,
00072     double _alphaM, double _betaK, double _betaKi, double _betaKc)
00073     : TransientIntegrator(INTEGRATOR_TAGS_HHTGeneralized),
00074     alphaI((2.0-_rhoInf)/(1.0+_rhoInf)), alphaF(1.0/(1.0+_rhoInf)),
00075     beta(1.0/(1.0+_rhoInf)/(1.0+_rhoInf)), gamma(0.5*(3.0-_rhoInf)/(1.0+_rhoInf)),
00076     deltaT(0.0), alphaM(_alphaM), betaK(_betaK), betaKi(_betaKi), betaKc(_betaKc),
00077     c1(0.0), c2(0.0), c3(0.0), 
00078     Ut(0), Utdot(0), Utdotdot(0), U(0), Udot(0), Udotdot(0),
00079     Ualpha(0), Ualphadot(0), Ualphadotdot(0)
00080 {
00081 
00082 }
00083 
00084 
00085 HHTGeneralized::HHTGeneralized(double _alphaI, double _alphaF,
00086     double _beta, double _gamma)
00087     : TransientIntegrator(INTEGRATOR_TAGS_HHTGeneralized),
00088     alphaI(_alphaI), alphaF(_alphaF),
00089     beta(_beta), gamma(_gamma), deltaT(0.0),
00090     alphaM(0.0), betaK(0.0), betaKi(0.0), betaKc(0.0),
00091     c1(0.0), c2(0.0), c3(0.0), 
00092     Ut(0), Utdot(0), Utdotdot(0), U(0), Udot(0), Udotdot(0),
00093     Ualpha(0), Ualphadot(0), Ualphadotdot(0)
00094 {
00095 
00096 }
00097 
00098 
00099 HHTGeneralized::HHTGeneralized(double _alphaI, double _alphaF,
00100     double _beta, double _gamma,
00101     double _alphaM, double _betaK, double _betaKi, double _betaKc)
00102     : TransientIntegrator(INTEGRATOR_TAGS_HHTGeneralized),
00103     alphaI(_alphaI), alphaF(_alphaF),
00104     beta(_beta), gamma(_gamma), deltaT(0.0),
00105     alphaM(_alphaM), betaK(_betaK), betaKi(_betaKi), betaKc(_betaKc),
00106     c1(0.0), c2(0.0), c3(0.0), 
00107     Ut(0), Utdot(0), Utdotdot(0), U(0), Udot(0), Udotdot(0),
00108     Ualpha(0), Ualphadot(0), Ualphadotdot(0)
00109 {
00110 
00111 }
00112 
00113 
00114 HHTGeneralized::~HHTGeneralized()
00115 {
00116     // clean up the memory created
00117     if (Ut != 0)
00118         delete Ut;
00119     if (Utdot != 0)
00120         delete Utdot;
00121     if (Utdotdot != 0)
00122         delete Utdotdot;
00123     if (U != 0)
00124         delete U;
00125     if (Udot != 0)
00126         delete Udot;
00127     if (Udotdot != 0)
00128         delete Udotdot;
00129     if (Ualpha != 0)
00130         delete Ualpha;
00131     if (Ualphadot != 0)
00132         delete Ualphadot;
00133     if (Ualphadotdot != 0)
00134         delete Ualphadotdot;
00135 }
00136 
00137 
00138 int HHTGeneralized::newStep(double _deltaT)
00139 {
00140     deltaT = _deltaT;
00141     if (beta == 0 || gamma == 0 )  {
00142         opserr << "HHTGeneralized::newStep() - error in variable\n";
00143         opserr << "gamma = " << gamma << " beta = " << beta << endln;
00144         return -1;
00145     }
00146     
00147     if (deltaT <= 0.0)  {
00148         opserr << "HHTGeneralized::newStep() - error in variable\n";
00149         opserr << "dT = " << deltaT << endln;
00150         return -2;      
00151     }
00152 
00153     // get a pointer to the AnalysisModel
00154     AnalysisModel *theModel = this->getAnalysisModelPtr();
00155     
00156     // set the constants
00157     c1 = 1.0;
00158     c2 = gamma/(beta*deltaT);
00159     c3 = 1.0/(beta*deltaT*deltaT);
00160        
00161     if (U == 0)  {
00162         opserr << "HHTGeneralized::newStep() - domainChange() failed or hasn't been called\n";
00163         return -3;      
00164     }
00165     
00166     // set response at t to be that at t+deltaT of previous step
00167     (*Ut) = *U;        
00168     (*Utdot) = *Udot;  
00169     (*Utdotdot) = *Udotdot;
00170 
00171     // increment the time to t+alpha*deltaT and apply the load
00172     double time = theModel->getCurrentDomainTime();
00173     time += alphaF*deltaT;
00174 //    theModel->applyLoadDomain(time);
00175     if (theModel->updateDomain(time, deltaT) < 0)  {
00176         opserr << "HHTGeneralized::newStep() - failed to update the domain\n";
00177         return -4;
00178     }
00179 
00180     // determine new velocities and accelerations at t+deltaT
00181     double a1 = (1.0 - gamma/beta);
00182     double a2 = deltaT*(1.0 - 0.5*gamma/beta);
00183     Udot->addVector(a1, *Utdotdot, a2);
00184     
00185     double a3 = -1.0/(beta*deltaT);
00186     double a4 = 1.0 - 0.5/beta;  
00187     Udotdot->addVector(a4, *Utdot, a3);
00188     
00189     // determine the velocities and accelerations at t+alpha*deltaT
00190     (*Ualphadot) = *Utdot;
00191     Ualphadot->addVector((1.0-alphaF), *Udot, alphaF);
00192     
00193     (*Ualphadotdot) = *Utdotdot;
00194     Ualphadotdot->addVector((1.0-alphaI), *Udotdot, alphaI);
00195 
00196     // set the trial response quantities for the nodes
00197     theModel->setVel(*Ualphadot);
00198     theModel->setAccel(*Ualphadotdot);
00199         
00200     return 0;
00201 }
00202 
00203 
00204 int HHTGeneralized::revertToLastStep()
00205 {
00206     // set response at t+deltaT to be that at t .. for next step
00207     if (U != 0)  {
00208         (*U) = *Ut;
00209         (*Udot) = *Utdot;
00210         (*Udotdot) = *Utdotdot;
00211     }
00212 
00213     return 0;
00214 }
00215 
00216 
00217 int HHTGeneralized::formEleTangent(FE_Element *theEle)
00218 {
00219     theEle->zeroTangent();
00220     if (statusFlag == CURRENT_TANGENT)  {
00221         theEle->addKtToTang(alphaF*c1);
00222         theEle->addCtoTang(alphaF*c2);
00223         theEle->addMtoTang(alphaI*c3);
00224     } else if (statusFlag == INITIAL_TANGENT)  {
00225         theEle->addKiToTang(alphaF*c1);
00226         theEle->addCtoTang(alphaF*c2);
00227         theEle->addMtoTang(alphaI*c3);
00228     }
00229     
00230     return 0;
00231 }    
00232 
00233 
00234 int HHTGeneralized::formNodTangent(DOF_Group *theDof)
00235 {
00236     theDof->zeroTangent();
00237 
00238     theDof->addCtoTang(alphaF*c2);
00239     theDof->addMtoTang(alphaI*c3);
00240     
00241     return 0;
00242 }
00243 
00244 
00245 int HHTGeneralized::domainChanged()
00246 {
00247     AnalysisModel *myModel = this->getAnalysisModelPtr();
00248     LinearSOE *theLinSOE = this->getLinearSOEPtr();
00249     const Vector &x = theLinSOE->getX();
00250     int size = x.Size();
00251     
00252     // if damping factors exist set them in the ele & node of the domain
00253     if (alphaM != 0.0 || betaK != 0.0 || betaKi != 0.0 || betaKc != 0.0)
00254         myModel->setRayleighDampingFactors(alphaM, betaK, betaKi, betaKc);
00255     
00256     // create the new Vector objects
00257     if (Ut == 0 || Ut->Size() != size)  {
00258         
00259         // delete the old
00260         if (Ut != 0)
00261             delete Ut;
00262         if (Utdot != 0)
00263             delete Utdot;
00264         if (Utdotdot != 0)
00265             delete Utdotdot;
00266         if (U != 0)
00267             delete U;
00268         if (Udot != 0)
00269             delete Udot;
00270         if (Udotdot != 0)
00271             delete Udotdot;
00272         if (Ualpha != 0)
00273             delete Ualpha;
00274         if (Ualphadot != 0)
00275             delete Ualphadot;
00276         if (Ualphadotdot != 0)
00277             delete Ualphadotdot;
00278         
00279         // create the new
00280         Ut = new Vector(size);
00281         Utdot = new Vector(size);
00282         Utdotdot = new Vector(size);
00283         U = new Vector(size);
00284         Udot = new Vector(size);
00285         Udotdot = new Vector(size);
00286         Ualpha = new Vector(size);
00287         Ualphadot = new Vector(size);
00288         Ualphadotdot = new Vector(size);
00289         
00290         // check we obtained the new
00291         if (Ut == 0 || Ut->Size() != size ||
00292             Utdot == 0 || Utdot->Size() != size ||
00293             Utdotdot == 0 || Utdotdot->Size() != size ||
00294             U == 0 || U->Size() != size ||
00295             Udot == 0 || Udot->Size() != size ||
00296             Udotdot == 0 || Udotdot->Size() != size ||
00297             Ualpha == 0 || Ualpha->Size() != size ||
00298             Ualphadot == 0 || Ualphadot->Size() != size ||
00299             Ualphadotdot == 0 || Ualphadotdot->Size() != size)  {
00300             
00301             opserr << "HHTGeneralized::domainChanged - ran out of memory\n";
00302             
00303             // delete the old
00304             if (Ut != 0)
00305                 delete Ut;
00306             if (Utdot != 0)
00307                 delete Utdot;
00308             if (Utdotdot != 0)
00309                 delete Utdotdot;
00310             if (U != 0)
00311                 delete U;
00312             if (Udot != 0)
00313                 delete Udot;
00314             if (Udotdot != 0)
00315                 delete Udotdot;
00316             if (Ualpha != 0)
00317                 delete Ualpha;
00318             if (Ualphadot != 0)
00319                 delete Ualphadot;
00320             if (Ualphadotdot != 0)
00321                 delete Ualphadotdot;
00322             
00323             Ut = 0; Utdot = 0; Utdotdot = 0;
00324             U = 0; Udot = 0; Udotdot = 0;
00325             Ualpha = 0; Ualphadot = 0; Ualphadotdot = 0;
00326 
00327             return -1;
00328         }
00329     }        
00330     
00331     // now go through and populate U, Udot and Udotdot by iterating through
00332     // the DOF_Groups and getting the last committed velocity and accel
00333     DOF_GrpIter &theDOFs = myModel->getDOFs();
00334     DOF_Group *dofPtr;
00335     
00336     while ((dofPtr = theDOFs()) != 0)  {
00337         const ID &id = dofPtr->getID();
00338         int idSize = id.Size();
00339         
00340         int i;
00341         const Vector &disp = dofPtr->getCommittedDisp();        
00342         for (i=0; i < idSize; i++)  {
00343             int loc = id(i);
00344             if (loc >= 0)  {
00345                 (*U)(loc) = disp(i);            
00346             }
00347         }
00348         
00349         const Vector &vel = dofPtr->getCommittedVel();
00350         for (i=0; i < idSize; i++)  {
00351             int loc = id(i);
00352             if (loc >= 0)  {
00353                 (*Udot)(loc) = vel(i);
00354             }
00355         }
00356         
00357         const Vector &accel = dofPtr->getCommittedAccel();      
00358         for (i=0; i < idSize; i++)  {
00359             int loc = id(i);
00360             if (loc >= 0)  {
00361                 (*Udotdot)(loc) = accel(i);
00362             }
00363         }        
00364     }    
00365     
00366     return 0;
00367 }
00368 
00369 
00370 int HHTGeneralized::update(const Vector &deltaU)
00371 {
00372     AnalysisModel *theModel = this->getAnalysisModelPtr();
00373     if (theModel == 0)  {
00374         opserr << "WARNING HHTGeneralized::update() - no AnalysisModel set\n";
00375         return -1;
00376     }   
00377     
00378     // check domainChanged() has been called, i.e. Ut will not be zero
00379     if (Ut == 0)  {
00380         opserr << "WARNING HHTGeneralized::update() - domainChange() failed or not called\n";
00381         return -2;
00382     }   
00383     
00384     // check deltaU is of correct size
00385     if (deltaU.Size() != U->Size())  {
00386         opserr << "WARNING HHTGeneralized::update() - Vectors of incompatible size ";
00387         opserr << " expecting " << U->Size() << " obtained " << deltaU.Size() << endln;
00388         return -3;
00389     }
00390     
00391     //  determine the response at t+deltaT
00392     (*U) += deltaU;
00393 
00394     Udot->addVector(1.0, deltaU, c2);
00395     
00396     Udotdot->addVector(1.0, deltaU, c3);
00397 
00398     // determine displacement and velocity at t+alpha*deltaT
00399     (*Ualpha) = *Ut;
00400     Ualpha->addVector((1.0-alphaF), *U, alphaF);
00401 
00402     (*Ualphadot) = *Utdot;
00403     Ualphadot->addVector((1.0-alphaF), *Udot, alphaF);
00404     
00405     (*Ualphadotdot) = *Utdotdot;
00406     Ualphadotdot->addVector((1.0-alphaI), *Udotdot, alphaI);
00407 
00408     // update the response at the DOFs
00409     theModel->setResponse(*Ualpha,*Ualphadot,*Ualphadotdot);
00410     if (theModel->updateDomain() < 0)  {
00411         opserr << "HHTGeneralized::update() - failed to update the domain\n";
00412         return -4;
00413     }
00414     
00415     return 0;
00416 }
00417 
00418 
00419 int HHTGeneralized::commit(void)
00420 {
00421     AnalysisModel *theModel = this->getAnalysisModelPtr();
00422     if (theModel == 0)  {
00423         opserr << "WARNING HHTGeneralized::commit() - no AnalysisModel set\n";
00424         return -1;
00425     }     
00426     
00427     // update the response at the DOFs
00428     theModel->setResponse(*U,*Udot,*Udotdot);
00429 //    if (theModel->updateDomain() < 0)  {
00430 //        opserr << "HHTGeneralized::commit() - failed to update the domain\n";
00431 //        return -4;
00432 //    }
00433     
00434     // set the time to be t+deltaT
00435     double time = theModel->getCurrentDomainTime();
00436     time += (1.0-alphaF)*deltaT;
00437     theModel->setCurrentDomainTime(time);
00438 
00439     return theModel->commitDomain();
00440 }
00441 
00442 
00443 int HHTGeneralized::sendSelf(int cTag, Channel &theChannel)
00444 {
00445     Vector data(8);
00446     data(0) = alphaI;
00447     data(1) = alphaF;
00448     data(2) = beta;
00449     data(3) = gamma;
00450     data(4) = alphaM;
00451     data(5) = betaK;
00452     data(6) = betaKi;
00453     data(7) = betaKc;
00454     
00455     if (theChannel.sendVector(this->getDbTag(), cTag, data) < 0)  {
00456         opserr << "WARNING HHTGeneralized::sendSelf() - could not send data\n";
00457         return -1;
00458     }
00459 
00460     return 0;
00461 }
00462 
00463 
00464 int HHTGeneralized::recvSelf(int cTag, Channel &theChannel, FEM_ObjectBroker &theBroker)
00465 {
00466     Vector data(8);
00467     if (theChannel.recvVector(this->getDbTag(), cTag, data) < 0)  {
00468         opserr << "WARNING HHTGeneralized::recvSelf() - could not receive data\n";
00469         return -1;
00470     }
00471     
00472     alphaI = data(0);
00473     alphaF = data(1);
00474     beta   = data(2);
00475     gamma  = data(3);
00476     alphaM = data(4);
00477     betaK  = data(5);
00478     betaKi = data(6);
00479     betaKc = data(7);
00480     
00481     return 0;
00482 }
00483 
00484 
00485 void HHTGeneralized::Print(OPS_Stream &s, int flag)
00486 {
00487     AnalysisModel *theModel = this->getAnalysisModelPtr();
00488     if (theModel != 0)  {
00489         double currentTime = theModel->getCurrentDomainTime();
00490         s << "\t HHTGeneralized - currentTime: " << currentTime << endln;
00491         s << "  alphaI: " << alphaI << " alphaF: " << alphaF  << " beta: " << beta  << " gamma: " << gamma << endln;
00492         s << "  c1: " << c1 << " c2: " << c2 << " c3: " << c3 << endln;
00493         s << "  Rayleigh Damping - alphaM: " << alphaM;
00494         s << "  betaK: " << betaK << "   betaKi: " << betaKi << endln;      
00495     } else 
00496         s << "\t HHTGeneralized - no associated AnalysisModel\n";
00497 }
00498 

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