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 #include <TransientDomainDecompositionAnalysis.h>
00033 #include <EquiSolnAlgo.h>
00034 #include <AnalysisModel.h>
00035 #include <LinearSOE.h>
00036 #include <LinearSOESolver.h>
00037 #include <DOF_Numberer.h>
00038 #include <ConstraintHandler.h>
00039 #include <TransientIntegrator.h>
00040 #include <ConvergenceTest.h>
00041 #include <Subdomain.h>
00042 #include <Timer.h>
00043 #include <Channel.h>
00044 #include <FEM_ObjectBroker.h>
00045
00046
00047 #ifdef _RELIABILITY
00048 #include <SensitivityAlgorithm.h>
00049 #endif
00050
00051
00052
00053 #include <FE_Element.h>
00054 #include <DOF_Group.h>
00055 #include <FE_EleIter.h>
00056 #include <DOF_GrpIter.h>
00057 #include <Matrix.h>
00058 #include <ID.h>
00059 #include <Graph.h>
00060
00061 #include <Vector.h>
00062 #include <Matrix.h>
00063
00064 TransientDomainDecompositionAnalysis::TransientDomainDecompositionAnalysis(Subdomain &the_Domain)
00065 :DomainDecompositionAnalysis(ANALYSIS_TAGS_TransientDomainDecompositionAnalysis, the_Domain),
00066 theConstraintHandler(0),
00067 theDOF_Numberer(0),
00068 theAnalysisModel(0),
00069 theAlgorithm(0),
00070 theSOE(0),
00071 theIntegrator(0),
00072 theTest(0),
00073 domainStamp(0)
00074 {
00075
00076 }
00077
00078 TransientDomainDecompositionAnalysis::TransientDomainDecompositionAnalysis(Subdomain &the_Domain,
00079 ConstraintHandler &theHandler,
00080 DOF_Numberer &theNumberer,
00081 AnalysisModel &theModel,
00082 EquiSolnAlgo &theSolnAlgo,
00083 LinearSOE &theLinSOE,
00084 TransientIntegrator &theTransientIntegrator,
00085 ConvergenceTest *theConvergenceTest,
00086 bool setLinks)
00087 :DomainDecompositionAnalysis(ANALYSIS_TAGS_TransientDomainDecompositionAnalysis, the_Domain),
00088 theConstraintHandler(&theHandler),
00089 theDOF_Numberer(&theNumberer),
00090 theAnalysisModel(&theModel),
00091 theAlgorithm(&theSolnAlgo),
00092 theSOE(&theLinSOE),
00093 theIntegrator(&theTransientIntegrator),
00094 theTest(theConvergenceTest),
00095 domainStamp(0)
00096 {
00097
00098 if (setLinks == true) {
00099
00100 theAnalysisModel->setLinks(the_Domain, theHandler);
00101 theConstraintHandler->setLinks(the_Domain,theModel,theTransientIntegrator);
00102 theDOF_Numberer->setLinks(theModel);
00103 theIntegrator->setLinks(theModel,theLinSOE);
00104 theAlgorithm->setLinks(theModel,theTransientIntegrator,theLinSOE);
00105 theAlgorithm->setConvergenceTest(theTest);
00106 }
00107
00108 }
00109
00110
00111 TransientDomainDecompositionAnalysis::~TransientDomainDecompositionAnalysis()
00112 {
00113
00114
00115
00116 }
00117
00118 void
00119 TransientDomainDecompositionAnalysis::clearAll(void)
00120 {
00121
00122 if (theAnalysisModel != 0)
00123 delete theAnalysisModel;
00124 if (theConstraintHandler != 0)
00125 delete theConstraintHandler;
00126 if (theDOF_Numberer != 0)
00127 delete theDOF_Numberer;
00128 if (theIntegrator != 0)
00129 delete theIntegrator;
00130 if (theAlgorithm != 0)
00131 delete theAlgorithm;
00132 if (theSOE != 0)
00133 delete theSOE;
00134 if (theTest != 0)
00135 delete theTest;
00136
00137
00138 theAnalysisModel =0;
00139 theConstraintHandler =0;
00140 theDOF_Numberer =0;
00141 theIntegrator =0;
00142 theAlgorithm =0;
00143 theSOE =0;
00144 theTest = 0;
00145 }
00146
00147
00148 bool
00149 TransientDomainDecompositionAnalysis::doesIndependentAnalysis(void)
00150 {
00151 return true;
00152 }
00153
00154
00155 int
00156 TransientDomainDecompositionAnalysis::analyze(double dT)
00157 {
00158 int result = 0;
00159 Domain *the_Domain = this->getDomainPtr();
00160
00161
00162
00163
00164 int stamp = the_Domain->hasDomainChanged();
00165 if (stamp != domainStamp) {
00166 domainStamp = stamp;
00167 result = this->domainChanged();
00168 if (result < 0) {
00169 opserr << "TransientDomainDecompositionAnalysis::analyze() - domainChanged failed";
00170 return -1;
00171 }
00172 }
00173
00174
00175 if (result < 0) {
00176 opserr << "TransientDomainDecompositionAnalysis::analyze() - the AnalysisModel failed";
00177 opserr << " with domain at load factor ";
00178 opserr << the_Domain->getCurrentTime() << endln;
00179 the_Domain->revertToLastCommit();
00180
00181 return -2;
00182 }
00183
00184 result = theIntegrator->newStep(dT);
00185 if (result < 0) {
00186 opserr << "TransientDomainDecompositionAnalysis::analyze() - the Integrator failed";
00187 opserr << " with domain at load factor ";
00188 opserr << the_Domain->getCurrentTime() << endln;
00189 the_Domain->revertToLastCommit();
00190
00191 return -2;
00192 }
00193
00194 result = theAlgorithm->solveCurrentStep();
00195 if (result < 0) {
00196 opserr << "TransientDomainDecompositionAnalysis::analyze() - the Algorithm failed";
00197 opserr << " with domain at load factor ";
00198 opserr << the_Domain->getCurrentTime() << endln;
00199 the_Domain->revertToLastCommit();
00200 theIntegrator->revertToLastStep();
00201
00202 return -3;
00203 }
00204
00205 result = theIntegrator->commit();
00206 if (result < 0) {
00207 opserr << "TransientDomainDecompositionAnalysis::analyze() - ";
00208 opserr << "the Integrator failed to commit";
00209 opserr << " with domain at load factor ";
00210 opserr << the_Domain->getCurrentTime() << endln;
00211 the_Domain->revertToLastCommit();
00212 theIntegrator->revertToLastStep();
00213
00214 return -4;
00215 }
00216
00217 return 0;
00218 }
00219
00220
00221 int
00222 TransientDomainDecompositionAnalysis::initialize(void)
00223 {
00224 Domain *the_Domain = this->getDomainPtr();
00225
00226
00227 int stamp = the_Domain->hasDomainChanged();
00228 if (stamp != domainStamp) {
00229 domainStamp = stamp;
00230 if (this->domainChanged() < 0) {
00231 opserr << "DirectIntegrationAnalysis::initialize() - domainChanged() failed\n";
00232 return -1;
00233 }
00234 }
00235 if (theIntegrator->initialize() < 0) {
00236 opserr << "DirectIntegrationAnalysis::initialize() - integrator initialize() failed\n";
00237 return -2;
00238 } else
00239 theIntegrator->commit();
00240
00241 return 0;
00242 }
00243
00244 int
00245 TransientDomainDecompositionAnalysis::domainChanged(void)
00246 {
00247
00248 int result = 0;
00249
00250
00251 theAnalysisModel->clearAll();
00252 theConstraintHandler->clearAll();
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263 result = theConstraintHandler->handle();
00264 if (result < 0) {
00265 opserr << "TransientDomainDecompositionAnalysis::handle() - ";
00266 opserr << "ConstraintHandler::handle() failed";
00267 return -1;
00268 }
00269
00270
00271
00272
00273
00274 result = theDOF_Numberer->numberDOF();
00275 if (result < 0) {
00276 opserr << "TransientDomainDecompositionAnalysis::handle() - ";
00277 opserr << "DOF_Numberer::numberDOF() failed";
00278 return -2;
00279 }
00280
00281
00282
00283 Graph &theGraph = theAnalysisModel->getDOFGraph();
00284 result = theSOE->setSize(theGraph);
00285 if (result < 0) {
00286 opserr << "TransientDomainDecompositionAnalysis::handle() - ";
00287 opserr << "LinearSOE::setSize() failed";
00288 return -3;
00289 }
00290
00291
00292
00293
00294 result = theIntegrator->domainChanged();
00295 if (result < 0) {
00296 opserr << "TransientDomainDecompositionAnalysis::setAlgorithm() - ";
00297 opserr << "Integrator::domainChanged() failed";
00298 return -4;
00299 }
00300
00301 result = theAlgorithm->domainChanged();
00302 if (result < 0) {
00303 opserr << "TransientDomainDecompositionAnalysis::setAlgorithm() - ";
00304 opserr << "Algorithm::domainChanged() failed";
00305 return -5;
00306 }
00307
00308
00309 return 0;
00310 }
00311
00312
00313 int
00314 TransientDomainDecompositionAnalysis::getNumExternalEqn(void)
00315 {
00316 opserr << "TransientDomainDecompositionAnalysis::getNumExternalEqn() - should never be called\n";
00317 return 0;
00318 }
00319 int
00320 TransientDomainDecompositionAnalysis::getNumInternalEqn(void)
00321 {
00322 opserr << "TransientDomainDecompositionAnalysis::getNumInternalEqn() - should never be called\n";
00323 return 0;
00324 }
00325 int
00326 TransientDomainDecompositionAnalysis::newStep(double dT)
00327 {
00328 this->analyze(dT);
00329 return 0;
00330
00331 }
00332 int
00333 TransientDomainDecompositionAnalysis::computeInternalResponse(void)
00334 {
00335 opserr << "TransientDomainDecompositionAnalysis::computeInternalResponse() - should never be called\n";
00336 return 0;
00337 }
00338 int
00339 TransientDomainDecompositionAnalysis::formTangent(void)
00340 {
00341 opserr << "TransientDomainDecompositionAnalysis::formTangent() - should never be called\n";
00342 return 0;
00343 }
00344 int
00345 TransientDomainDecompositionAnalysis::formResidual(void)
00346 {
00347 opserr << "TransientDomainDecompositionAnalysis::formResidual() - should never be called\n";
00348 return 0;
00349 }
00350 int
00351 TransientDomainDecompositionAnalysis::formTangVectProduct(Vector &force)
00352 {
00353 opserr << "TransientDomainDecompositionAnalysis::formTangVectProduct() - should never be called\n";
00354 return 0;
00355 }
00356
00357 const Matrix &
00358 TransientDomainDecompositionAnalysis::getTangent(void)
00359 {
00360 static Matrix errMatrix;
00361 opserr << "TransientDomainDecompositionAnalysis::getTangent() - should never be called\n";
00362 return errMatrix;
00363 }
00364
00365 const Vector &
00366 TransientDomainDecompositionAnalysis::getResidual(void)
00367 {
00368 static Vector errVector;
00369 opserr << "TransientDomainDecompositionAnalysis::getResidual() - should never be called\n";
00370 return errVector;
00371 }
00372
00373 const Vector &
00374 TransientDomainDecompositionAnalysis::getTangVectProduct(void)
00375 {
00376 static Vector errVector;
00377 opserr << "TransientDomainDecompositionAnalysis::getTangVectProduct() - should never be called\n";
00378 return errVector;
00379 }
00380
00381 int
00382 TransientDomainDecompositionAnalysis::sendSelf(int commitTag, Channel &theChannel)
00383 {
00384
00385
00386 int dataTag = this->getDbTag();
00387 static ID data(8);
00388
00389 if (theAlgorithm == 0) {
00390 opserr << "TransientDomainDecompositionAnalysis::sendSelf() - no objects exist!\n";
00391 return -1;
00392 }
00393
00394 LinearSOESolver *theSolver = theSOE->getSolver();
00395
00396 data(0) = theConstraintHandler->getClassTag();
00397 data(1) = theDOF_Numberer->getClassTag();
00398 data(2) = theAnalysisModel->getClassTag();
00399 data(3) = theAlgorithm->getClassTag();
00400 data(4) = theSOE->getClassTag();
00401 data(5) = theSolver->getClassTag();
00402 data(6) = theIntegrator->getClassTag();
00403
00404 if (theTest != 0)
00405 data(7) = theTest->getClassTag();
00406 else
00407 data(7) = -1;
00408
00409 theChannel.sendID(dataTag, commitTag, data);
00410
00411
00412 if ( theConstraintHandler->sendSelf(commitTag, theChannel) != 0) {
00413 opserr << "TransientDomainDecompositionAnalysis::sendSelf() - failed to send handler\n";
00414 return -1;
00415 }
00416
00417 if ( theDOF_Numberer->sendSelf(commitTag, theChannel) != 0) {
00418 opserr << "TransientDomainDecompositionAnalysis::sendSelf() - failed to send numberer\n";
00419 return -1;
00420 }
00421
00422 if ( theAnalysisModel->sendSelf(commitTag, theChannel) != 0) {
00423 opserr << "TransientDomainDecompositionAnalysis::sendSelf() - failed to send model\n";
00424 return -1;
00425 }
00426
00427 if ( theAlgorithm->sendSelf(commitTag, theChannel) != 0) {
00428 opserr << "TransientDomainDecompositionAnalysis::sendSelf() - failed to send algorithm\n";
00429 return -1;
00430 }
00431
00432 if ( theSOE->sendSelf(commitTag, theChannel) != 0) {
00433 opserr << "TransientDomainDecompositionAnalysis::sendSelf() - failed to send SOE\n";
00434 return -1;
00435 } else
00436 ;
00437
00438
00439
00440 if ( theSolver->sendSelf(commitTag, theChannel) != 0) {
00441 opserr << "TransientDomainDecompositionAnalysis::sendSelf() - failed to send Solver\n";
00442 return -1;
00443 }
00444
00445 if ( theIntegrator->sendSelf(commitTag, theChannel) != 0) {
00446 opserr << "TransientDomainDecompositionAnalysis::sendSelf() - failed to send integrator\n";
00447 return -1;
00448 }
00449
00450 if (theTest != 0)
00451 if (theTest->sendSelf(commitTag, theChannel) != 0) {
00452 opserr << "TransientDomainDecompositionAnalysis::sendSelf() - failed to send integrator\n";
00453 return -1;
00454 }
00455
00456 return 0;
00457 }
00458 int
00459 TransientDomainDecompositionAnalysis::recvSelf(int commitTag, Channel &theChannel,
00460 FEM_ObjectBroker &theBroker)
00461 {
00462
00463 Domain *the_Domain = this->getSubdomainPtr();
00464
00465
00466 static ID data(8);
00467 int dataTag = this->getDbTag();
00468 theChannel.recvID(dataTag, commitTag, data);
00469
00470
00471
00472
00473 if (theConstraintHandler == 0 || theConstraintHandler->getClassTag() != data(0)) {
00474 if (theConstraintHandler != 0)
00475 delete theConstraintHandler;
00476
00477 theConstraintHandler = theBroker.getNewConstraintHandler(data(0));
00478 if (theConstraintHandler == 0) {
00479 opserr << "TransientDomainDecompositionAnalysis::recvSelf";
00480 opserr << " - failed to get the ConstraintHandler\n";
00481 return -1;
00482 }
00483 }
00484 theConstraintHandler->recvSelf(commitTag, theChannel,theBroker);
00485
00486 if (theDOF_Numberer == 0 || theDOF_Numberer->getClassTag() != data(1)) {
00487 if (theDOF_Numberer != 0)
00488 delete theDOF_Numberer;
00489
00490 theDOF_Numberer = theBroker.getNewNumberer(data(1));
00491 if (theDOF_Numberer == 0) {
00492 opserr << "TransientDomainDecompositionAnalysis::recvSelf";
00493 opserr << " - failed to get the ConstraintHandler\n";
00494 return -1;
00495 }
00496 }
00497 theDOF_Numberer->recvSelf(commitTag, theChannel,theBroker);
00498
00499 if (theAnalysisModel == 0 || theAnalysisModel->getClassTag() != data(2)) {
00500 if (theAnalysisModel != 0)
00501 delete theAnalysisModel;
00502
00503 theAnalysisModel = theBroker.getNewAnalysisModel(data(2));
00504 if (theAnalysisModel == 0) {
00505 opserr << "TransientDomainDecompositionAnalysis::recvSelf";
00506 opserr << " - failed to get the Analysis Model\n";
00507 return -1;
00508 }
00509 }
00510 theAnalysisModel->recvSelf(commitTag, theChannel,theBroker);
00511
00512 if (theAlgorithm == 0 || theAlgorithm->getClassTag() != data(3)) {
00513 if (theAlgorithm != 0)
00514 delete theAlgorithm;
00515
00516 theAlgorithm = theBroker.getNewEquiSolnAlgo(data(3));
00517 if (theAlgorithm == 0) {
00518 opserr << "TransientDomainDecompositionAnalysis::recvSelf";
00519 opserr << " - failed to get the Solution Algorithm\n";
00520 return -1;
00521 }
00522 }
00523 theAlgorithm->recvSelf(commitTag, theChannel,theBroker);
00524
00525 if (theSOE == 0 || theSOE->getClassTag() != data(4)) {
00526 if (theSOE != 0)
00527 delete theSOE;
00528
00529 theSOE = theBroker.getNewLinearSOE(data(4), data(5));
00530 if (theSOE == 0) {
00531 opserr << "TransientDomainDecompositionAnalysis::recvSelf";
00532 opserr << " - failed to get the LinearSOE\n";
00533 return -1;
00534 }
00535 }
00536
00537 theSOE->recvSelf(commitTag, theChannel, theBroker);
00538 LinearSOESolver *theSolver = theSOE->getSolver();
00539 theSolver->recvSelf(commitTag, theChannel, theBroker);
00540
00541
00542 if (theIntegrator == 0 || theIntegrator->getClassTag() != data(6)) {
00543 if (theIntegrator != 0)
00544 delete theIntegrator;
00545
00546 theIntegrator = theBroker.getNewTransientIntegrator(data(6));
00547 if (theIntegrator == 0) {
00548 opserr << "TransientDomainDecompositionAnalysis::recvSelf";
00549 opserr << " - failed to get the Integrator\n";
00550 return -1;
00551 }
00552 }
00553
00554 theIntegrator->recvSelf(commitTag, theChannel,theBroker);
00555
00556
00557 if (theTest == 0 || theTest->getClassTag() != data(7)) {
00558 if (theTest != 0)
00559 delete theIntegrator;
00560
00561 if (data(7) != -1) {
00562 theTest = theBroker.getNewConvergenceTest(data(7));
00563 if (theTest == 0) {
00564 opserr << "TransientDomainDecompositionAnalysis::recvSelf";
00565 opserr << " - failed to get the ConvergenceTest\n";
00566 return -1;
00567 }
00568 }
00569 }
00570 if (theTest != 0)
00571 theTest->recvSelf(commitTag, theChannel,theBroker);
00572
00573
00574 theAnalysisModel->setLinks(*the_Domain, *theConstraintHandler);
00575 theConstraintHandler->setLinks(*the_Domain, *theAnalysisModel, *theIntegrator);
00576 theDOF_Numberer->setLinks(*theAnalysisModel);
00577 theIntegrator->setLinks(*theAnalysisModel, *theSOE);
00578 theAlgorithm->setLinks(*theAnalysisModel, *theIntegrator, *theSOE);
00579 theAlgorithm->setConvergenceTest(theTest);
00580
00581 return 0;
00582 }
00583
00584 int
00585 TransientDomainDecompositionAnalysis::setAlgorithm(EquiSolnAlgo &theNewAlgorithm)
00586 {
00587
00588 if (theAlgorithm != 0)
00589 delete theAlgorithm;
00590
00591
00592 theAlgorithm = &theNewAlgorithm;
00593
00594 if (theAnalysisModel != 0 && theIntegrator != 0 && theSOE != 0)
00595 theAlgorithm->setLinks(*theAnalysisModel,*theIntegrator,*theSOE);
00596
00597 if (theTest != 0)
00598 theAlgorithm->setConvergenceTest(theTest);
00599
00600
00601 domainStamp = 0;
00602
00603 return 0;
00604 }
00605
00606 int
00607 TransientDomainDecompositionAnalysis::setIntegrator(IncrementalIntegrator &theNewIntegrator)
00608 {
00609
00610 if (theIntegrator != 0) {
00611 delete theIntegrator;
00612 }
00613
00614
00615 Domain *the_Domain = this->getDomainPtr();
00616
00617 theIntegrator = (TransientIntegrator *)(&theNewIntegrator);
00618
00619 if (theIntegrator != 0 && theConstraintHandler != 0 && theAlgorithm != 0 && theAnalysisModel != 0 && theSOE != 0) {
00620 theIntegrator->setLinks(*theAnalysisModel,*theSOE);
00621 theConstraintHandler->setLinks(*the_Domain,*theAnalysisModel,*theIntegrator);
00622 theAlgorithm->setLinks(*theAnalysisModel,*theIntegrator,*theSOE);
00623 }
00624
00625
00626 domainStamp = 0;
00627
00628 return 0;
00629 }
00630
00631
00632 int
00633 TransientDomainDecompositionAnalysis::setLinearSOE(LinearSOE &theNewSOE)
00634 {
00635
00636 if (theSOE != 0)
00637 delete theSOE;
00638
00639
00640 theSOE = &theNewSOE;
00641 if (theIntegrator != 0 && theAlgorithm != 0 && theAnalysisModel != 0 && theSOE != 0) {
00642 theIntegrator->setLinks(*theAnalysisModel,*theSOE);
00643 theAlgorithm->setLinks(*theAnalysisModel,*theIntegrator,*theSOE);
00644 }
00645
00646
00647 domainStamp = 0;
00648
00649 return 0;
00650 }
00651
00652 int
00653 TransientDomainDecompositionAnalysis::setConvergenceTest(ConvergenceTest &theConvergenceTest)
00654 {
00655
00656 if (theTest != 0) {
00657 delete theTest;
00658 }
00659 theTest = &theConvergenceTest;
00660
00661 if (theAlgorithm != 0)
00662 return theAlgorithm->setConvergenceTest(theTest);
00663
00664 return 0;
00665 }
00666