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 #include <DOF_Group.h>
00037 #include <DOF_GrpIter.h>
00038 #include <FE_EleIter.h>
00039
00040 #include <DirectIntegrationAnalysis.h>
00041 #include <EquiSolnAlgo.h>
00042 #include <AnalysisModel.h>
00043 #include <LinearSOE.h>
00044 #include <DOF_Numberer.h>
00045 #include <ConstraintHandler.h>
00046 #include <ConvergenceTest.h>
00047 #include <TransientIntegrator.h>
00048 #include <Domain.h>
00049
00050 #include <FE_Element.h>
00051 #include <DOF_Group.h>
00052 #include <FE_EleIter.h>
00053 #include <DOF_GrpIter.h>
00054 #include <Matrix.h>
00055 #include <ID.h>
00056 #include <Graph.h>
00057
00058 #ifdef _RELIABILITY
00059 #include <SensitivityAlgorithm.h>
00060 #endif
00061
00062
00063
00064
00065
00066 DirectIntegrationAnalysis::DirectIntegrationAnalysis(Domain &the_Domain,
00067 ConstraintHandler &theHandler,
00068 DOF_Numberer &theNumberer,
00069 AnalysisModel &theModel,
00070 EquiSolnAlgo &theSolnAlgo,
00071 LinearSOE &theLinSOE,
00072 TransientIntegrator &theTransientIntegrator,
00073 ConvergenceTest *theConvergenceTest)
00074 :TransientAnalysis(the_Domain),
00075 theConstraintHandler(&theHandler),
00076 theDOF_Numberer(&theNumberer),
00077 theAnalysisModel(&theModel),
00078 theAlgorithm(&theSolnAlgo),
00079 theSOE(&theLinSOE),
00080 theIntegrator(&theTransientIntegrator),
00081 theTest(theConvergenceTest),
00082 domainStamp(0)
00083 {
00084
00085
00086 theAnalysisModel->setLinks(the_Domain, theHandler);
00087 theConstraintHandler->setLinks(the_Domain,theModel,theTransientIntegrator);
00088 theDOF_Numberer->setLinks(theModel);
00089 theIntegrator->setLinks(theModel,theLinSOE);
00090 theAlgorithm->setLinks(theModel,theTransientIntegrator,theLinSOE);
00091
00092 if (theTest != 0)
00093 theAlgorithm->setConvergenceTest(theTest);
00094 else
00095 theTest = theAlgorithm->getConvergenceTest();
00096
00097
00098 #ifdef _RELIABILITY
00099 theSensitivityAlgorithm = 0;
00100 #endif
00101
00102 }
00103
00104 DirectIntegrationAnalysis::~DirectIntegrationAnalysis()
00105 {
00106
00107
00108
00109 }
00110
00111 void
00112 DirectIntegrationAnalysis::clearAll(void)
00113 {
00114
00115 if (theAnalysisModel != 0)
00116 delete theAnalysisModel;
00117 if (theConstraintHandler != 0)
00118 delete theConstraintHandler;
00119 if (theDOF_Numberer != 0)
00120 delete theDOF_Numberer;
00121 if (theIntegrator != 0)
00122 delete theIntegrator;
00123 if (theAlgorithm != 0)
00124 delete theAlgorithm;
00125 if (theSOE != 0)
00126 delete theSOE;
00127 if (theTest != 0)
00128 delete theTest;
00129
00130
00131 #ifdef _RELIABILITY
00132 delete theSensitivityAlgorithm;
00133 #endif
00134
00135
00136 theAnalysisModel =0;
00137 theConstraintHandler =0;
00138 theDOF_Numberer =0;
00139 theIntegrator =0;
00140 theAlgorithm =0;
00141 theSOE =0;
00142 theTest =0;
00143 }
00144
00145 #include <NodeIter.h>
00146 #include <Node.h>
00147
00148 int
00149 DirectIntegrationAnalysis::initialize(void)
00150 {
00151 Domain *the_Domain = this->getDomainPtr();
00152
00153
00154 int stamp = the_Domain->hasDomainChanged();
00155 if (stamp != domainStamp) {
00156 domainStamp = stamp;
00157 if (this->domainChanged() < 0) {
00158 opserr << "DirectIntegrationAnalysis::initialize() - domainChanged() failed\n";
00159 return -1;
00160 }
00161 }
00162 if (theIntegrator->initialize() < 0) {
00163 opserr << "DirectIntegrationAnalysis::initialize() - integrator initialize() failed\n";
00164 return -2;
00165 } else
00166 theIntegrator->commit();
00167
00168 return 0;
00169 }
00170
00171 int
00172 DirectIntegrationAnalysis::analyze(int numSteps, double dT)
00173 {
00174
00175 int result = 0;
00176 Domain *the_Domain = this->getDomainPtr();
00177
00178 for (int i=0; i<numSteps; i++) {
00179 if (theAnalysisModel->newStepDomain(dT) < 0) {
00180 opserr << "DirectIntegrationAnalysis::analyze() - the AnalysisModel failed";
00181 opserr << " at time " << the_Domain->getCurrentTime() << endln;
00182 the_Domain->revertToLastCommit();
00183 return -2;
00184 }
00185
00186
00187 int stamp = the_Domain->hasDomainChanged();
00188 if (stamp != domainStamp) {
00189 domainStamp = stamp;
00190 if (this->domainChanged() < 0) {
00191 opserr << "DirectIntegrationAnalysis::analyze() - domainChanged() failed\n";
00192 return -1;
00193 }
00194 }
00195
00196 if (theIntegrator->newStep(dT) < 0) {
00197 opserr << "DirectIntegrationAnalysis::analyze() - the Integrator failed";
00198 opserr << " at time " << the_Domain->getCurrentTime() << endln;
00199 the_Domain->revertToLastCommit();
00200 return -2;
00201 }
00202
00203 result = theAlgorithm->solveCurrentStep();
00204 if (result < 0) {
00205 opserr << "DirectIntegrationAnalysis::analyze() - the Algorithm failed";
00206 opserr << " at time " << the_Domain->getCurrentTime() << endln;
00207 the_Domain->revertToLastCommit();
00208 theIntegrator->revertToLastStep();
00209 return -3;
00210 }
00211
00212
00213 #ifdef _RELIABILITY
00214 if (theSensitivityAlgorithm != 0) {
00215 result = theSensitivityAlgorithm->computeSensitivities();
00216 if (result < 0) {
00217 opserr << "StaticAnalysis::analyze() - the SensitivityAlgorithm failed";
00218 opserr << " at iteration: " << i << " with domain at load factor ";
00219 opserr << the_Domain->getCurrentTime() << endln;
00220 the_Domain->revertToLastCommit();
00221 theIntegrator->revertToLastStep();
00222 return -5;
00223 }
00224 }
00225 #endif
00226
00227
00228 result = theIntegrator->commit();
00229 if (result < 0) {
00230 opserr << "DirectIntegrationAnalysis::analyze() - ";
00231 opserr << "the Integrator failed to commit";
00232 opserr << " at time " << the_Domain->getCurrentTime() << endln;
00233 the_Domain->revertToLastCommit();
00234 theIntegrator->revertToLastStep();
00235 return -4;
00236 }
00237
00238
00239 }
00240 return result;
00241 }
00242
00243
00244 int
00245 DirectIntegrationAnalysis::domainChanged(void)
00246 {
00247 Domain *the_Domain = this->getDomainPtr();
00248 int stamp = the_Domain->hasDomainChanged();
00249 domainStamp = stamp;
00250
00251 theAnalysisModel->clearAll();
00252 theConstraintHandler->clearAll();
00253
00254
00255
00256
00257
00258 theConstraintHandler->handle();
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272 theDOF_Numberer->numberDOF();
00273
00274
00275 theConstraintHandler->doneNumberingDOF();
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292 theSOE->setSize(theAnalysisModel->getDOFGraph());
00293
00294
00295 theIntegrator->domainChanged();
00296 theAlgorithm->domainChanged();
00297
00298
00299 return 0;
00300 }
00301
00302
00303 #ifdef _RELIABILITY
00304 int
00305 DirectIntegrationAnalysis::setSensitivityAlgorithm(SensitivityAlgorithm *passedSensitivityAlgorithm)
00306 {
00307 int result = 0;
00308
00309
00310 if (theSensitivityAlgorithm != 0) {
00311 delete theSensitivityAlgorithm;
00312 }
00313
00314 theSensitivityAlgorithm = passedSensitivityAlgorithm;
00315
00316 return 0;
00317 }
00318 #endif
00319
00320
00321
00322 int
00323 DirectIntegrationAnalysis::setNumberer(DOF_Numberer &theNewNumberer)
00324 {
00325 int result = 0;
00326
00327
00328 if (theDOF_Numberer != 0)
00329 delete theDOF_Numberer;
00330
00331
00332 theDOF_Numberer = &theNewNumberer;
00333 theDOF_Numberer->setLinks(*theAnalysisModel);
00334
00335
00336 Domain *the_Domain = this->getDomainPtr();
00337 int stamp = the_Domain->hasDomainChanged();
00338 domainStamp = stamp;
00339 result = this->domainChanged();
00340 if (result < 0) {
00341 opserr << "StaticAnalysis::setNumberer() - setNumberer() failed";
00342 return -1;
00343 }
00344
00345 return 0;
00346 }
00347
00348
00349
00350 int
00351 DirectIntegrationAnalysis::setAlgorithm(EquiSolnAlgo &theNewAlgorithm)
00352 {
00353
00354 if (theAlgorithm != 0)
00355 delete theAlgorithm;
00356
00357
00358 theAlgorithm = &theNewAlgorithm;
00359 theAlgorithm->setLinks(*theAnalysisModel,*theIntegrator,*theSOE);
00360
00361
00362 Domain *the_Domain = this->getDomainPtr();
00363
00364 int stamp = the_Domain->hasDomainChanged();
00365 if (stamp != domainStamp) {
00366 domainStamp = stamp;
00367 if (this->domainChanged() < 0) {
00368 opserr << "DirectIntegrationAnalysis::setAlgorithm() - ";
00369 opserr << "domainChanged failed";
00370 return -1;
00371 }
00372 } else {
00373 if (theAlgorithm->domainChanged() < 0) {
00374 opserr << "DirectIntegrationAnalysis::setAlgorithm() - ";
00375 opserr << "algorithm::domainChanged() failed";
00376 return -2;
00377 }
00378 }
00379
00380 return 0;
00381 }
00382
00383
00384 int
00385 DirectIntegrationAnalysis::setIntegrator(TransientIntegrator &theNewIntegrator)
00386 {
00387
00388 Domain *the_Domain = this->getDomainPtr();
00389 theIntegrator = &theNewIntegrator;
00390 theIntegrator->setLinks(*theAnalysisModel,*theSOE);
00391 theConstraintHandler->setLinks(*the_Domain,*theAnalysisModel,*theIntegrator);
00392 theAlgorithm->setLinks(*theAnalysisModel,*theIntegrator,*theSOE);
00393
00394
00395 int stamp = the_Domain->hasDomainChanged();
00396 if (stamp != domainStamp) {
00397 domainStamp = stamp;
00398 if (this->domainChanged() < 0) {
00399 opserr << "DirectIntegrationAnalysis::setAlgorithm() - ";
00400 opserr << "domainChanged failed";
00401 return -1;
00402 }
00403 }
00404 else {
00405 if (theIntegrator->domainChanged() < 0) {
00406 opserr << "DirectIntegrationAnalysis::setAlgorithm() - ";
00407 opserr << "Integrator::domainChanged failed";
00408 return -1;
00409 }
00410 }
00411
00412 return 0;
00413 }
00414 int
00415 DirectIntegrationAnalysis::setLinearSOE(LinearSOE &theNewSOE)
00416 {
00417
00418 if (theSOE != 0)
00419 delete theSOE;
00420
00421
00422 theSOE = &theNewSOE;
00423 theIntegrator->setLinks(*theAnalysisModel,*theSOE);
00424 theAlgorithm->setLinks(*theAnalysisModel,*theIntegrator,*theSOE);
00425
00426
00427 Domain *the_Domain = this->getDomainPtr();
00428 int stamp = the_Domain->hasDomainChanged();
00429 if (stamp != domainStamp) {
00430 domainStamp = stamp;
00431 if (this->domainChanged() < 0) {
00432 opserr << "DirectIntegrationAnalysis::setAlgorithm() - ";
00433 opserr << "domainChanged failed";
00434 return -1;
00435 }
00436 } else {
00437 Graph &theGraph = theAnalysisModel->getDOFGraph();
00438 if (theSOE->setSize(theGraph) < 0) {
00439 opserr << "DirectIntegrationAnalysis::setAlgorithm() - ";
00440 opserr << "LinearSOE::setSize() failed";
00441 return -2;
00442 }
00443 }
00444
00445 return 0;
00446 }
00447
00448
00449 int
00450 DirectIntegrationAnalysis::setConvergenceTest(ConvergenceTest &theNewTest)
00451 {
00452
00453 if (theTest != 0)
00454 delete theTest;
00455
00456
00457 theTest = &theNewTest;
00458 theAlgorithm->setConvergenceTest(theTest);
00459
00460 return 0;
00461 }
00462
00463
00464 int
00465 DirectIntegrationAnalysis::checkDomainChange(void)
00466 {
00467 Domain *the_Domain = this->getDomainPtr();
00468
00469
00470 int stamp = the_Domain->hasDomainChanged();
00471 if (stamp != domainStamp) {
00472 domainStamp = stamp;
00473 if (this->domainChanged() < 0) {
00474 opserr << "DirectIntegrationAnalysis::initialize() - domainChanged() failed\n";
00475 return -1;
00476 }
00477 }
00478
00479 return 0;
00480 }
00481
00482
00483 EquiSolnAlgo *
00484 DirectIntegrationAnalysis::getAlgorithm(void)
00485 {
00486 return theAlgorithm;
00487 }
00488
00489
00490 TransientIntegrator *
00491 DirectIntegrationAnalysis::getIntegrator(void)
00492 {
00493 return theIntegrator;
00494 }
00495
00496 ConvergenceTest *
00497 DirectIntegrationAnalysis::getConvergenceTest(void)
00498 {
00499 return theTest;
00500 }
00501
00502
00503
00504