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

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