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 #include <LoadPattern.h>
00035 #include <stdlib.h>
00036 #include <ID.h>
00037 #include <TimeSeries.h>
00038 #include <NodalLoad.h>
00039 #include <ElementalLoad.h>
00040 #include <SP_Constraint.h>
00041 #include <ArrayOfTaggedObjects.h>
00042 #include <ElementalLoadIter.h>
00043 #include <NodalLoadIter.h>
00044 #include <SingleDomSP_Iter.h>
00045 #include <Channel.h>
00046 #include <FEM_ObjectBroker.h>
00047 #include <GroundMotion.h>
00048
00049 #include <OPS_Globals.h>
00050
00051 LoadPattern::LoadPattern(int tag, int clasTag)
00052 :DomainComponent(tag,clasTag),
00053 isConstant(1), loadFactor(0),
00054 theSeries(0),
00055 currentGeoTag(0), lastGeoSendTag(-1),
00056 theNodalLoads(0), theElementalLoads(0), theSPs(0),
00057 theNodIter(0), theEleIter(0), theSpIter(0), lastChannel(0)
00058 {
00059
00060 theNodalLoads = new ArrayOfTaggedObjects(32);
00061 theElementalLoads = new ArrayOfTaggedObjects(32);
00062 theSPs = new ArrayOfTaggedObjects(32);
00063
00064 if (theNodalLoads == 0 || theElementalLoads == 0 || theSPs == 0) {
00065 opserr << " LoadPattern::LoadPattern() - ran out of memory\n";
00066 exit(-1);
00067 }
00068
00069 theEleIter = new ElementalLoadIter(theElementalLoads);
00070 theNodIter = new NodalLoadIter(theNodalLoads);
00071 theSpIter = new SingleDomSP_Iter(theSPs);
00072
00073 if (theEleIter == 0 || theNodIter == 0 || theSpIter == 0) {
00074 opserr << " LoadPattern::LoadPattern() - ran out of memory\n";
00075 exit(-1);
00076 }
00077
00078 randomLoads = 0;
00079
00080 }
00081
00082
00083 LoadPattern::LoadPattern()
00084 :DomainComponent(0,PATTERN_TAG_LoadPattern),
00085 isConstant(1), loadFactor(0),
00086 theSeries(0),
00087 currentGeoTag(0), lastGeoSendTag(-1),
00088 dbSPs(0), dbNod(0), dbEle(0),
00089 theNodalLoads(0), theElementalLoads(0), theSPs(0),
00090 theNodIter(0), theEleIter(0), theSpIter(0), lastChannel(0)
00091 {
00092 theNodalLoads = new ArrayOfTaggedObjects(32);
00093 theElementalLoads = new ArrayOfTaggedObjects(32);
00094 theSPs = new ArrayOfTaggedObjects(32);
00095
00096 if (theNodalLoads == 0 || theElementalLoads == 0 || theSPs == 0) {
00097 opserr << " LoadPattern::LoadPattern() - ran out of memory\n";
00098 exit(-1);
00099 }
00100
00101 theEleIter = new ElementalLoadIter(theElementalLoads);
00102 theNodIter = new NodalLoadIter(theNodalLoads);
00103 theSpIter = new SingleDomSP_Iter(theSPs);
00104
00105 if (theEleIter == 0 || theNodIter == 0 || theSpIter == 0) {
00106 opserr << " LoadPattern::LoadPattern() - ran out of memory\n";
00107 exit(-1);
00108 }
00109
00110 randomLoads = 0;
00111
00112 }
00113
00114
00115 LoadPattern::LoadPattern(int tag)
00116 :DomainComponent(tag,PATTERN_TAG_LoadPattern),
00117 isConstant(1), loadFactor(0.),
00118 theSeries(0),
00119 currentGeoTag(0), lastGeoSendTag(-1),
00120 dbSPs(0), dbNod(0), dbEle(0),
00121 theNodalLoads(0), theElementalLoads(0), theSPs(0),
00122 theNodIter(0), theEleIter(0), theSpIter(0), lastChannel(0)
00123 {
00124 theNodalLoads = new ArrayOfTaggedObjects(32);
00125 theElementalLoads = new ArrayOfTaggedObjects(32);
00126 theSPs = new ArrayOfTaggedObjects(32);
00127
00128 if (theNodalLoads == 0 || theElementalLoads == 0 || theSPs == 0) {
00129 opserr << " LoadPattern::LoadPattern() - ran out of memory\n";
00130 exit(-1);
00131 }
00132
00133 theEleIter = new ElementalLoadIter(theElementalLoads);
00134 theNodIter = new NodalLoadIter(theNodalLoads);
00135 theSpIter = new SingleDomSP_Iter(theSPs);
00136
00137 if (theEleIter == 0 || theNodIter == 0 || theSpIter == 0) {
00138 opserr << " LoadPattern::LoadPattern() - ran out of memory\n";
00139 exit(-1);
00140 }
00141
00142 randomLoads = 0;
00143
00144 }
00145
00146
00147
00148
00149
00150 LoadPattern::~LoadPattern()
00151 {
00152 if (theSeries != 0)
00153 delete theSeries;
00154
00155 if (theNodalLoads != 0)
00156 delete theNodalLoads;
00157
00158 if (theElementalLoads != 0)
00159 delete theElementalLoads;
00160
00161 if (theSPs != 0)
00162 delete theSPs;
00163
00164 if (theEleIter != 0)
00165 delete theEleIter;
00166
00167 if (theNodIter != 0)
00168 delete theNodIter;
00169
00170 if (theSpIter != 0)
00171 delete theSpIter;
00172
00173
00174 if (randomLoads != 0)
00175 delete randomLoads;
00176
00177 }
00178
00179
00180 void
00181 LoadPattern::setTimeSeries(TimeSeries *theTimeSeries)
00182 {
00183
00184 if (theSeries != 0)
00185 delete theSeries;
00186
00187
00188 theSeries = theTimeSeries;
00189 }
00190
00191
00192 void
00193 LoadPattern::setDomain(Domain *theDomain)
00194 {
00195
00196 if (theNodalLoads != 0) {
00197 NodalLoad *nodLoad;
00198 NodalLoadIter &theNodalIter = this->getNodalLoads();
00199 while ((nodLoad = theNodalIter()) != 0)
00200 nodLoad->setDomain(theDomain);
00201
00202 ElementalLoad *eleLoad;
00203 ElementalLoadIter &theElementalIter = this->getElementalLoads();
00204 while ((eleLoad = theElementalIter()) != 0)
00205 eleLoad->setDomain(theDomain);
00206
00207 SP_Constraint *theSP;
00208 SP_ConstraintIter &theSpConstraints = this->getSPs();
00209 while ((theSP = theSpConstraints()) != 0)
00210 theSP->setDomain(theDomain);
00211 }
00212
00213
00214 this->DomainComponent::setDomain(theDomain);
00215 }
00216
00217
00218
00219 bool
00220 LoadPattern::addNodalLoad(NodalLoad *load)
00221 {
00222 Domain *theDomain = this->getDomain();
00223
00224 bool result = theNodalLoads->addComponent(load);
00225 if (result == true) {
00226 if (theDomain != 0)
00227 load->setDomain(theDomain);
00228 load->setLoadPatternTag(this->getTag());
00229 currentGeoTag++;
00230 } else
00231 opserr << "WARNING: LoadPattern::addNodalLoad() - load could not be added\n";
00232
00233 return result;
00234 }
00235
00236 bool
00237 LoadPattern::addElementalLoad(ElementalLoad *load)
00238 {
00239 Domain *theDomain = this->getDomain();
00240
00241 bool result = theElementalLoads->addComponent(load);
00242 if (result == true) {
00243 if (theDomain != 0)
00244 load->setDomain(theDomain);
00245 load->setLoadPatternTag(this->getTag());
00246 currentGeoTag++;
00247 } else
00248 opserr << "WARNING: LoadPattern::addElementalLoad() - load could not be added\n";
00249
00250 return result;
00251 }
00252
00253 bool
00254 LoadPattern::addSP_Constraint(SP_Constraint *theSp)
00255 {
00256 Domain *theDomain = this->getDomain();
00257
00258 bool result = theSPs->addComponent(theSp);
00259 if (result == true) {
00260 if (theDomain != 0)
00261 theSp->setDomain(theDomain);
00262 theSp->setLoadPatternTag(this->getTag());
00263 currentGeoTag++;
00264 } else
00265 opserr << "WARNING: LoadPattern::addSP_Constraint() - load could not be added\n";
00266 return result;
00267 }
00268
00269
00270 NodalLoadIter &
00271 LoadPattern::getNodalLoads(void)
00272 {
00273 theNodIter->reset();
00274 return *theNodIter;
00275 }
00276
00277 ElementalLoadIter &
00278 LoadPattern::getElementalLoads(void)
00279 {
00280 theEleIter->reset();
00281 return *theEleIter;
00282 }
00283
00284 SP_ConstraintIter &
00285 LoadPattern::getSPs(void)
00286 {
00287 theSpIter->reset();
00288 return *theSpIter;
00289 }
00290
00291 void
00292 LoadPattern::clearAll(void)
00293 {
00294 theElementalLoads->clearAll();
00295 theNodalLoads->clearAll();
00296 theSPs->clearAll();
00297 currentGeoTag++;
00298 lastChannel = 0;
00299 }
00300
00301 NodalLoad *
00302 LoadPattern::removeNodalLoad(int tag)
00303 {
00304 TaggedObject *obj = theNodalLoads->removeComponent(tag);
00305 if (obj == 0)
00306 return 0;
00307 NodalLoad *result = (NodalLoad *)obj;
00308 result->setDomain(0);
00309 currentGeoTag++;
00310 return result;
00311 }
00312
00313 ElementalLoad *
00314 LoadPattern::removeElementalLoad(int tag)
00315 {
00316 TaggedObject *obj = theElementalLoads->removeComponent(tag);
00317 if (obj == 0)
00318 return 0;
00319 ElementalLoad *result = (ElementalLoad *)obj;
00320 result->setDomain(0);
00321 currentGeoTag++;
00322 return result;
00323 }
00324
00325 SP_Constraint *
00326 LoadPattern::removeSP_Constraint(int tag)
00327 {
00328 TaggedObject *obj = theSPs->removeComponent(tag);
00329 if (obj == 0)
00330 return 0;
00331 SP_Constraint *result = (SP_Constraint *)obj;
00332 result->setDomain(0);
00333 currentGeoTag++;
00334 return result;
00335 }
00336
00337
00338 void
00339 LoadPattern::applyLoad(double pseudoTime)
00340 {
00341
00342 if (theSeries != 0 && isConstant != 0)
00343 loadFactor = theSeries->getFactor(pseudoTime);
00344
00345 NodalLoad *nodLoad;
00346 NodalLoadIter &theNodalIter = this->getNodalLoads();
00347
00348 while ((nodLoad = theNodalIter()) != 0)
00349 nodLoad->applyLoad(loadFactor);
00350
00351 ElementalLoad *eleLoad;
00352 ElementalLoadIter &theElementalIter = this->getElementalLoads();
00353 while ((eleLoad = theElementalIter()) != 0)
00354 eleLoad->applyLoad(loadFactor);
00355
00356 SP_Constraint *sp;
00357 SP_ConstraintIter &theIter = this->getSPs();
00358 while ((sp = theIter()) != 0)
00359 sp->applyConstraint(loadFactor);
00360 }
00361
00362 void
00363 LoadPattern::setLoadConstant(void)
00364 {
00365 isConstant = 0;
00366 }
00367
00368 double
00369 LoadPattern::getLoadFactor(void)
00370 {
00371 if (theSeries != 0)
00372 return loadFactor;
00373 else
00374 return 0.0;
00375 }
00376
00377 int
00378 LoadPattern::sendSelf(int cTag, Channel &theChannel)
00379 {
00380
00381
00382 int myDbTag = this->getDbTag();
00383
00384
00385 int numNodLd, numEleLd, numSPs;
00386 ID lpData(11);
00387
00388 numNodLd = theNodalLoads->getNumComponents();
00389 numEleLd = theElementalLoads->getNumComponents();
00390 numSPs = theSPs->getNumComponents();
00391
00392 lpData(10) = this->getTag();
00393 lpData(0) = currentGeoTag;
00394 lpData(1) = numNodLd;
00395 lpData(2) = numEleLd;
00396 lpData(3) = numSPs;
00397
00398 if (dbNod == 0) {
00399 dbNod = theChannel.getDbTag();
00400 dbEle = theChannel.getDbTag();
00401 dbSPs = theChannel.getDbTag();
00402 }
00403
00404 lpData(4) = dbNod;
00405 lpData(5) = dbEle;
00406 lpData(6) = dbSPs;
00407
00408 lpData(7) = isConstant;
00409
00410 if (theSeries != 0) {
00411 int dbtag = theSeries->getDbTag();
00412 int classtag = theSeries->getClassTag();
00413 if (dbtag == 0) {
00414 dbtag = theChannel.getDbTag();
00415 theSeries->setDbTag(dbtag);
00416 }
00417 lpData(8) = classtag;
00418 lpData(9) = dbtag;
00419 } else
00420 lpData(8) = -1;
00421
00422
00423
00424
00425
00426 if (theChannel.sendID(myDbTag, cTag, lpData) < 0) {
00427 opserr << "LoadPattern::sendSelf - channel failed to send the initial ID\n";
00428 return -1;
00429 }
00430
00431 if (isConstant == 0) {
00432 Vector data(1);
00433 data(0) = loadFactor;
00434 if (theChannel.sendVector(myDbTag, cTag, data) < 0) {
00435 opserr << "LoadPattern::sendSelf - channel failed to send the Vector\n";
00436 return -2;
00437 }
00438
00439 }
00440
00441 if (theSeries != 0)
00442 if (theSeries->sendSelf(cTag, theChannel) < 0) {
00443 opserr << "LoadPattern::sendSelf - the TimeSeries failed to send\n";
00444 return -3;
00445 }
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461 if (lastChannel != theChannel.getTag() || lastGeoSendTag != currentGeoTag || theChannel.isDatastore() == 0) {
00462
00463 lastChannel = theChannel.getTag();
00464
00465
00466
00467
00468
00469
00470
00471 if (numNodLd != 0) {
00472 ID nodeData(numNodLd*2);
00473 NodalLoad *theNode;
00474 NodalLoadIter &theNodes = this->getNodalLoads();
00475 int loc =0;
00476
00477
00478 while ((theNode = theNodes()) != 0) {
00479 nodeData(loc) = theNode->getClassTag();
00480 int dbTag = theNode->getDbTag();
00481
00482
00483
00484 if (dbTag == 0 && myDbTag != 0) {
00485 dbTag = theChannel.getDbTag();
00486 if (dbTag != 0)
00487 theNode->setDbTag(dbTag);
00488 }
00489
00490 nodeData(loc+1) = dbTag;
00491 loc+=2;
00492 }
00493
00494
00495 if (theChannel.sendID(dbNod, currentGeoTag, nodeData) < 0) {
00496 opserr << "LoadPattern::sendSelf - channel failed to send the NodalLoads ID\n";
00497 return -4;
00498 }
00499 }
00500
00501
00502
00503 if (numEleLd != 0) {
00504 ID elementData(numEleLd*2);
00505 ElementalLoad *theEle;
00506 ElementalLoadIter &theElements = this->getElementalLoads();
00507 int loc = 0;
00508
00509 while ((theEle = theElements()) != 0) {
00510 elementData(loc) = theEle->getClassTag();
00511 int dbTag = theEle->getDbTag();
00512
00513 if (dbTag == 0 && myDbTag != 0) {
00514 dbTag = theChannel.getDbTag();
00515 if (dbTag != 0)
00516 theEle->setDbTag(dbTag);
00517 }
00518
00519 elementData(loc+1) = dbTag;
00520 loc+=2;
00521 }
00522
00523
00524 if (theChannel.sendID(dbEle, currentGeoTag, elementData) < 0) {
00525 opserr << "Domain::send - channel failed to send the element ID\n";
00526 return -5;
00527 }
00528 }
00529
00530
00531
00532 if (numSPs != 0) {
00533 ID spData(numSPs*2);
00534 SP_Constraint *theSP;
00535 SP_ConstraintIter &theSPs = this->getSPs();
00536 int loc = 0;
00537
00538 while ((theSP = theSPs()) != 0) {
00539 spData(loc) = theSP->getClassTag();
00540 int dbTag = theSP->getDbTag();
00541
00542 if (dbTag == 0 && myDbTag != 0) {
00543 dbTag = theChannel.getDbTag();
00544 if (dbTag != 0)
00545 theSP->setDbTag(dbTag);
00546 }
00547
00548 spData(loc+1) = dbTag;
00549 loc+=2;
00550 }
00551
00552 if (theChannel.sendID(dbSPs, currentGeoTag, spData) < 0) {
00553 opserr << "LoadPAttern::sendSelf - channel failed sending SP_Constraint ID\n";
00554 return -6;
00555 }
00556 }
00557
00558
00559 lastGeoSendTag = currentGeoTag;
00560 if (theChannel.isDatastore() == 1) {
00561 static ID theLastSendTag(1);
00562 theLastSendTag(0) = lastGeoSendTag;
00563 theChannel.sendID(myDbTag,0, theLastSendTag);
00564 }
00565 }
00566
00567
00568
00569 NodalLoad *theNode;
00570 NodalLoadIter &theNodes = this->getNodalLoads();
00571 while ((theNode = theNodes()) != 0) {
00572 if (theNode->sendSelf(cTag, theChannel) < 0) {
00573 opserr << "LoadPattern::sendSelf - node with tag " << theNode->getTag() << " failed in sendSelf\n";
00574 return -7;
00575 }
00576 }
00577
00578 ElementalLoad *theEle;
00579 ElementalLoadIter &theElements = this->getElementalLoads();
00580 while ((theEle = theElements()) != 0) {
00581 if (theEle->sendSelf(cTag, theChannel) < 0) {
00582 opserr << "LoadPattern::sendSelf - element with tag " << theEle->getTag() << " failed in sendSelf\n";
00583 return -8;
00584 }
00585 }
00586
00587 SP_Constraint *theSP;
00588 SP_ConstraintIter &theSPs = this->getSPs();
00589 while ((theSP = theSPs()) != 0) {
00590 if (theSP->sendSelf(cTag, theChannel) < 0) {
00591
00592 opserr << "LoadPattern::sendSelf - SP_Constraint: " << *theSP << " failed sendSelf\n";
00593 return -9;
00594 }
00595 }
00596
00597
00598 return 0;
00599 }
00600
00601
00602
00603 int
00604 LoadPattern::recvSelf(int cTag, Channel &theChannel, FEM_ObjectBroker &theBroker)
00605 {
00606
00607
00608
00609 int myDbTag = this->getDbTag();
00610
00611
00612 int numNod, numEle, numSPs;
00613 ID lpData(11);
00614
00615 if (theChannel.recvID(myDbTag, cTag, lpData) < 0) {
00616 opserr << "LoadPattern::recvSelf - channel failed to recv the initial ID\n";
00617 return -1;
00618 }
00619
00620 isConstant = lpData(7);
00621
00622 this->setTag(lpData(10));
00623
00624 if (isConstant == 0) {
00625 Vector data(1);
00626 if (theChannel.recvVector(myDbTag, cTag, data) < 0) {
00627 opserr << "LoadPattern::recvSelf - channel failed to recv the Vector\n";
00628 return -2;
00629 }
00630 loadFactor = data(0);
00631 }
00632
00633
00634 if (lpData(8) != -1) {
00635 if (theSeries == 0) {
00636 theSeries = theBroker.getNewTimeSeries(lpData(8));
00637 } else if (theSeries->getClassTag() != lpData(8)) {
00638 delete theSeries;
00639 theSeries = theBroker.getNewTimeSeries(lpData(8));
00640 }
00641 if (theSeries == 0) {
00642 opserr << "LoadPattern::recvSelf - failed to create TimeSeries\n";
00643 return -3;
00644 }
00645
00646 theSeries->setDbTag(lpData(9));
00647
00648 if (theSeries->recvSelf(cTag, theChannel, theBroker) < 0) {
00649 opserr << "LoadPattern::recvSelf - the TimeSeries failed to recv\n";
00650 return -3;
00651 }
00652 }
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662 if (lastChannel != theChannel.getTag() || currentGeoTag != lpData(0) || theChannel.isDatastore() == 0) {
00663
00664
00665 this->clearAll();
00666 lastChannel = theChannel.getTag();
00667 currentGeoTag = lpData(0);
00668
00669 numNod = lpData(1);
00670 numEle = lpData(2);
00671 numSPs = lpData(3);
00672 dbNod = lpData(4);
00673 dbEle = lpData(5);
00674 dbSPs = lpData(6);
00675
00676
00677
00678
00679
00680
00681 if (numNod != 0) {
00682 ID nodeData(2*numNod);
00683
00684
00685 if (theChannel.recvID(dbNod, currentGeoTag, nodeData) < 0) {
00686 opserr << "LoadPAttern::recvSelf - channel failed to recv the NodalLoad ID\n";
00687 return -2;
00688 }
00689
00690
00691
00692
00693
00694 int loc = 0;
00695
00696 for (int i=0; i<numNod; i++) {
00697 int classTag = nodeData(loc);
00698 int dbTag = nodeData(loc+1);
00699
00700 NodalLoad *theNode = theBroker.getNewNodalLoad(classTag);
00701
00702 if (theNode == 0) {
00703 opserr << "LoadPattern::recv - cannot create NodalLoad with classTag " << classTag << endln;
00704 return -2;
00705 }
00706
00707 theNode->setDbTag(dbTag);
00708
00709 if (theNode->recvSelf(cTag, theChannel, theBroker) < 0) {
00710 opserr << "LoadPattern::recvSelf - NodalLoad with dbTag " << dbTag << " failed in recvSelf\n";
00711 return -2;
00712 }
00713
00714 if (this->addNodalLoad(theNode) == false) {
00715 opserr << "LoadPattern::recvSelf - failed adding NodalLoad tagged " << theNode->getTag() << " into LP!\n";
00716 return -3;
00717 }
00718
00719 loc+=2;
00720 }
00721 }
00722
00723
00724
00725
00726
00727 if (numEle != 0) {
00728 ID eleData(2*numEle);
00729
00730 if (theChannel.recvID(dbEle, currentGeoTag, eleData) < 0) {
00731 opserr << "LoadPattern::recvSelf - channel failed to recv the EleLoad ID\n";
00732 return -2;
00733 }
00734
00735 int loc = 0;
00736 for (int i=0; i<numEle; i++) {
00737 int classTag = eleData(loc);
00738 int dbTag = eleData(loc+1);
00739
00740 ElementalLoad *theEle = theBroker.getNewElementalLoad(classTag);
00741 if (theEle == 0) {
00742 opserr << "LoadPattern::recv - cannot create ElementalLoad with classTag " << classTag << endln;
00743 return -2;
00744 }
00745
00746 theEle->setDbTag(dbTag);
00747
00748 if (theEle->recvSelf(cTag, theChannel, theBroker) < 0) {
00749 opserr << "LoadPattern::recvSelf - Ele with dbTag " << dbTag << " failed in recvSelf\n";
00750 return -2;
00751 }
00752
00753 if (this->addElementalLoad(theEle) == false) {
00754 opserr << "LoadPattern::recvSelf - could not add Ele with tag " << theEle->getTag() << " into LP!\n";
00755 return -3;
00756 }
00757
00758 loc+=2;
00759 }
00760 }
00761
00762
00763
00764
00765
00766 if (numSPs != 0) {
00767 ID spData(2*numSPs);
00768
00769 if (theChannel.recvID(dbSPs, currentGeoTag, spData) < 0) {
00770 opserr << "LoadPattern::recvSelf - channel failed to recv the SP_Constraints ID\n";
00771 return -2;
00772 }
00773
00774 int loc = 0;
00775 for (int i=0; i<numSPs; i++) {
00776 int classTag = spData(loc);
00777 int dbTag = spData(loc+1);
00778
00779 SP_Constraint *theSP = theBroker.getNewSP(classTag);
00780 if (theSP == 0) {
00781 opserr << "LoadPattern::recv - cannot create SP_Constraint with classTag " << classTag << endln;
00782 return -2;
00783 }
00784 theSP->setDbTag(dbTag);
00785
00786 if (theSP->recvSelf(cTag, theChannel, theBroker) < 0) {
00787 opserr << "LoadPattern::recvSelf - SP_Constraint with dbTag " << dbTag << " failed in recvSelf\n";
00788 return -2;
00789 }
00790
00791 if (this->addSP_Constraint(theSP) == false) {
00792 opserr << "LoadPattern::recvSelf - could not add SP_Constraint with tag " << theSP->getTag()
00793 << " into LP!\n";
00794
00795 return -3;
00796 }
00797
00798 loc+=2;
00799 }
00800 }
00801
00802
00803 currentGeoTag = lpData(0);
00804 lastGeoSendTag = currentGeoTag;
00805
00806 } else {
00807 if (theSeries != 0)
00808 if (theSeries->recvSelf(cTag, theChannel, theBroker) < 0) {
00809 opserr << "LoadPattern::recvSelf - the TimeSeries failed to recv\n";
00810 return -3;
00811 }
00812
00813
00814 NodalLoad *theNode;
00815 NodalLoadIter &theNodes = this->getNodalLoads();
00816 while ((theNode = theNodes()) != 0) {
00817 if (theNode->recvSelf(cTag, theChannel, theBroker) < 0) {
00818 opserr << "LoadPattern::recvSelf - node with tag " << theNode->getTag() << " failed in recvSelf\n";
00819 return -7;
00820 }
00821 }
00822
00823 ElementalLoad *theEle;
00824 ElementalLoadIter &theElements = this->getElementalLoads();
00825 while ((theEle = theElements()) != 0) {
00826 if (theEle->recvSelf(cTag, theChannel, theBroker) < 0) {
00827 opserr << "LoadPattern::recvSelf - element with tag " << theEle->getTag() << " failed in recvSelf\n";
00828 return -8;
00829 }
00830 }
00831
00832 SP_Constraint *theSP;
00833 SP_ConstraintIter &theSPs = this->getSPs();
00834 while ((theSP = theSPs()) != 0) {
00835 if (theSP->recvSelf(cTag, theChannel, theBroker) < 0) {
00836 opserr << "LoadPattern::recvSelf - SP_Constraint tagged " << theSP->getTag() << " failed recvSelf\n";
00837 return -9;
00838 }
00839 }
00840 }
00841
00842
00843 return 0;
00844 }
00845
00846 void
00847 LoadPattern::Print(OPS_Stream &s, int flag)
00848 {
00849 s << "Load Pattern: " << this->getTag() << "\n";
00850 if (theSeries != 0)
00851 theSeries->Print(s,flag);
00852 opserr << " Nodal Loads: \n";
00853 theNodalLoads->Print(s,flag);
00854 opserr << "\n Elemental Loads: \n";
00855 theElementalLoads->Print(s, flag);
00856 opserr << "\n Single Point Constraints: \n";
00857 theSPs->Print(s, flag);
00858 }
00859
00860
00861 LoadPattern *
00862 LoadPattern::getCopy(void)
00863 {
00864 LoadPattern *theCopy = new LoadPattern(this->getTag());
00865 if (theCopy == 0) {
00866 opserr << "LoadPattern::getCopy() - ran out of memory\n";
00867 return theCopy;
00868 }
00869 theCopy->loadFactor = loadFactor;
00870 theCopy->isConstant = isConstant;
00871 theCopy->theSeries = theSeries;
00872 return theCopy;
00873 }
00874
00875 int
00876 LoadPattern::addMotion(GroundMotion &theMotion, int tag)
00877 {
00878 opserr << "LoadPattern::addMotion() - cannot add GroundMotion - use MultiSupport Pattern instead\n";
00879 return -1;
00880 }
00881
00882 GroundMotion *
00883 LoadPattern::getMotion(int tag)
00884 {
00885 return 0;
00886 }
00887
00888
00889
00890 void
00891 LoadPattern::applyLoadSensitivity(double pseudoTime)
00892 {
00893 if (theSeries != 0 && isConstant != 0) {
00894 loadFactor = theSeries->getFactorSensitivity(pseudoTime);
00895 }
00896
00897 NodalLoad *nodLoad;
00898 NodalLoadIter &theNodalIter = this->getNodalLoads();
00899 while ((nodLoad = theNodalIter()) != 0)
00900 nodLoad->applyLoad(loadFactor);
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915 }
00916
00917 int
00918 LoadPattern::setParameter(const char **argv, int argc, Parameter ¶m)
00919 {
00920 if (theSeries == 0) {
00921 opserr << "set/update/activate parameter is illegaly called in LoadPattern " << endln;
00922 return 0;
00923 }
00924
00925 if (argc < 1)
00926 return -1;
00927
00928
00929 if (strstr(argv[0],"loadAtNode") != 0) {
00930
00931 if (argc < 3)
00932 return -1;
00933
00934 RVisRandomProcessDiscretizer = false;
00935
00936 int nodeNumber = atoi(argv[1]);
00937 NodalLoad *thePossibleNodalLoad;
00938 NodalLoad *theNodalLoad = 0;
00939 NodalLoadIter &theNodalIter = this->getNodalLoads();
00940
00941 while ((thePossibleNodalLoad = theNodalIter()) != 0) {
00942 if ( nodeNumber == thePossibleNodalLoad->getNodeTag() ) {
00943 theNodalLoad = thePossibleNodalLoad;
00944 }
00945 }
00946
00947 if (theNodalLoad != 0)
00948 return theNodalLoad->setParameter(&argv[2], argc-2, param);
00949 else
00950 return -1;
00951 }
00952
00953 else if (strstr(argv[0],"elementPointLoad") != 0) {
00954
00955 if (argc < 3)
00956 return -1;
00957
00958 RVisRandomProcessDiscretizer = false;
00959
00960 int eleNumber = atoi(argv[1]);
00961 ElementalLoad *theEleLoad = 0;
00962 ElementalLoadIter &theEleLoadIter = this->getElementalLoads();
00963 while ((theEleLoad = theEleLoadIter()) != 0) {
00964 const ID &eleTags = theEleLoad->getElementTags();
00965 for (int i = 0; i < eleTags.Size(); i++)
00966 if (eleNumber == eleTags(i)) {
00967 return theEleLoad->setParameter(&argv[2], argc-2, param);
00968 }
00969 }
00970
00971 return -1;
00972 }
00973
00974 else if (strstr(argv[0],"randomProcessDiscretizer") != 0) {
00975
00976 if (argc < 2)
00977 return -1;
00978
00979 RVisRandomProcessDiscretizer = true;
00980 return theSeries->setParameter(&argv[1], argc-1, param);
00981 }
00982
00983
00984 else
00985 return -1;
00986 }
00987
00988 int
00989 LoadPattern::updateParameter(int parameterID, Information &info)
00990 {
00991 if (theSeries == 0) {
00992 opserr << "set/update/activate parameter is illegaly called in LoadPattern " << endln;
00993 }
00994
00995 opserr << "LoadPattern::updateParameter -- no parameters defined, this method should not be called" << endln;
00996
00997 return 0;
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043
01044 }
01045
01046
01047
01048
01049
01050 int
01051 LoadPattern::activateParameter(int parameterID)
01052 {
01053 if (theSeries == 0) {
01054 opserr << "set/update/activate parameter is illegaly called in LoadPattern " << endln;
01055 }
01056
01057 opserr << "LoadPattern::activateParameter -- no parameters defined, this method should not be called" << endln;
01058
01059 return 0;
01060
01061
01062
01063
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084
01085
01086
01087
01088
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119 }
01120
01121
01122 const Vector &
01123 LoadPattern::getExternalForceSensitivity(int gradNumber)
01124 {
01125
01126
01127
01128
01129
01130 Vector tempRandomLoads(1);
01131 int sizeRandomLoads;
01132
01133
01134 if (randomLoads == 0) {
01135 randomLoads = new Vector(1);
01136 }
01137 else {
01138 delete randomLoads;
01139 randomLoads = new Vector(1);
01140 }
01141
01142
01143 NodalLoad *theNodalLoad = 0;
01144 NodalLoadIter &theNodalIter = this->getNodalLoads();
01145 int i;
01146
01147
01148 int nodeNumber;
01149 int dofNumber;
01150 while ((theNodalLoad = theNodalIter()) != 0) {
01151 const Vector &gradientVector = theNodalLoad->getExternalForceSensitivity(gradNumber);
01152 if (gradientVector(0) != 0.0 ) {
01153
01154
01155 nodeNumber = theNodalLoad->getNodeTag();
01156 dofNumber = (int)gradientVector(0);
01157
01158
01159 sizeRandomLoads = randomLoads->Size();
01160 if (sizeRandomLoads == 1) {
01161 delete randomLoads;
01162 randomLoads = new Vector(2);
01163 (*randomLoads)(0) = (double)nodeNumber;
01164 (*randomLoads)(1) = (double)dofNumber;
01165 }
01166 else {
01167 tempRandomLoads = (*randomLoads);
01168 delete randomLoads;
01169 randomLoads = new Vector(sizeRandomLoads+2);
01170 for (i=0; i<sizeRandomLoads; i++) {
01171 (*randomLoads)(i) = tempRandomLoads(i);
01172 }
01173 (*randomLoads)(sizeRandomLoads) = nodeNumber;
01174 (*randomLoads)(sizeRandomLoads+1) = dofNumber;
01175 }
01176 }
01177 }
01178
01179 return (*randomLoads);
01180 }
01181
01182