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 #include <ActorSubdomain.h>
00028 #include <FEM_ObjectBroker.h>
00029 #include <Element.h>
00030 #include <Node.h>
00031 #include <SP_Constraint.h>
00032 #include <MP_Constraint.h>
00033 #include <ElementalLoad.h>
00034 #include <NodalLoad.h>
00035 #include <LoadPattern.h>
00036 #include <Matrix.h>
00037 #include <Vector.h>
00038 #include <DomainDecompositionAnalysis.h>
00039 #include <PartitionedModelBuilder.h>
00040 #include <ConvergenceTest.h>
00041
00042 #include <EquiSolnAlgo.h>
00043 #include <IncrementalIntegrator.h>
00044 #include <LinearSOE.h>
00045 #include <LinearSOESolver.h>
00046 #include <Recorder.h>
00047
00048 #include <ArrayOfTaggedObjects.h>
00049 #include <ShadowActorSubdomain.h>
00050
00051 ActorSubdomain::ActorSubdomain(Channel &theChannel,
00052 FEM_ObjectBroker &theBroker)
00053 :Subdomain(0), Actor(theChannel,theBroker,0),
00054 msgData(4),lastResponse(0)
00055 {
00056
00057 }
00058
00059 ActorSubdomain::~ActorSubdomain()
00060 {
00061
00062 }
00063
00064
00065 int
00066 ActorSubdomain::run(void)
00067 {
00068 Vector theVect(4);
00069 bool exitYet = false;
00070
00071 while (exitYet == false) {
00072
00073 this->recvID(msgData);
00074 int action = msgData(0);
00075
00076 int theType, theOtherType, tag, dbTag, loadPatternTag;
00077 Element *theEle;
00078 Node *theNod;
00079 SP_Constraint *theSP;
00080 MP_Constraint *theMP;
00081 LoadPattern *theLoadPattern;
00082 NodalLoad *theNodalLoad;
00083 ElementalLoad *theElementalLoad;
00084 DomainDecompositionAnalysis *theDDAnalysis;
00085 const Matrix *theMatrix;
00086 const Vector *theVector;
00087 Matrix *theM;
00088 Vector *theV;
00089 PartitionedModelBuilder *theBuilder;
00090 IncrementalIntegrator *theIntegrator;
00091 EquiSolnAlgo *theAlgorithm;
00092 LinearSOE *theSOE;
00093 LinearSOESolver *theSolver;
00094 ConvergenceTest *theTest;
00095 Recorder *theRecorder;
00096 bool res;
00097 double doubleRes;
00098 int intRes;
00099
00100
00101 const ID *theID;
00102
00103 switch (action) {
00104
00105 case ShadowActorSubdomain_setTag:
00106 tag = msgData(1);
00107 this->setTag(tag);
00108 this->Actor::setCommitTag(tag);
00109
00110 break;
00111
00112 case ShadowActorSubdomain_newStep:
00113 this->recvVector(theVect);
00114 this->newStep(theVect(0));
00115
00116 break;
00117
00118 case ShadowActorSubdomain_buildSubdomain:
00119 theType = msgData(1);
00120 tag = msgData(3);
00121 this->setTag(tag);
00122 tag = msgData(2);
00123 theBuilder = theBroker->getPtrNewPartitionedModelBuilder(*this,
00124 theType);
00125 this->recvObject(*theBuilder);
00126 this->buildSubdomain(tag, *theBuilder);
00127
00128 break;
00129
00130 case ShadowActorSubdomain_getRemoteData:
00131 theID = &(this->getExternalNodes());
00132 msgData(0) = theID->Size();
00133 msgData(1) = this->getNumDOF();
00134
00135 this->sendID(msgData);
00136 if (theID->Size() != 0)
00137 this->sendID(*theID);
00138 break;
00139
00140 case ShadowActorSubdomain_getCost:
00141 theVect(0) = this->getCost();
00142 this->sendVector(theVect);
00143 break;
00144
00145 case ShadowActorSubdomain_addElement:
00146 theType = msgData(1);
00147 dbTag = msgData(2);
00148
00149 theEle = theBroker->getNewElement(theType);
00150
00151 if (theEle != 0) {
00152 theEle->setDbTag(dbTag);
00153 this->recvObject(*theEle);
00154 bool result = this->addElement(theEle);
00155 if (result == true)
00156 msgData(0) = 0;
00157 else
00158 msgData(0) = -1;
00159 } else
00160 msgData(0) = -1;
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173 break;
00174
00175
00176 case ShadowActorSubdomain_hasNode:
00177 theType = msgData(1);
00178 res = this->hasNode(theType);
00179 if (res == true)
00180 msgData(0) = 0;
00181 else
00182 msgData(0) = -1;
00183 this->sendID(msgData);
00184
00185 break;
00186
00187 case ShadowActorSubdomain_hasElement:
00188 theType = msgData(1);
00189 res = this->hasElement(theType);
00190 if (res == true)
00191 msgData(0) = 0;
00192 else
00193 msgData(0) = -1;
00194 this->sendID(msgData);
00195
00196 break;
00197
00198
00199 case ShadowActorSubdomain_addNode:
00200 theType = msgData(1);
00201 dbTag = msgData(2);
00202 theNod = theBroker->getNewNode(theType);
00203
00204 if (theNod != 0) {
00205 theNod->setDbTag(dbTag);
00206 this->recvObject(*theNod);
00207 bool result = this->addNode(theNod);
00208 if (result == true)
00209 msgData(0) = 0;
00210 else
00211 msgData(0) = -1;
00212 } else
00213 msgData(0) = -1;
00214
00215 break;
00216
00217
00218
00219
00220
00221 case ShadowActorSubdomain_addExternalNode:
00222 theType = msgData(1);
00223 dbTag = msgData(2);
00224 theNod = theBroker->getNewNode(theType);
00225
00226 if (theNod != 0) {
00227 theNod->setDbTag(dbTag);
00228 this->recvObject(*theNod);
00229 bool result = this->Subdomain::addExternalNode(theNod);
00230 delete theNod;
00231
00232
00233
00234
00235
00236
00237
00238 if (result == true)
00239 msgData(0) = 0;
00240 else
00241 msgData(0) = -1;
00242 } else
00243 msgData(0) = -1;
00244
00245 break;
00246
00247
00248 case ShadowActorSubdomain_addSP_Constraint:
00249 theType = msgData(1);
00250 dbTag = msgData(2);
00251
00252 theSP = theBroker->getNewSP(theType);
00253
00254 if (theSP != 0) {
00255 theSP->setDbTag(dbTag);
00256 this->recvObject(*theSP);
00257 bool result = this->addSP_Constraint(theSP);
00258 if (result == true)
00259 msgData(0) = 0;
00260 else
00261 msgData(0) = -1;
00262 } else
00263 msgData(0) = -1;
00264
00265 break;
00266
00267 case ShadowActorSubdomain_addMP_Constraint:
00268 theType = msgData(1);
00269 dbTag = msgData(2);
00270 theMP = theBroker->getNewMP(theType);
00271
00272 if (theMP != 0) {
00273 theMP->setDbTag(dbTag);
00274 this->recvObject(*theMP);
00275 bool result = this->addMP_Constraint(theMP);
00276 if (result == true)
00277 msgData(0) = 0;
00278 else
00279 msgData(0) = -1;
00280 } else
00281 msgData(0) = -1;
00282
00283 break;
00284
00285
00286 case ShadowActorSubdomain_addLoadPattern:
00287 theType = msgData(1);
00288 dbTag = msgData(2);
00289
00290 theLoadPattern = theBroker->getNewLoadPattern(theType);
00291
00292 if (theLoadPattern != 0) {
00293 theLoadPattern->setDbTag(dbTag);
00294 this->recvObject(*theLoadPattern);
00295 bool result = this->addLoadPattern(theLoadPattern);
00296 if (result == true)
00297 msgData(0) = 0;
00298 else
00299 msgData(0) = -1;
00300 } else
00301 msgData(0) = -1;
00302
00303 break;
00304
00305 case ShadowActorSubdomain_addNodalLoadToPattern:
00306 theType = msgData(1);
00307 dbTag = msgData(2);
00308 loadPatternTag = msgData(3);
00309
00310 theNodalLoad = theBroker->getNewNodalLoad(theType);
00311
00312 if (theNodalLoad != 0) {
00313 theNodalLoad->setDbTag(dbTag);
00314 this->recvObject(*theNodalLoad);
00315 bool result = this->addNodalLoad(theNodalLoad, loadPatternTag);
00316 if (result == true)
00317 msgData(0) = 0;
00318 else
00319 msgData(0) = -1;
00320 } else
00321 msgData(0) = -1;
00322
00323 break;
00324
00325
00326 case ShadowActorSubdomain_addElementalLoadToPattern:
00327 theType = msgData(1);
00328 dbTag = msgData(2);
00329 loadPatternTag = msgData(3);
00330
00331 theElementalLoad = theBroker->getNewElementalLoad(theType);
00332
00333 if (theElementalLoad != 0) {
00334 theElementalLoad->setDbTag(dbTag);
00335 this->recvObject(*theElementalLoad);
00336 bool result = this->addElementalLoad(theElementalLoad,
00337 loadPatternTag);
00338 if (result == true)
00339 msgData(0) = 0;
00340 else
00341 msgData(0) = -1;
00342 } else
00343 msgData(0) = -1;
00344
00345 break;
00346
00347 case ShadowActorSubdomain_addSP_ConstraintToPattern:
00348 theType = msgData(1);
00349 dbTag = msgData(2);
00350 loadPatternTag = msgData(3);
00351
00352 theSP = theBroker->getNewSP(theType);
00353
00354 if (theSP != 0) {
00355 theSP->setDbTag(dbTag);
00356 this->recvObject(*theSP);
00357 bool result = this->addSP_Constraint(theSP, loadPatternTag);
00358
00359 if (result == true)
00360 msgData(0) = 0;
00361 else
00362 msgData(0) = -1;
00363 } else
00364 msgData(0) = -1;
00365
00366 break;
00367
00368 case ShadowActorSubdomain_removeElement:
00369 tag = msgData(1);
00370
00371 theEle = this->removeElement(tag);
00372
00373 if (theEle != 0)
00374 msgData(0) = theEle->getClassTag();
00375 else
00376 msgData(0) = -1;
00377
00378 this->sendID(msgData);
00379 if (theEle != 0) {
00380 this->sendObject(*theEle);
00381 delete theEle;
00382 }
00383
00384 msgData(0) = 0;
00385
00386 break;
00387
00388
00389 case ShadowActorSubdomain_removeNode:
00390 tag = msgData(1);
00391
00392 theNod = this->removeNode(tag);
00393
00394 if (theNod != 0)
00395 msgData(0) = theNod->getClassTag();
00396 else
00397 msgData(0) = -1;
00398
00399 this->sendID(msgData);
00400 if (theNod != 0) {
00401 this->sendObject(*theNod);
00402 delete theNod;
00403 }
00404
00405 msgData(0) = 0;
00406
00407 break;
00408
00409 case ShadowActorSubdomain_removeSP_Constraint:
00410 tag = msgData(1);
00411
00412 theSP = this->removeSP_Constraint(tag);
00413
00414 break;
00415
00416 case ShadowActorSubdomain_removeMP_Constraint:
00417 tag = msgData(1);
00418
00419 theMP = this->removeMP_Constraint(tag);
00420
00421 break;
00422
00423 case ShadowActorSubdomain_removeLoadPattern:
00424 tag = msgData(1);
00425
00426 theLoadPattern = this->removeLoadPattern(tag);
00427
00428 break;
00429
00430 case ShadowActorSubdomain_removeNodalLoadFromPattern:
00431 tag = msgData(1);
00432 theType = msgData(2);
00433
00434 theNodalLoad = this->removeNodalLoad(tag, theType);
00435
00436 break;
00437
00438 case ShadowActorSubdomain_removeElementalLoadFromPattern:
00439 tag = msgData(1);
00440 theType = msgData(2);
00441
00442 theElementalLoad = this->removeElementalLoad(tag, theType);
00443
00444 break;
00445
00446 case ShadowActorSubdomain_removeSP_ConstraintFromPattern:
00447 tag = msgData(1);
00448 theType = msgData(2);
00449
00450 theSP = this->removeSP_Constraint(tag, theType);
00451
00452 break;
00453
00454
00455
00456 case ShadowActorSubdomain_getElement:
00457 tag = msgData(1);
00458
00459 theEle = this->getElement(tag);
00460
00461 if (theEle != 0)
00462 msgData(0) = theEle->getClassTag();
00463 else
00464 msgData(0) = -1;
00465
00466 this->sendID(msgData);
00467 if (theEle != 0) {
00468 this->sendObject(*theEle);
00469 }
00470
00471 msgData(0) = 0;
00472
00473 break;
00474
00475
00476 case ShadowActorSubdomain_Print:
00477 this->Print(opserr);
00478 this->sendID(msgData);
00479
00480 break;
00481
00482 case ShadowActorSubdomain_applyLoad:
00483 this->recvVector(theVect);
00484 this->applyLoad(theVect(0));
00485 break;
00486
00487 case ShadowActorSubdomain_setCommittedTime:
00488 this->recvVector(theVect);
00489 this->setCommittedTime(theVect(0));
00490 this->setCurrentTime(theVect(0));
00491 break;
00492
00493 case ShadowActorSubdomain_setLoadConstant:
00494 this->setLoadConstant();
00495 break;
00496
00497 case ShadowActorSubdomain_update:
00498 this->update();
00499 break;
00500
00501 case ShadowActorSubdomain_updateTimeDt:
00502 this->updateTimeDt();
00503 break;
00504
00505 case ShadowActorSubdomain_computeNodalResponse:
00506 tag = msgData(1);
00507 if (lastResponse == 0)
00508 lastResponse = new Vector(tag);
00509 else if (lastResponse->Size() != tag) {
00510 delete lastResponse;
00511 lastResponse = new Vector(tag);
00512 }
00513 this->recvVector(*lastResponse);
00514 this->computeNodalResponse();
00515
00516
00517
00518 case ShadowActorSubdomain_commit:
00519 this->commit();
00520 break;
00521
00522 case ShadowActorSubdomain_revertToLastCommit:
00523 this->revertToLastCommit();
00524 break;
00525
00526 case ShadowActorSubdomain_revertToStart:
00527 this->revertToStart();
00528 break;
00529
00530 case ShadowActorSubdomain_addRecorder:
00531 theType = msgData(1);
00532 theRecorder = theBroker->getPtrNewRecorder(theType);
00533 if (theRecorder != 0) {
00534 this->recvObject(*theRecorder);
00535 this->addRecorder(*theRecorder);
00536 }
00537 break;
00538
00539 case ShadowActorSubdomain_removeRecorders:
00540 this->removeRecorders();
00541 break;
00542
00543
00544 case ShadowActorSubdomain_wipeAnalysis:
00545 this->wipeAnalysis();
00546 break;
00547
00548 case ShadowActorSubdomain_setDomainDecompAnalysis:
00549 theType = msgData(1);
00550 theDDAnalysis =
00551 theBroker->getNewDomainDecompAnalysis(theType, *this);
00552
00553 if (theDDAnalysis != 0) {
00554 this->recvObject(*theDDAnalysis);
00555 this->setDomainDecompAnalysis(*theDDAnalysis);
00556 msgData(0) = 0;
00557 } else
00558 msgData(0) = -1;
00559
00560 break;
00561
00562 case ShadowActorSubdomain_setAnalysisAlgorithm:
00563 theType = msgData(1);
00564 theAlgorithm = theBroker->getNewEquiSolnAlgo(theType);
00565 if (theAlgorithm != 0) {
00566 this->recvObject(*theAlgorithm);
00567 this->setAnalysisAlgorithm(*theAlgorithm);
00568 msgData(0) = 0;
00569 } else
00570 msgData(0) = -1;
00571
00572 break;
00573
00574 case ShadowActorSubdomain_setAnalysisIntegrator:
00575 theType = msgData(1);
00576 theIntegrator = theBroker->getNewIncrementalIntegrator(theType);
00577 if (theIntegrator != 0) {
00578 this->recvObject(*theIntegrator);
00579 this->setAnalysisIntegrator(*theIntegrator);
00580 msgData(0) = 0;
00581 } else
00582 msgData(0) = -1;
00583
00584 break;
00585
00586 case ShadowActorSubdomain_setAnalysisLinearSOE:
00587 theType = msgData(1);
00588 theOtherType = msgData(2);
00589 theSOE = theBroker->getNewLinearSOE(theType, theOtherType);
00590
00591 if (theSOE != 0) {
00592 this->recvObject(*theSOE);
00593 theSolver = theSOE->getSolver();
00594 this->recvObject(*theSolver);
00595 this->setAnalysisLinearSOE(*theSOE);
00596 msgData(0) = 0;
00597 } else
00598 msgData(0) = -1;
00599
00600 break;
00601
00602 case ShadowActorSubdomain_setAnalysisConvergenceTest:
00603 theType = msgData(1);
00604 theTest = theBroker->getNewConvergenceTest(theType);
00605
00606 if (theTest != 0) {
00607 this->recvObject(*theTest);
00608 this->setAnalysisConvergenceTest(*theTest);
00609 msgData(0) = 0;
00610 } else
00611 msgData(0) = -1;
00612
00613 break;
00614
00615 case ShadowActorSubdomain_domainChange:
00616 this->domainChange();
00617
00618 tag = this->getNumDOF();
00619 if (lastResponse == 0)
00620 lastResponse = new Vector(tag);
00621 else if (lastResponse->Size() != tag) {
00622 delete lastResponse;
00623 lastResponse = new Vector(tag);
00624 }
00625
00626 break;
00627
00628 case ShadowActorSubdomain_clearAnalysis:
00629
00630 break;
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647 case ShadowActorSubdomain_getTang:
00648 theMatrix = &(this->getTang());
00649 this->sendMatrix(*theMatrix);
00650 break;
00651
00652 case ShadowActorSubdomain_getResistingForce:
00653 theVector = &(this->getResistingForce());
00654 this->sendVector(*theVector);
00655 break;
00656
00657 case ShadowActorSubdomain_computeTang:
00658 tag = msgData(1);
00659 this->setTag(tag);
00660 this->computeTang();
00661 break;
00662
00663
00664 case ShadowActorSubdomain_computeResidual:
00665 this->computeResidual();
00666 break;
00667
00668 case ShadowActorSubdomain_clearAll:
00669 this->clearAll();
00670 this->sendID(msgData);
00671 break;
00672
00673
00674 case ShadowActorSubdomain_getNodeDisp:
00675 tag = msgData(1);
00676 dbTag = msgData(2);
00677 doubleRes = this->getNodeDisp(tag, dbTag, intRes);
00678 msgData(0) = intRes;
00679 this->sendID(msgData);
00680 if (intRes == 0) {
00681 theV = new Vector(1);
00682 (*theV)(0) = doubleRes;
00683 this->sendVector(*theV);
00684 delete theV;
00685 }
00686 break;
00687
00688 case ShadowActorSubdomain_setMass:
00689 tag = msgData(1);
00690 dbTag = msgData(2);
00691 theOtherType = msgData(3);
00692 theM = new Matrix(dbTag, theOtherType);
00693 this->recvMatrix(*theM);
00694 intRes = this->setMass(*theM, tag);
00695
00696 delete theM;
00697 msgData(0) = intRes;
00698 this->sendID(msgData);
00699 break;
00700
00701 case ShadowActorSubdomain_setRayleighDampingFactors:
00702 theV = new Vector(4);
00703 this->recvVector(*theV);
00704 intRes = this->Subdomain::setRayleighDampingFactors((*theV)(0), (*theV)(1), (*theV)(2), (*theV)
00705 (3));
00706 delete theV;
00707 break;
00708
00709 case ShadowActorSubdomain_DIE:
00710 exitYet = true;
00711 break;
00712
00713 default:
00714 opserr << "ActorSubdomain::invalid action " << action << "received\n";
00715 msgData(0) = -1;
00716 }
00717 }
00718
00719 this->sendID(msgData);
00720 return 0;
00721 }
00722
00723
00724
00725 const Vector &
00726 ActorSubdomain::getLastExternalSysResponse(void)
00727 {
00728 int numDOF = this->getNumDOF();
00729 numDOF = this->getNumDOF();
00730
00731 if (lastResponse == 0)
00732 lastResponse = new Vector(numDOF);
00733 else if (lastResponse->Size() != numDOF) {
00734 delete lastResponse;
00735 lastResponse = new Vector(numDOF);
00736 }
00737
00738 if (mapBuilt == false)
00739 this->buildMap();
00740
00741 ID &theMap = *map;
00742 Vector &localResponse = *lastResponse;
00743 int numberDOF = this->getNumDOF();
00744 for (int i=0; i<numberDOF; i++)
00745 (*mappedVect)(theMap(i)) = localResponse(i);
00746
00747 return *mappedVect;
00748
00749 }
00750
00751 int
00752 ActorSubdomain::update(void)
00753 {
00754 int res = this->Domain::update();
00755
00756 this->barrierCheck(res);
00757
00758 return res;
00759 }
00760
00761 int
00762 ActorSubdomain::updateTimeDt(void)
00763 {
00764 static Vector data(2);
00765
00766 this->recvVector(data);
00767
00768 double newTime = data(0);
00769 double dT = data(1);
00770 int res = this->Domain::update(newTime, dT);
00771 return this->barrierCheck(res);
00772 }
00773
00774 int
00775 ActorSubdomain::barrierCheck(int myResult)
00776 {
00777 static ID data(1);
00778 data(0) = myResult;
00779 this->sendID(data);
00780 this->recvID(data);
00781
00782 return data(0);
00783 }
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793