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