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
00037 #include <LoadPattern.h>
00038 #include <stdlib.h>
00039 #include <ID.h>
00040 #include <TimeSeries.h>
00041 #include <NodalLoad.h>
00042 #include <ElementalLoad.h>
00043 #include <SP_Constraint.h>
00044 #include <ArrayOfTaggedObjects.h>
00045 #include <ElementalLoadIter.h>
00046 #include <NodalLoadIter.h>
00047 #include <SingleDomSP_Iter.h>
00048 #include <Channel.h>
00049 #include <FEM_ObjectBroker.h>
00050
00051 #include <G3Globals.h>
00052
00053 LoadPattern::LoadPattern(int tag, int clasTag)
00054 :DomainComponent(tag,clasTag),
00055 loadFactor(0), isConstant(1),
00056 theSeries(0),
00057 currentGeoTag(0), lastGeoSendTag(0),
00058 theNodalLoads(0), theElementalLoads(0), theSPs(0),
00059 theNodIter(0), theEleIter(0), theSpIter(0)
00060 {
00061
00062 theNodalLoads = new ArrayOfTaggedObjects(32);
00063 theElementalLoads = new ArrayOfTaggedObjects(32);
00064 theSPs = new ArrayOfTaggedObjects(32);
00065
00066 if (theNodalLoads == 0 || theElementalLoads == 0 || theSPs == 0) {
00067 cerr << " LoadPattern::LoadPattern() - ran out of memory\n";
00068 exit(-1);
00069 }
00070
00071 theEleIter = new ElementalLoadIter(theElementalLoads);
00072 theNodIter = new NodalLoadIter(theNodalLoads);
00073 theSpIter = new SingleDomSP_Iter(theSPs);
00074
00075 if (theEleIter == 0 || theNodIter == 0 || theSpIter == 0) {
00076 cerr << " LoadPattern::LoadPattern() - ran out of memory\n";
00077 exit(-1);
00078 }
00079 }
00080
00081
00082 LoadPattern::LoadPattern()
00083 :DomainComponent(0,PATTERN_TAG_LoadPattern),
00084 loadFactor(0), isConstant(1),
00085 theSeries(0),
00086 currentGeoTag(0), lastGeoSendTag(0),
00087 dbSPs(0), dbNod(0), dbEle(0),
00088 theNodalLoads(0), theElementalLoads(0), theSPs(0),
00089 theNodIter(0), theEleIter(0), theSpIter(0)
00090 {
00091 theNodalLoads = new ArrayOfTaggedObjects(32);
00092 theElementalLoads = new ArrayOfTaggedObjects(32);
00093 theSPs = new ArrayOfTaggedObjects(32);
00094
00095 if (theNodalLoads == 0 || theElementalLoads == 0 || theSPs == 0) {
00096 cerr << " LoadPattern::LoadPattern() - ran out of memory\n";
00097 exit(-1);
00098 }
00099
00100 theEleIter = new ElementalLoadIter(theElementalLoads);
00101 theNodIter = new NodalLoadIter(theNodalLoads);
00102 theSpIter = new SingleDomSP_Iter(theSPs);
00103
00104 if (theEleIter == 0 || theNodIter == 0 || theSpIter == 0) {
00105 cerr << " LoadPattern::LoadPattern() - ran out of memory\n";
00106 exit(-1);
00107 }
00108 }
00109
00110
00111 LoadPattern::LoadPattern(int tag)
00112 :DomainComponent(tag,PATTERN_TAG_LoadPattern),
00113 loadFactor(0), isConstant(1),
00114 theSeries(0),
00115 currentGeoTag(0), lastGeoSendTag(0),
00116 dbSPs(0), dbNod(0), dbEle(0),
00117 theNodalLoads(0), theElementalLoads(0), theSPs(0),
00118 theNodIter(0), theEleIter(0), theSpIter(0)
00119 {
00120 theNodalLoads = new ArrayOfTaggedObjects(32);
00121 theElementalLoads = new ArrayOfTaggedObjects(32);
00122 theSPs = new ArrayOfTaggedObjects(32);
00123
00124 if (theNodalLoads == 0 || theElementalLoads == 0 || theSPs == 0) {
00125 cerr << " LoadPattern::LoadPattern() - ran out of memory\n";
00126 exit(-1);
00127 }
00128
00129 theEleIter = new ElementalLoadIter(theElementalLoads);
00130 theNodIter = new NodalLoadIter(theNodalLoads);
00131 theSpIter = new SingleDomSP_Iter(theSPs);
00132
00133 if (theEleIter == 0 || theNodIter == 0 || theSpIter == 0) {
00134 cerr << " LoadPattern::LoadPattern() - ran out of memory\n";
00135 exit(-1);
00136 }
00137 }
00138
00139
00140
00141
00142
00143 LoadPattern::~LoadPattern()
00144 {
00145 if (theSeries != 0)
00146 delete theSeries;
00147
00148 if (theNodalLoads != 0)
00149 delete theNodalLoads;
00150
00151 if (theElementalLoads != 0)
00152 delete theElementalLoads;
00153
00154 if (theSPs != 0)
00155 delete theSPs;
00156
00157 if (theEleIter != 0)
00158 delete theEleIter;
00159
00160 if (theNodIter != 0)
00161 delete theNodIter;
00162
00163 if (theSpIter != 0)
00164 delete theSpIter;
00165 }
00166
00167
00168 void
00169 LoadPattern::setTimeSeries(TimeSeries *theTimeSeries)
00170 {
00171
00172 if (theSeries != 0)
00173 delete theSeries;
00174
00175
00176 theSeries = theTimeSeries;
00177 }
00178
00179
00180 void
00181 LoadPattern::setDomain(Domain *theDomain)
00182 {
00183
00184 if (theNodalLoads != 0) {
00185 NodalLoad *nodLoad;
00186 NodalLoadIter &theNodalIter = this->getNodalLoads();
00187 while ((nodLoad = theNodalIter()) != 0)
00188 nodLoad->setDomain(theDomain);
00189
00190 ElementalLoad *eleLoad;
00191 ElementalLoadIter &theElementalIter = this->getElementalLoads();
00192 while ((eleLoad = theElementalIter()) != 0)
00193 eleLoad->setDomain(theDomain);
00194
00195 SP_Constraint *theSP;
00196 SP_ConstraintIter &theSpConstraints = this->getSPs();
00197 while ((theSP = theSpConstraints()) != 0)
00198 theSP->setDomain(theDomain);
00199 }
00200
00201
00202 this->DomainComponent::setDomain(theDomain);
00203 }
00204
00205
00206
00207 bool
00208 LoadPattern::addNodalLoad(NodalLoad *load)
00209 {
00210 Domain *theDomain = this->getDomain();
00211
00212 bool result = theNodalLoads->addComponent(load);
00213 if (result == true) {
00214 if (theDomain != 0)
00215 load->setDomain(theDomain);
00216 load->setLoadPatternTag(this->getTag());
00217 currentGeoTag++;
00218 } else
00219 cerr << "WARNING: LoadPattern::addNodalLoad() - load could not be added\n";
00220
00221 return result;
00222 }
00223
00224 bool
00225 LoadPattern::addElementalLoad(ElementalLoad *load)
00226 {
00227 Domain *theDomain = this->getDomain();
00228
00229 bool result = theElementalLoads->addComponent(load);
00230 if (result == true) {
00231 if (theDomain != 0)
00232 load->setDomain(theDomain);
00233 load->setLoadPatternTag(this->getTag());
00234 currentGeoTag++;
00235 } else
00236 cerr << "WARNING: LoadPattern::addElementalLoad() - load could not be added\n";
00237
00238 return result;
00239 }
00240
00241 bool
00242 LoadPattern::addSP_Constraint(SP_Constraint *theSp)
00243 {
00244 Domain *theDomain = this->getDomain();
00245
00246 bool result = theSPs->addComponent(theSp);
00247 if (result == true) {
00248 if (theDomain != 0)
00249 theSp->setDomain(theDomain);
00250 theSp->setLoadPatternTag(this->getTag());
00251 currentGeoTag++;
00252 } else
00253 cerr << "WARNING: LoadPattern::addSP_Constraint() - load could not be added\n";
00254 return result;
00255 }
00256
00257
00258 NodalLoadIter &
00259 LoadPattern::getNodalLoads(void)
00260 {
00261 theNodIter->reset();
00262 return *theNodIter;
00263 }
00264
00265 ElementalLoadIter &
00266 LoadPattern::getElementalLoads(void)
00267 {
00268 theEleIter->reset();
00269 return *theEleIter;
00270 }
00271
00272 SP_ConstraintIter &
00273 LoadPattern::getSPs(void)
00274 {
00275 theSpIter->reset();
00276 return *theSpIter;
00277 }
00278
00279 void
00280 LoadPattern::clearAll(void)
00281 {
00282 theElementalLoads->clearAll();
00283 theNodalLoads->clearAll();
00284 theSPs->clearAll();
00285 currentGeoTag++;
00286 }
00287
00288 NodalLoad *
00289 LoadPattern::removeNodalLoad(int tag)
00290 {
00291 TaggedObject *obj = theNodalLoads->removeComponent(tag);
00292 if (obj == 0)
00293 return 0;
00294 NodalLoad *result = (NodalLoad *)obj;
00295 result->setDomain(0);
00296 currentGeoTag++;
00297 return result;
00298 }
00299
00300 ElementalLoad *
00301 LoadPattern::removeElementalLoad(int tag)
00302 {
00303 TaggedObject *obj = theElementalLoads->removeComponent(tag);
00304 if (obj == 0)
00305 return 0;
00306 ElementalLoad *result = (ElementalLoad *)obj;
00307 result->setDomain(0);
00308 currentGeoTag++;
00309 return result;
00310 }
00311
00312 SP_Constraint *
00313 LoadPattern::removeSP_Constraint(int tag)
00314 {
00315 TaggedObject *obj = theSPs->removeComponent(tag);
00316 if (obj == 0)
00317 return 0;
00318 SP_Constraint *result = (SP_Constraint *)obj;
00319 result->setDomain(0);
00320 currentGeoTag++;
00321 return result;
00322 }
00323
00324
00325 void
00326 LoadPattern::applyLoad(double pseudoTime)
00327 {
00328
00329 if (theSeries != 0 && isConstant != 0)
00330 loadFactor = theSeries->getFactor(pseudoTime);
00331
00332 NodalLoad *nodLoad;
00333 NodalLoadIter &theNodalIter = this->getNodalLoads();
00334 while ((nodLoad = theNodalIter()) != 0)
00335 nodLoad->applyLoad(loadFactor);
00336
00337 ElementalLoad *eleLoad;
00338 ElementalLoadIter &theElementalIter = this->getElementalLoads();
00339 while ((eleLoad = theElementalIter()) != 0)
00340 eleLoad->applyLoad(loadFactor);
00341
00342 SP_Constraint *sp;
00343 SP_ConstraintIter &theIter = this->getSPs();
00344 while ((sp = theIter()) != 0)
00345 sp->applyConstraint(loadFactor);
00346 }
00347
00348 void
00349 LoadPattern::setLoadConstant(void)
00350 {
00351 isConstant = 0;
00352 }
00353
00354
00355 int
00356 LoadPattern::sendSelf(int cTag, Channel &theChannel)
00357 {
00358
00359
00360 int myDbTag = this->getDbTag();
00361
00362
00363 int numNodLd, numEleLd, numSPs;
00364 ID lpData(11);
00365
00366 lpData(0) = currentGeoTag;
00367 lpData(1) = numNodLd = theNodalLoads->getNumComponents();
00368 lpData(2) = numEleLd = theElementalLoads->getNumComponents();
00369 lpData(3) = numSPs = theSPs->getNumComponents();
00370
00371 if (dbNod == 0) {
00372 lpData(4) = dbNod = theChannel.getDbTag();
00373 lpData(5) = dbEle = theChannel.getDbTag();
00374 lpData(6) = dbSPs = theChannel.getDbTag();
00375 } else {
00376 lpData(4) = dbNod;
00377 lpData(5) = dbEle;
00378 lpData(6) = dbSPs;
00379 }
00380
00381 lpData(7) = isConstant;
00382
00383 if (theSeries != 0) {
00384 int dbtag = theSeries->getDbTag();
00385 int classtag = theSeries->getClassTag();
00386 if (dbtag == 0) {
00387 dbtag = theChannel.getDbTag();
00388 theSeries->setDbTag(dbtag);
00389 }
00390 lpData(8) = classtag;
00391 lpData(9) = dbtag;
00392 } else
00393 lpData(8) = -1;
00394
00395
00396
00397 if (loadFactor == 0.0)
00398 lpData(10) = 0;
00399 else
00400 lpData(10) = 1;
00401
00402 if (theChannel.sendID(myDbTag, cTag, lpData) < 0) {
00403 g3ErrorHandler->warning("LoadPattern::sendSelf - channel failed to send the initial ID");
00404 return -1;
00405 }
00406
00407 if (loadFactor != 0.0) {
00408 Vector data(1);
00409 data(0) = loadFactor;
00410 if (theChannel.sendVector(myDbTag, cTag, data) < 0) {
00411 g3ErrorHandler->warning("LoadPattern::sendSelf - channel failed to send the Vector");
00412 return -2;
00413 }
00414 }
00415
00416 if (theSeries != 0)
00417 if (theSeries->sendSelf(cTag, theChannel) < 0) {
00418 g3ErrorHandler->warning("LoadPattern::sendSelf - the TimeSeries failed to send");
00419 return -3;
00420 }
00421
00422
00423
00424
00425 if (lastGeoSendTag != currentGeoTag) {
00426
00427
00428
00429
00430
00431
00432
00433 if (numNodLd != 0) {
00434 ID nodeData(numNodLd*2);
00435 NodalLoad *theNode;
00436 NodalLoadIter &theNodes = this->getNodalLoads();
00437 int loc =0;
00438
00439
00440 while ((theNode = theNodes()) != 0) {
00441 nodeData(loc) = theNode->getClassTag();
00442 int dbTag = theNode->getDbTag();
00443
00444
00445
00446 if (dbTag == 0 && myDbTag != 0) {
00447 dbTag = theChannel.getDbTag();
00448 if (dbTag != 0)
00449 theNode->setDbTag(dbTag);
00450 }
00451
00452 nodeData(loc+1) = dbTag;
00453 loc+=2;
00454 }
00455
00456
00457 if (theChannel.sendID(dbNod, cTag, nodeData) < 0) {
00458 g3ErrorHandler->warning("LoadPattern::sendSelf - channel failed to send the NodalLoads ID");
00459 return -4;
00460 }
00461 }
00462
00463
00464
00465 if (numEleLd != 0) {
00466 ID elementData(numEleLd*2);
00467 ElementalLoad *theEle;
00468 ElementalLoadIter &theElements = this->getElementalLoads();
00469 int loc = 0;
00470
00471 while ((theEle = theElements()) != 0) {
00472 elementData(loc) = theEle->getClassTag();
00473 int dbTag = theEle->getDbTag();
00474
00475 if (dbTag == 0 && myDbTag != 0) {
00476 dbTag = theChannel.getDbTag();
00477 if (dbTag != 0)
00478 theEle->setDbTag(dbTag);
00479 }
00480
00481 elementData(loc+1) = dbTag;
00482 loc+=2;
00483 }
00484
00485
00486 if (theChannel.sendID(dbEle, cTag, elementData) < 0) {
00487 g3ErrorHandler->warning("Domain::send - channel failed to send the element ID");
00488 return -5;
00489 }
00490 }
00491
00492
00493
00494 if (numSPs != 0) {
00495 ID spData(numSPs*2);
00496 SP_Constraint *theSP;
00497 SP_ConstraintIter &theSPs = this->getSPs();
00498 int loc = 0;
00499
00500 while ((theSP = theSPs()) != 0) {
00501 spData(loc) = theSP->getClassTag();
00502 int dbTag = theSP->getDbTag();
00503
00504 if (dbTag == 0 && myDbTag != 0) {
00505 dbTag = theChannel.getDbTag();
00506 if (dbTag != 0)
00507 theSP->setDbTag(dbTag);
00508 }
00509
00510 spData(loc+1) = dbTag;
00511 loc+=2;
00512 }
00513
00514 if (theChannel.sendID(dbSPs, cTag, spData) < 0) {
00515 g3ErrorHandler->warning("LoadPAttern::sendSelf - channel failed sending SP_Constraint ID");
00516 return -6;
00517 }
00518 }
00519
00520
00521 lastGeoSendTag = currentGeoTag;
00522 }
00523
00524
00525
00526
00527 NodalLoad *theNode;
00528 NodalLoadIter &theNodes = this->getNodalLoads();
00529 while ((theNode = theNodes()) != 0) {
00530 if (theNode->sendSelf(cTag, theChannel) < 0) {
00531 g3ErrorHandler->warning("LoadPattern::sendSelf - node with tag %d failed in sendSelf",
00532 theNode->getTag());
00533 return -7;
00534 }
00535 }
00536
00537 ElementalLoad *theEle;
00538 ElementalLoadIter &theElements = this->getElementalLoads();
00539 while ((theEle = theElements()) != 0) {
00540 if (theEle->sendSelf(cTag, theChannel) < 0) {
00541 g3ErrorHandler->warning("LoadPattern::sendSelf - element with tag %d failed in sendSelf",
00542 theEle->getTag());
00543 return -8;
00544 }
00545 }
00546
00547 SP_Constraint *theSP;
00548 SP_ConstraintIter &theSPs = this->getSPs();
00549 while ((theSP = theSPs()) != 0) {
00550 if (theSP->sendSelf(cTag, theChannel) < 0) {
00551 g3ErrorHandler->warning("LoadPattern::sendSelf - SP_Constraint tagged %d failed sendSelf",
00552 theSP->getTag());
00553 return -9;
00554 }
00555 }
00556
00557
00558 return 0;
00559 }
00560
00561
00562
00563 int
00564 LoadPattern::recvSelf(int cTag, Channel &theChannel, FEM_ObjectBroker &theBroker)
00565 {
00566
00567
00568
00569 int myDbTag = this->getDbTag();
00570
00571
00572 int numNod, numEle, numSPs;
00573 ID lpData(11);
00574
00575 if (theChannel.recvID(myDbTag, cTag, lpData) < 0) {
00576 g3ErrorHandler->warning("LoadPattern::recvSelf - channel failed to recv the initial ID");
00577 return -1;
00578 }
00579
00580 isConstant = lpData(7);
00581
00582 if (lpData(10) == 1) {
00583 Vector data(1);
00584 data(0) = loadFactor;
00585 if (theChannel.recvVector(myDbTag, cTag, data) < 0) {
00586 g3ErrorHandler->warning("LoadPattern::recvSelf - channel failed to recv the Vector");
00587 return -2;
00588 }
00589 }
00590
00591
00592
00593 if (currentGeoTag != lpData(0) || theSeries == 0) {
00594 if (theSeries == 0) {
00595 theSeries = theBroker.getNewTimeSeries(lpData(8));
00596 theSeries->setDbTag(lpData(9));
00597 } else if (theSeries->getClassTag() != lpData(8)) {
00598 delete theSeries;
00599 theSeries = theBroker.getNewTimeSeries(lpData(8));
00600 theSeries->setDbTag(lpData(9));
00601 } else if (theSeries->getDbTag() != lpData(9)) {
00602 theSeries->setDbTag(lpData(9));
00603 }
00604
00605 if (theSeries == 0) {
00606 g3ErrorHandler->warning("LoadPattern::recvSelf - failed to create TimeSeries");
00607 return -3;
00608 }
00609
00610
00611 theSeries->setDbTag(lpData(9));
00612
00613
00614 this->clearAll();
00615
00616 if (theSeries != 0)
00617 if (theSeries->recvSelf(cTag, theChannel, theBroker) < 0) {
00618 g3ErrorHandler->warning("LoadPattern::recvSelf - the TimeSeries failed to recv");
00619 return -3;
00620 }
00621
00622 numNod = lpData(1);
00623 numEle = lpData(2);
00624 numSPs = lpData(3);
00625 dbNod = lpData(4);
00626 dbEle = lpData(5);
00627 dbSPs = lpData(6);
00628
00629
00630
00631
00632
00633
00634
00635 if (numNod != 0) {
00636 ID nodeData(2*numNod);
00637
00638
00639 if (theChannel.recvID(dbNod, cTag, nodeData) < 0) {
00640 g3ErrorHandler->warning("LoadPAttern::recvSelf - channel failed to recv the NodalLoad ID");
00641 return -2;
00642 }
00643
00644
00645
00646
00647
00648 int loc = 0;
00649
00650 for (int i=0; i<numNod; i++) {
00651 int classTag = nodeData(loc);
00652 int dbTag = nodeData(loc+1);
00653
00654 NodalLoad *theNode = theBroker.getNewNodalLoad(classTag);
00655
00656 if (theNode == 0) {
00657 g3ErrorHandler->warning("LoadPattern::recv - cannot create NodalLoad with classTag %d ",
00658 classTag);
00659 return -2;
00660 }
00661
00662 theNode->setDbTag(dbTag);
00663
00664 if (theNode->recvSelf(cTag, theChannel, theBroker) < 0) {
00665 g3ErrorHandler->warning("LoadPattern::recvSelf - NodalLoad with dbTag %d failed in recvSelf",
00666 dbTag);
00667 return -2;
00668 }
00669
00670 if (this->addNodalLoad(theNode) == false) {
00671 g3ErrorHandler->warning("LoadPattern::recvSelf - failed adding NodalLoad tagged %d into LP!",
00672 theNode->getTag());
00673 return -3;
00674 }
00675
00676 loc+=2;
00677 }
00678 }
00679
00680
00681
00682
00683
00684 if (numEle != 0) {
00685 ID eleData(2*numEle);
00686
00687 if (theChannel.recvID(dbEle, cTag, eleData) < 0) {
00688 g3ErrorHandler->warning("LoadPattern::recvSelf - channel failed to recv the EleLoad ID");
00689 return -2;
00690 }
00691
00692 int loc = 0;
00693 for (int i=0; i<numEle; i++) {
00694 int classTag = eleData(loc);
00695 int dbTag = eleData(loc+1);
00696
00697 ElementalLoad *theEle = theBroker.getNewElementalLoad(classTag);
00698 if (theEle == 0) {
00699 g3ErrorHandler->warning("LoadPattern::recv - cannot create ElementalLoad with classTag %d ",
00700 classTag);
00701 return -2;
00702 }
00703
00704 theEle->setDbTag(dbTag);
00705
00706 if (theEle->recvSelf(cTag, theChannel, theBroker) < 0) {
00707 g3ErrorHandler->warning("LoadPattern::recvSelf - Ele with dbTag %d failed in recvSelf",
00708 dbTag);
00709 return -2;
00710 }
00711
00712 if (this->addElementalLoad(theEle) == false) {
00713 g3ErrorHandler->warning("LoadPattern::recvSelf - could not add Ele with tag %d into LP!",
00714 theEle->getTag());
00715 return -3;
00716 }
00717
00718 loc+=2;
00719 }
00720 }
00721
00722
00723
00724
00725
00726 if (numSPs != 0) {
00727 ID spData(2*numSPs);
00728
00729 if (theChannel.recvID(dbSPs, cTag, spData) < 0) {
00730 g3ErrorHandler->warning("LoadPattern::recvSelf - channel failed to recv the SP_Constraints ID");
00731 return -2;
00732 }
00733
00734 int loc = 0;
00735 for (int i=0; i<numSPs; i++) {
00736 int classTag = spData(loc);
00737 int dbTag = spData(loc+1);
00738
00739 SP_Constraint *theSP = theBroker.getNewSP(classTag);
00740 if (theSP == 0) {
00741 g3ErrorHandler->warning("LoadPattern::recv - cannot create SP_Constraint with classTag %d ",
00742 classTag);
00743 return -2;
00744 }
00745 theSP->setDbTag(dbTag);
00746
00747 if (theSP->recvSelf(cTag, theChannel, theBroker) < 0) {
00748 g3ErrorHandler->warning("LoadPattern::recvSelf - SP_Constraint with dbTag %d failed in recvSelf",
00749 dbTag);
00750 return -2;
00751 }
00752
00753 if (this->addSP_Constraint(theSP) == false) {
00754 g3ErrorHandler->warning("LoadPattern::recvSelf - could not add SP_Constraint with tag %d into LP!",
00755 theSP->getTag());
00756 return -3;
00757 }
00758
00759 loc+=2;
00760 }
00761 }
00762
00763
00764 currentGeoTag = lpData(0);
00765 lastGeoSendTag = currentGeoTag;
00766
00767 } else {
00768 if (theSeries != 0)
00769 if (theSeries->recvSelf(cTag, theChannel, theBroker) < 0) {
00770 g3ErrorHandler->warning("LoadPattern::recvSelf - the TimeSeries failed to recv");
00771 return -3;
00772 }
00773
00774
00775 NodalLoad *theNode;
00776 NodalLoadIter &theNodes = this->getNodalLoads();
00777 while ((theNode = theNodes()) != 0) {
00778 if (theNode->recvSelf(cTag, theChannel, theBroker) < 0) {
00779 g3ErrorHandler->warning("LoadPattern::recvSelf - node with tag %d failed in recvSelf",
00780 theNode->getTag());
00781 return -7;
00782 }
00783 }
00784
00785 ElementalLoad *theEle;
00786 ElementalLoadIter &theElements = this->getElementalLoads();
00787 while ((theEle = theElements()) != 0) {
00788 if (theEle->recvSelf(cTag, theChannel, theBroker) < 0) {
00789 g3ErrorHandler->warning("LoadPattern::recvSelf - element with tag %d failed in recvSelf",
00790 theEle->getTag());
00791 return -8;
00792 }
00793 }
00794
00795 SP_Constraint *theSP;
00796 SP_ConstraintIter &theSPs = this->getSPs();
00797 while ((theSP = theSPs()) != 0) {
00798 if (theSP->recvSelf(cTag, theChannel, theBroker) < 0) {
00799 g3ErrorHandler->warning("LoadPattern::recvSelf - SP_Constraint tagged %d failed recvSelf",
00800 theSP->getTag());
00801 return -9;
00802 }
00803 }
00804 }
00805
00806
00807 return 0;
00808 }
00809
00810 void
00811 LoadPattern::Print(ostream &s, int flag)
00812 {
00813 s << "Load Pattern: " << this->getTag() << "\n";
00814 if (theSeries != 0)
00815 theSeries->Print(s,flag);
00816 cerr << " Nodal Loads: \n";
00817 theNodalLoads->Print(s,flag);
00818 cerr << "\n Elemental Loads: \n";
00819 theElementalLoads->Print(s, flag);
00820 cerr << "\n Single Point Constraints: \n";
00821 theSPs->Print(s, flag);
00822 }
00823
00824
00825 LoadPattern *
00826 LoadPattern::getCopy(void)
00827 {
00828 LoadPattern *theCopy = new LoadPattern(this->getTag());
00829 if (theCopy == 0) {
00830 g3ErrorHandler->fatal("LoadPattern::getCopy() - ran out of memory\n");
00831 return theCopy;
00832 }
00833 theCopy->loadFactor = loadFactor;
00834 theCopy->isConstant = isConstant;
00835 theCopy->theSeries = theSeries;
00836 return theCopy;
00837 }
00838
00839
00840 int
00841 LoadPattern::setParameter(char **argv, int argc, Information &info)
00842 {
00843
00844 if (strcmp(argv[0],"loadAtNode") == 0) {
00845
00846 int nodeNumber = atoi(argv[1]);
00847 NodalLoad *thePossibleNodalLoad;
00848 NodalLoad *theNodalLoad = 0;
00849 NodalLoadIter &theNodalIter = this->getNodalLoads();
00850
00851 while ((thePossibleNodalLoad = theNodalIter()) != 0) {
00852 if ( nodeNumber == thePossibleNodalLoad->getNodeTag() ) {
00853 theNodalLoad = thePossibleNodalLoad;
00854 }
00855 }
00856
00857 int ok = -1;
00858 ok = theNodalLoad->setParameter (&argv[2], argc, info);
00859
00860 if (ok > 0 )
00861 return ok*1000 + nodeNumber;
00862 else
00863 return -1;
00864 }
00865
00866
00867 else
00868 return -1;
00869 }
00870
00871 int
00872 LoadPattern::updateParameter(int parameterID, Information &info)
00873 {
00874 NodalLoad *thePossibleNodalLoad = 0;
00875 NodalLoad *theNodalLoad = 0;
00876 NodalLoadIter &theNodalIter = this->getNodalLoads();
00877
00878 switch (parameterID) {
00879 case 1: case -1:
00880 return -1;
00881 default:
00882 if (parameterID > 1000 && parameterID < 2000) {
00883 int nodeNumber = parameterID-1000;
00884 while ((thePossibleNodalLoad = theNodalIter()) != 0) {
00885 if ( nodeNumber == thePossibleNodalLoad->getNodeTag() ) {
00886 theNodalLoad = thePossibleNodalLoad;
00887 }
00888 }
00889 return theNodalLoad->updateParameter(1, info);
00890 }
00891 else if (parameterID > 2000 && parameterID < 3000) {
00892 int nodeNumber = parameterID-2000;
00893 while ((thePossibleNodalLoad = theNodalIter()) != 0) {
00894 if ( nodeNumber == thePossibleNodalLoad->getNodeTag() ) {
00895 theNodalLoad = thePossibleNodalLoad;
00896 }
00897 }
00898 return theNodalLoad->updateParameter(2, info);
00899 }
00900 else if (parameterID > 3000 && parameterID < 4000) {
00901 int nodeNumber = parameterID-3000;
00902 while ((thePossibleNodalLoad = theNodalIter()) != 0) {
00903 if ( nodeNumber == thePossibleNodalLoad->getNodeTag() ) {
00904 theNodalLoad = thePossibleNodalLoad;
00905 }
00906 }
00907 return theNodalLoad->updateParameter(3, info);
00908 }
00909 else
00910 return -1;
00911 }
00912 }