AlphaOSGeneralized.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:31:57 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/analysis/integrator/AlphaOSGeneralized.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 AlphaOSGeneralized class.
00030 //
00031 // What: "@(#)E AlphaOSGeneralized.cpp, revA"
00032 
00033 #include <AlphaOSGeneralized.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 #include <FE_EleIter.h>
00044 
00045 AlphaOSGeneralized::AlphaOSGeneralized()
00046     : TransientIntegrator(INTEGRATOR_TAGS_AlphaOSGeneralized),
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), Upt(0), Uptdot(0)
00053 {
00054     
00055 }
00056 
00057 
00058 AlphaOSGeneralized::AlphaOSGeneralized(double _rhoInf)
00059     : TransientIntegrator(INTEGRATOR_TAGS_AlphaOSGeneralized),
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), Upt(0), Uptdot(0)
00066 {
00067     
00068 }
00069 
00070 
00071 AlphaOSGeneralized::AlphaOSGeneralized(double _rhoInf, 
00072     double _alphaM, double _betaK, double _betaKi, double _betaKc)
00073     : TransientIntegrator(INTEGRATOR_TAGS_AlphaOSGeneralized),
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), Upt(0), Uptdot(0)
00080 {
00081     
00082 }
00083 
00084 
00085 AlphaOSGeneralized::AlphaOSGeneralized(double _alphaI, double _alphaF,
00086     double _beta, double _gamma)
00087     : TransientIntegrator(INTEGRATOR_TAGS_AlphaOSGeneralized),
00088     alphaI(_alphaI), alphaF(_alphaF), beta(_beta), gamma(_gamma),
00089     deltaT(0.0), alphaM(0.0), betaK(0.0), betaKi(0.0), betaKc(0.0),
00090     c1(0.0), c2(0.0), c3(0.0),
00091     Ut(0), Utdot(0), Utdotdot(0), U(0), Udot(0), Udotdot(0),
00092     Ualpha(0), Ualphadot(0), Ualphadotdot(0), Upt(0), Uptdot(0)
00093 {
00094     
00095 }
00096 
00097 
00098 AlphaOSGeneralized::AlphaOSGeneralized(double _alphaI, double _alphaF,
00099     double _beta, double _gamma,
00100     double _alphaM, double _betaK, double _betaKi, double _betaKc)
00101     : TransientIntegrator(INTEGRATOR_TAGS_AlphaOSGeneralized),
00102     alphaI(_alphaI), alphaF(_alphaF), beta(_beta), gamma(_gamma), deltaT(0.0),
00103     alphaM(_alphaM), betaK(_betaK), betaKi(_betaKi), betaKc(_betaKc),
00104     c1(0.0), c2(0.0), c3(0.0),
00105     Ut(0), Utdot(0), Utdotdot(0), U(0), Udot(0), Udotdot(0),
00106     Ualpha(0), Ualphadot(0), Ualphadotdot(0), Upt(0), Uptdot(0)
00107 {
00108     
00109 }
00110 
00111 
00112 AlphaOSGeneralized::~AlphaOSGeneralized()
00113 {
00114     // clean up the memory created
00115     if (Ut != 0)
00116         delete Ut;
00117     if (Utdot != 0)
00118         delete Utdot;
00119     if (Utdotdot != 0)
00120         delete Utdotdot;
00121     if (U != 0)
00122         delete U;
00123     if (Udot != 0)
00124         delete Udot;
00125     if (Udotdot != 0)
00126         delete Udotdot;
00127     if (Ualpha != 0)
00128         delete Ualpha;
00129     if (Ualphadot != 0)
00130         delete Ualphadot;
00131     if (Ualphadotdot != 0)
00132         delete Ualphadotdot;
00133     if (Upt != 0)
00134         delete Upt;
00135     if (Uptdot != 0)
00136         delete Uptdot;
00137 }
00138 
00139 
00140 int AlphaOSGeneralized::newStep(double _deltaT)
00141 {
00142     updateCount = 0;
00143 
00144     deltaT = _deltaT;
00145     if (beta == 0 || gamma == 0 )  {
00146         opserr << "AlphaOSGeneralized::newStep() - error in variable\n";
00147         opserr << "gamma = " << gamma << " beta = " << beta << endln;
00148         return -1;
00149     }
00150     
00151     if (deltaT <= 0.0)  {
00152         opserr << "AlphaOSGeneralized::newStep() - error in variable\n";
00153         opserr << "dT = " << deltaT << "\n";
00154         return -2;      
00155     }
00156     
00157     // get a pointer to the AnalysisModel
00158     AnalysisModel *theModel = this->getAnalysisModelPtr();
00159     
00160     // set the constants
00161     c1 = 1.0;
00162     c2 = gamma/(beta*deltaT);
00163     c3 = 1.0/(beta*deltaT*deltaT);
00164     
00165     if (U == 0)  {
00166         opserr << "AlphaOSGeneralized::newStep() - domainChange() failed or hasn't been called\n";
00167         return -3;      
00168     }
00169     
00170     // set response at t to be that at t+deltaT of previous step
00171     (*Ut) = *U;  
00172     (*Utdot) = *Udot;  
00173     (*Utdotdot) = *Udotdot;  
00174     
00175     // determine new displacements and velocities at time t+deltaT
00176     U->addVector(1.0, *Utdot, deltaT);
00177     double a1 = (0.5 - beta)*deltaT*deltaT;
00178     U->addVector(1.0, *Utdotdot, a1);
00179     
00180     double a2 = deltaT*(1.0 - gamma);
00181     Udot->addVector(1.0, *Utdotdot, a2);
00182             
00183     // determine the displacements and velocities at t+alphaF*deltaT
00184     (*Ualpha) = *Upt;
00185     Ualpha->addVector((1.0-alphaF), *U, alphaF);
00186     
00187     (*Ualphadot) = *Uptdot;
00188     Ualphadot->addVector((1.0-alphaF), *Udot, alphaF);
00189         
00190     // set the trial response quantities for the elements
00191     theModel->setDisp(*Ualpha);
00192     theModel->setVel(*Ualphadot);
00193     
00194     // increment the time to t+alphaF*deltaT and apply the load
00195     double time = theModel->getCurrentDomainTime();
00196     time += alphaF*deltaT;
00197     if (theModel->updateDomain(time, deltaT) < 0)  {
00198         opserr << "AlphaOSGeneralized::newStep() - failed to update the domain\n";
00199         return -4;
00200     }
00201 
00202     // determine the velocities and accelerations at t+alpha*deltaT
00203     (*Ualphadot) = *Utdot;
00204     Ualphadot->addVector((1.0-alphaF), *Udot, alphaF);
00205 
00206     (*Ualphadotdot) = (1.0-alphaI)*(*Utdotdot);
00207 
00208     // set the trial response quantities for the nodes
00209     theModel->setVel(*Ualphadot);
00210     theModel->setAccel(*Ualphadotdot);
00211     
00212     return 0;
00213 }
00214 
00215 
00216 int AlphaOSGeneralized::revertToLastStep()
00217 {
00218     // set response at t+deltaT to be that at t .. for next step
00219     if (U != 0)  {
00220         (*U) = *Ut;
00221         (*Udot) = *Utdot;
00222         (*Udotdot) = *Utdotdot;
00223     }
00224 
00225     return 0;
00226 }
00227 
00228 int AlphaOSGeneralized::formEleTangent(FE_Element *theEle)
00229 {
00230     theEle->zeroTangent();
00231     
00232     theEle->addKiToTang(alphaF*c1);
00233     theEle->addCtoTang(alphaF*c2);
00234     theEle->addMtoTang(alphaI*c3);
00235     
00236     return 0;
00237 }    
00238 
00239 
00240 int AlphaOSGeneralized::formNodTangent(DOF_Group *theDof)
00241 {
00242     theDof->zeroTangent();
00243     
00244     theDof->addCtoTang(alphaF*c2);
00245     theDof->addMtoTang(alphaI*c3);
00246     
00247     return 0;
00248 }    
00249 
00250 
00251 int AlphaOSGeneralized::domainChanged()
00252 {
00253     AnalysisModel *myModel = this->getAnalysisModelPtr();
00254     LinearSOE *theLinSOE = this->getLinearSOEPtr();
00255     const Vector &x = theLinSOE->getX();
00256     int size = x.Size();
00257     
00258     // if damping factors exist set them in the element & node of the domain
00259     if (alphaM != 0.0 || betaK != 0.0 || betaKi != 0.0 || betaKc != 0.0)
00260         myModel->setRayleighDampingFactors(alphaM, betaK, betaKi, betaKc);
00261     
00262     // create the new Vector objects
00263     if (Ut == 0 || Ut->Size() != size)  {
00264         
00265         // delete the old
00266         if (Ut != 0)
00267             delete Ut;
00268         if (Utdot != 0)
00269             delete Utdot;
00270         if (Utdotdot != 0)
00271             delete Utdotdot;
00272         if (U != 0)
00273             delete U;
00274         if (Udot != 0)
00275             delete Udot;
00276         if (Udotdot != 0)
00277             delete Udotdot;
00278         if (Ualpha != 0)
00279             delete Ualpha;
00280         if (Ualphadot != 0)
00281             delete Ualphadot;
00282         if (Ualphadotdot != 0)
00283             delete Ualphadotdot;
00284         if (Upt != 0)
00285             delete Upt;
00286         if (Uptdot != 0)
00287             delete Uptdot;
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         Upt = new Vector(size);
00300         Uptdot = new Vector(size);
00301         
00302         // check we obtained the new
00303         if (Ut == 0 || Ut->Size() != size ||
00304             Utdot == 0 || Utdot->Size() != size ||
00305             Utdotdot == 0 || Utdotdot->Size() != size ||
00306             U == 0 || U->Size() != size ||
00307             Udot == 0 || Udot->Size() != size ||
00308             Udotdot == 0 || Udotdot->Size() != size ||
00309             Ualpha == 0 || Ualpha->Size() != size ||
00310             Ualphadot == 0 || Ualphadot->Size() != size ||
00311             Ualphadotdot == 0 || Ualphadotdot->Size() != size ||
00312             Upt == 0 || Upt->Size() != size ||
00313             Uptdot == 0 || Uptdot->Size() != size)  {
00314             
00315             opserr << "AlphaOSGeneralized::domainChanged - ran out of memory\n";
00316             
00317             // delete the old
00318             if (Ut != 0)
00319                 delete Ut;
00320             if (Utdot != 0)
00321                 delete Utdot; 
00322             if (Utdotdot != 0)
00323                 delete Utdotdot;
00324             if (U != 0)
00325                 delete U;
00326             if (Udot != 0)
00327                 delete Udot;
00328             if (Udotdot != 0)
00329                 delete Udotdot;
00330             if (Ualpha != 0)
00331                 delete Ualpha;
00332             if (Ualphadot != 0)
00333                 delete Ualphadot;
00334             if (Ualphadotdot != 0)
00335                 delete Ualphadotdot;
00336             if (Upt != 0)
00337                 delete Upt;
00338             if (Uptdot != 0)
00339                 delete Uptdot;
00340             
00341             Ut = 0; Utdot = 0; Utdotdot = 0;
00342             U = 0; Udot = 0; Udotdot = 0;
00343             Ualpha = 0; Ualphadot = 0; Ualphadotdot = 0;
00344             Upt = 0; Uptdot = 0;
00345 
00346             return -1;
00347         }
00348     }        
00349     
00350     // now go through and populate U, Udot and Udotdot by iterating through
00351     // the DOF_Groups and getting the last committed velocity and accel
00352     DOF_GrpIter &theDOFs = myModel->getDOFs();
00353     DOF_Group *dofPtr;
00354     
00355     while ((dofPtr = theDOFs()) != 0)  {
00356         const ID &id = dofPtr->getID();
00357         int idSize = id.Size();
00358         
00359         int i;
00360         const Vector &disp = dofPtr->getCommittedDisp();        
00361         for (i=0; i < idSize; i++)  {
00362             int loc = id(i);
00363             if (loc >= 0)  {
00364                 (*U)(loc) = disp(i);            
00365             }
00366         }
00367         
00368         const Vector &vel = dofPtr->getCommittedVel();
00369         for (i=0; i < idSize; i++)  {
00370             int loc = id(i);
00371             if (loc >= 0)  {
00372                 (*Udot)(loc) = vel(i);
00373             }
00374         }
00375         
00376         const Vector &accel = dofPtr->getCommittedAccel();      
00377         for (i=0; i < idSize; i++)  {
00378             int loc = id(i);
00379             if (loc >= 0)  {
00380                 (*Udotdot)(loc) = accel(i);
00381             }
00382         }
00383     }    
00384     
00385     return 0;
00386 }
00387 
00388 
00389 int AlphaOSGeneralized::update(const Vector &deltaU)
00390 {
00391     updateCount++;
00392     if (updateCount > 1)  {
00393         opserr << "WARNING AlphaOSGeneralized::update() - called more than once -";
00394         opserr << " AlphaOSGeneralized integration scheme requires a LINEAR solution algorithm\n";
00395         return -1;
00396     }
00397     
00398     AnalysisModel *theModel = this->getAnalysisModelPtr();
00399     if (theModel == 0)  {
00400         opserr << "WARNING AlphaOSGeneralized::update() - no AnalysisModel set\n";
00401         return -1;
00402     }   
00403     
00404     // check domainChanged() has been called, i.e. Ut will not be zero
00405     if (Ut == 0)  {
00406         opserr << "WARNING AlphaOSGeneralized::update() - domainChange() failed or not called\n";
00407         return -2;
00408     }   
00409     
00410     // check deltaU is of correct size
00411     if (deltaU.Size() != U->Size())  {
00412         opserr << "WARNING AlphaOSGeneralized::update() - Vectors of incompatible size ";
00413         opserr << " expecting " << U->Size() << " obtained " << deltaU.Size() << "\n";
00414         return -3;
00415     }
00416     
00417     // save the predictor displacements and velocities
00418     (*Upt) = *U;
00419     (*Uptdot) = *Udot;
00420 
00421     //  determine the response at t+deltaT
00422     (*U) += deltaU;
00423 
00424     Udot->addVector(1.0, deltaU, c2);
00425 
00426     (*Udotdot) = c3*deltaU;
00427     
00428     // update the response at the DOFs
00429     theModel->setResponse(*U,*Udot,*Udotdot);
00430 //    if (theModel->updateDomain() < 0)  {
00431 //        opserr << "AlphaOSGeneralized::update() - failed to update the domain\n";
00432 //        return -4;
00433 //    }
00434     
00435     return 0;
00436 }    
00437 
00438 
00439 int AlphaOSGeneralized::commit(void)
00440 {
00441     AnalysisModel *theModel = this->getAnalysisModelPtr();
00442     if (theModel == 0)  {
00443         opserr << "WARNING AlphaOSGeneralized::commit() - no AnalysisModel set\n";
00444         return -1;
00445     }
00446         
00447     // set the time to be t+deltaT
00448     double time = theModel->getCurrentDomainTime();
00449     time += (1.0-alphaF)*deltaT;
00450     theModel->setCurrentDomainTime(time);
00451     
00452     return theModel->commitDomain();
00453 }    
00454 
00455 
00456 int AlphaOSGeneralized::sendSelf(int cTag, Channel &theChannel)
00457 {
00458     Vector data(8);
00459     data(0) = alphaI;
00460     data(1) = alphaF;
00461     data(2) = beta;
00462     data(3) = gamma;
00463     data(4) = alphaM;
00464     data(5) = betaK;
00465     data(6) = betaKi;
00466     data(7) = betaKc;
00467     
00468     if (theChannel.sendVector(this->getDbTag(), cTag, data) < 0)  {
00469         opserr << "WARNING AlphaOSGeneralized::sendSelf() - could not send data\n";
00470         return -1;
00471     }
00472 
00473     return 0;
00474 }
00475 
00476 
00477 int AlphaOSGeneralized::recvSelf(int cTag, Channel &theChannel, FEM_ObjectBroker &theBroker)
00478 {
00479     Vector data(8);
00480     if (theChannel.recvVector(this->getDbTag(), cTag, data) < 0)  {
00481         opserr << "WARNING AlphaOSGeneralized::recvSelf() - could not receive data\n";
00482         return -1;
00483     }
00484     
00485     alphaI = data(0);
00486     alphaF = data(1);
00487     beta   = data(2);
00488     gamma  = data(3);
00489     alphaM = data(4);
00490     betaK  = data(5);
00491     betaKi = data(6);
00492     betaKc = data(7);
00493     
00494     return 0;
00495 }
00496 
00497 
00498 void AlphaOSGeneralized::Print(OPS_Stream &s, int flag)
00499 {
00500     AnalysisModel *theModel = this->getAnalysisModelPtr();
00501     if (theModel != 0)  {
00502         double currentTime = theModel->getCurrentDomainTime();
00503         s << "\t AlphaOSGeneralized - currentTime: " << currentTime << endln;
00504         s << "  alphaI: " << alphaI << " alphaF: " << alphaF  << " beta: " << beta  << " gamma: " << gamma << endln;
00505         s << "  c1: " << c1 << " c2: " << c2 << " c3: " << c3 << endln;
00506         s << "  Rayleigh Damping - alphaM: " << alphaM;
00507         s << "  betaK: " << betaK << "   betaKi: " << betaKi << endln;      
00508     } else 
00509         s << "\t AlphaOSGeneralized - no associated AnalysisModel\n";
00510 }
00511 
00512 
00513 int AlphaOSGeneralized::formElementResidual(void)
00514 {
00515     // calculate Residual Force     
00516     AnalysisModel *theModel = this->getAnalysisModelPtr();
00517     LinearSOE *theSOE = this->getLinearSOEPtr();
00518     
00519     // loop through the FE_Elements and add the residual
00520     FE_Element *elePtr;
00521     int res = 0;    
00522     FE_EleIter &theEles = theModel->getFEs();
00523     while((elePtr = theEles()) != 0)  {
00524         // calculate R-F(d)
00525         if (theSOE->addB(elePtr->getResidual(this),elePtr->getID()) < 0)  {
00526             opserr << "WARNING IncrementalIntegrator::formElementResidual -";
00527             opserr << " failed in addB for ID " << elePtr->getID();
00528             res = -2;
00529         }        
00530         // add Ki*d -> R-F(d)+Ki*d
00531         double tmp_c2 = c2;
00532         double tmp_c3 = c3;
00533         alphaF = alphaF-1.0;
00534         c2 = c3 = 0.0; // no contribution of C and M to tangent
00535         const Vector Ki_d = elePtr->getTangForce(*Ut - *Upt);
00536         if (theSOE->addB(Ki_d, elePtr->getID())<0)  {
00537             opserr << "WARNING AlphaOSGeneralized::formElementResidual -";
00538             opserr << " failed in addB for ID " << elePtr->getID();
00539             res = -2;
00540         }
00541         alphaF = alphaF+1.0;
00542         c2 = tmp_c2;
00543         c3 = tmp_c3;
00544     }
00545 
00546     return res;
00547 }
00548 

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