00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include <HHTExplicit.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
00047
00048 HHTExplicit::HHTExplicit()
00049 : TransientIntegrator(INTEGRATOR_TAGS_HHTExplicit),
00050 alpha(1.0), gamma(0.0), deltaT(0.0),
00051 alphaM(0.0), betaK(0.0), betaKi(0.0), betaKc(0.0),
00052 c2(0.0), c3(0.0),
00053 Ut(0), Utdot(0), Utdotdot(0), U(0), Udot(0), Udotdot(0),
00054 Ualpha(0), Ualphadot(0)
00055 {
00056
00057 }
00058
00059
00060 HHTExplicit::HHTExplicit(double _alpha)
00061 : TransientIntegrator(INTEGRATOR_TAGS_HHTExplicit),
00062 alpha(_alpha), gamma(0.5), deltaT(0.0),
00063 alphaM(0.0), betaK(0.0), betaKi(0.0), betaKc(0.0),
00064 c2(0.0), c3(0.0),
00065 Ut(0), Utdot(0), Utdotdot(0), U(0), Udot(0), Udotdot(0),
00066 Ualpha(0), Ualphadot(0)
00067 {
00068
00069 }
00070
00071
00072 HHTExplicit::HHTExplicit(double _alpha,
00073 double _alphaM, double _betaK, double _betaKi, double _betaKc)
00074 : TransientIntegrator(INTEGRATOR_TAGS_HHTExplicit),
00075 alpha(_alpha), gamma(0.5), deltaT(0.0),
00076 alphaM(_alphaM), betaK(_betaK), betaKi(_betaKi), betaKc(_betaKc),
00077 c2(0.0), c3(0.0),
00078 Ut(0), Utdot(0), Utdotdot(0), U(0), Udot(0), Udotdot(0),
00079 Ualpha(0), Ualphadot(0)
00080 {
00081
00082 }
00083
00084
00085 HHTExplicit::HHTExplicit(double _alpha, double _gamma)
00086 : TransientIntegrator(INTEGRATOR_TAGS_HHTExplicit),
00087 alpha(_alpha), gamma(_gamma), deltaT(0.0),
00088 alphaM(0.0), betaK(0.0), betaKi(0.0), betaKc(0.0),
00089 c2(0.0), c3(0.0),
00090 Ut(0), Utdot(0), Utdotdot(0), U(0), Udot(0), Udotdot(0),
00091 Ualpha(0), Ualphadot(0)
00092 {
00093
00094 }
00095
00096
00097 HHTExplicit::HHTExplicit(double _alpha, double _gamma,
00098 double _alphaM, double _betaK, double _betaKi, double _betaKc)
00099 : TransientIntegrator(INTEGRATOR_TAGS_HHTExplicit),
00100 alpha(_alpha), gamma(_gamma), deltaT(0.0),
00101 alphaM(_alphaM), betaK(_betaK), betaKi(_betaKi), betaKc(_betaKc),
00102 c2(0.0), c3(0.0),
00103 Ut(0), Utdot(0), Utdotdot(0), U(0), Udot(0), Udotdot(0),
00104 Ualpha(0), Ualphadot(0)
00105 {
00106
00107 }
00108
00109
00110 HHTExplicit::~HHTExplicit()
00111 {
00112
00113 if (Ut != 0)
00114 delete Ut;
00115 if (Utdot != 0)
00116 delete Utdot;
00117 if (Utdotdot != 0)
00118 delete Utdotdot;
00119 if (U != 0)
00120 delete U;
00121 if (Udot != 0)
00122 delete Udot;
00123 if (Udotdot != 0)
00124 delete Udotdot;
00125 if (Ualpha != 0)
00126 delete Ualpha;
00127 if (Ualphadot != 0)
00128 delete Ualphadot;
00129 }
00130
00131
00132 int HHTExplicit::newStep(double _deltaT)
00133 {
00134 updateCount = 0;
00135
00136 deltaT = _deltaT;
00137 if (gamma == 0 ) {
00138 opserr << "HHTExplicit::newStep() - error in variable\n";
00139 opserr << "gamma = " << gamma << endln;
00140 return -1;
00141 }
00142
00143 if (deltaT <= 0.0) {
00144 opserr << "HHTExplicit::newStep() - error in variable\n";
00145 opserr << "dT = " << deltaT << endln;
00146 return -2;
00147 }
00148
00149
00150 AnalysisModel *theModel = this->getAnalysisModelPtr();
00151
00152
00153 c2 = gamma*deltaT;
00154 c3 = 1.0;
00155
00156 if (U == 0) {
00157 opserr << "HHTExplicit::newStep() - domainChange() failed or hasn't been called\n";
00158 return -3;
00159 }
00160
00161
00162 (*Ut) = *U;
00163 (*Utdot) = *Udot;
00164 (*Utdotdot) = *Udotdot;
00165
00166
00167 U->addVector(1.0, *Utdot, deltaT);
00168 double a1 = 0.5*deltaT*deltaT;
00169 U->addVector(1.0, *Utdotdot, a1);
00170
00171 double a2 = deltaT*(1.0 - gamma);
00172 Udot->addVector(1.0, *Utdotdot, a2);
00173
00174
00175 (*Ualpha) = *Ut;
00176 Ualpha->addVector((1.0-alpha), *U, alpha);
00177
00178 (*Ualphadot) = *Utdot;
00179 Ualphadot->addVector((1.0-alpha), *Udot, alpha);
00180
00181
00182 theModel->setDisp(*Ualpha);
00183 theModel->setVel(*Ualphadot);
00184
00185
00186 double time = theModel->getCurrentDomainTime();
00187 time += alpha*deltaT;
00188 if (theModel->updateDomain(time, deltaT) < 0) {
00189 opserr << "HHTExplicit::newStep() - failed to update the domain\n";
00190 return -4;
00191 }
00192
00193
00194 Udotdot->Zero();
00195
00196
00197 theModel->setAccel(*Udotdot);
00198
00199 return 0;
00200 }
00201
00202
00203 int HHTExplicit::revertToLastStep()
00204 {
00205
00206 if (U != 0) {
00207 (*U) = *Ut;
00208 (*Udot) = *Utdot;
00209 (*Udotdot) = *Utdotdot;
00210 }
00211
00212 return 0;
00213 }
00214
00215
00216 int HHTExplicit::formEleTangent(FE_Element *theEle)
00217 {
00218 theEle->zeroTangent();
00219
00220 theEle->addCtoTang(alpha*c2);
00221 theEle->addMtoTang(c3);
00222
00223 return 0;
00224 }
00225
00226
00227 int HHTExplicit::formNodTangent(DOF_Group *theDof)
00228 {
00229 theDof->zeroTangent();
00230
00231 theDof->addCtoTang(alpha*c2);
00232 theDof->addMtoTang(c3);
00233
00234 return 0;
00235 }
00236
00237
00238 int HHTExplicit::domainChanged()
00239 {
00240 AnalysisModel *myModel = this->getAnalysisModelPtr();
00241 LinearSOE *theLinSOE = this->getLinearSOEPtr();
00242 const Vector &x = theLinSOE->getX();
00243 int size = x.Size();
00244
00245
00246 if (alphaM != 0.0 || betaK != 0.0 || betaKi != 0.0 || betaKc != 0.0)
00247 myModel->setRayleighDampingFactors(alphaM, betaK, betaKi, betaKc);
00248
00249
00250 if (Ut == 0 || Ut->Size() != size) {
00251
00252
00253 if (Ut != 0)
00254 delete Ut;
00255 if (Utdot != 0)
00256 delete Utdot;
00257 if (Utdotdot != 0)
00258 delete Utdotdot;
00259 if (U != 0)
00260 delete U;
00261 if (Udot != 0)
00262 delete Udot;
00263 if (Udotdot != 0)
00264 delete Udotdot;
00265 if (Ualpha != 0)
00266 delete Ualpha;
00267 if (Ualphadot != 0)
00268 delete Ualphadot;
00269
00270
00271 Ut = new Vector(size);
00272 Utdot = new Vector(size);
00273 Utdotdot = new Vector(size);
00274 U = new Vector(size);
00275 Udot = new Vector(size);
00276 Udotdot = new Vector(size);
00277 Ualpha = new Vector(size);
00278 Ualphadot = new Vector(size);
00279
00280
00281 if (Ut == 0 || Ut->Size() != size ||
00282 Utdot == 0 || Utdot->Size() != size ||
00283 Utdotdot == 0 || Utdotdot->Size() != size ||
00284 U == 0 || U->Size() != size ||
00285 Udot == 0 || Udot->Size() != size ||
00286 Udotdot == 0 || Udotdot->Size() != size ||
00287 Ualpha == 0 || Ualpha->Size() != size ||
00288 Ualphadot == 0 || Ualphadot->Size() != size) {
00289
00290 opserr << "HHTExplicit::domainChanged - ran out of memory\n";
00291
00292
00293 if (Ut != 0)
00294 delete Ut;
00295 if (Utdot != 0)
00296 delete Utdot;
00297 if (Utdotdot != 0)
00298 delete Utdotdot;
00299 if (U != 0)
00300 delete U;
00301 if (Udot != 0)
00302 delete Udot;
00303 if (Udotdot != 0)
00304 delete Udotdot;
00305 if (Ualpha != 0)
00306 delete Ualpha;
00307 if (Ualphadot != 0)
00308 delete Ualphadot;
00309
00310 Ut = 0; Utdot = 0; Utdotdot = 0;
00311 U = 0; Udot = 0; Udotdot = 0;
00312 Ualpha = 0; Ualphadot = 0;
00313
00314 return -1;
00315 }
00316 }
00317
00318
00319
00320 DOF_GrpIter &theDOFs = myModel->getDOFs();
00321 DOF_Group *dofPtr;
00322
00323 while ((dofPtr = theDOFs()) != 0) {
00324 const ID &id = dofPtr->getID();
00325 int idSize = id.Size();
00326
00327 int i;
00328 const Vector &disp = dofPtr->getCommittedDisp();
00329 for (i=0; i < idSize; i++) {
00330 int loc = id(i);
00331 if (loc >= 0) {
00332 (*U)(loc) = disp(i);
00333 }
00334 }
00335
00336 const Vector &vel = dofPtr->getCommittedVel();
00337 for (i=0; i < idSize; i++) {
00338 int loc = id(i);
00339 if (loc >= 0) {
00340 (*Udot)(loc) = vel(i);
00341 }
00342 }
00343
00344 const Vector &accel = dofPtr->getCommittedAccel();
00345 for (i=0; i < idSize; i++) {
00346 int loc = id(i);
00347 if (loc >= 0) {
00348 (*Udotdot)(loc) = accel(i);
00349 }
00350 }
00351 }
00352
00353 return 0;
00354 }
00355
00356
00357 int HHTExplicit::update(const Vector &aiPlusOne)
00358 {
00359 updateCount++;
00360 if (updateCount > 1) {
00361 opserr << "WARNING HHTExplicit::update() - called more than once -";
00362 opserr << " HHTExplicit integration scheme requires a LINEAR solution algorithm\n";
00363 return -1;
00364 }
00365
00366 AnalysisModel *theModel = this->getAnalysisModelPtr();
00367 if (theModel == 0) {
00368 opserr << "WARNING HHTExplicit::update() - no AnalysisModel set\n";
00369 return -1;
00370 }
00371
00372
00373 if (Ut == 0) {
00374 opserr << "WARNING HHTExplicit::update() - domainChange() failed or not called\n";
00375 return -2;
00376 }
00377
00378
00379 if (aiPlusOne.Size() != U->Size()) {
00380 opserr << "WARNING HHTExplicit::update() - Vectors of incompatible size ";
00381 opserr << " expecting " << U->Size() << " obtained " << aiPlusOne.Size() << endln;
00382 return -3;
00383 }
00384
00385
00386 Udot->addVector(1.0, aiPlusOne, c2);
00387
00388 (*Udotdot) = aiPlusOne;
00389
00390
00391 theModel->setVel(*Udot);
00392 theModel->setAccel(*Udotdot);
00393
00394 return 0;
00395 }
00396
00397
00398 int HHTExplicit::commit(void)
00399 {
00400 AnalysisModel *theModel = this->getAnalysisModelPtr();
00401 if (theModel == 0) {
00402 opserr << "WARNING HHTExplicit::commit() - no AnalysisModel set\n";
00403 return -1;
00404 }
00405
00406
00407 double time = theModel->getCurrentDomainTime();
00408 time += (1.0-alpha)*deltaT;
00409 theModel->setCurrentDomainTime(time);
00410
00411 return theModel->commitDomain();
00412 }
00413
00414
00415 int HHTExplicit::sendSelf(int cTag, Channel &theChannel)
00416 {
00417 Vector data(6);
00418 data(0) = alpha;
00419 data(1) = gamma;
00420 data(2) = alphaM;
00421 data(3) = betaK;
00422 data(4) = betaKi;
00423 data(5) = betaKc;
00424
00425 if (theChannel.sendVector(this->getDbTag(), cTag, data) < 0) {
00426 opserr << "WARNING HHTExplicit::sendSelf() - could not send data\n";
00427 return -1;
00428 }
00429
00430 return 0;
00431 }
00432
00433
00434 int HHTExplicit::recvSelf(int cTag, Channel &theChannel, FEM_ObjectBroker &theBroker)
00435 {
00436 Vector data(6);
00437 if (theChannel.recvVector(this->getDbTag(), cTag, data) < 0) {
00438 opserr << "WARNING HHTExplicit::recvSelf() - could not receive data\n";
00439 return -1;
00440 }
00441
00442 alpha = data(0);
00443 gamma = data(1);
00444 alphaM = data(2);
00445 betaK = data(3);
00446 betaKi = data(4);
00447 betaKc = data(5);
00448
00449 return 0;
00450 }
00451
00452
00453 void HHTExplicit::Print(OPS_Stream &s, int flag)
00454 {
00455 AnalysisModel *theModel = this->getAnalysisModelPtr();
00456 if (theModel != 0) {
00457 double currentTime = theModel->getCurrentDomainTime();
00458 s << "\t HHTExplicit - currentTime: " << currentTime << endln ;
00459 s << " alpha: " << alpha << " gamma: " << gamma << endln;
00460 s << " c2: " << c2 << " c3: " << c3 << endln;
00461 s << " Rayleigh Damping - alphaM: " << alphaM;
00462 s << " betaK: " << betaK << " betaKi: " << betaKi << endln;
00463 } else
00464 s << "\t HHTExplicit - no associated AnalysisModel\n";
00465 }
00466
00467
00468