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 <StaticAnalysis.h>
00037 #include <EquiSolnAlgo.h>
00038 #include <AnalysisModel.h>
00039 #include <LinearSOE.h>
00040 #include <DOF_Numberer.h>
00041 #include <ConstraintHandler.h>
00042 #include <StaticIntegrator.h>
00043 #include <Domain.h>
00044 #include <Timer.h>
00045
00046 #include <FE_Element.h>
00047 #include <DOF_Group.h>
00048 #include <FE_EleIter.h>
00049 #include <DOF_GrpIter.h>
00050 #include <Matrix.h>
00051 #include <ID.h>
00052 #include <Graph.h>
00053
00054
00055
00056
00057 StaticAnalysis::StaticAnalysis(Domain &the_Domain,
00058 ConstraintHandler &theHandler,
00059 DOF_Numberer &theNumberer,
00060 AnalysisModel &theModel,
00061 EquiSolnAlgo &theSolnAlgo,
00062 LinearSOE &theLinSOE,
00063 StaticIntegrator &theStaticIntegrator)
00064 :Analysis(the_Domain), theConstraintHandler(&theHandler),
00065 theDOF_Numberer(&theNumberer), theAnalysisModel(&theModel),
00066 theAlgorithm(&theSolnAlgo), theSOE(&theLinSOE),
00067 theIntegrator(&theStaticIntegrator),
00068 domainStamp(0)
00069 {
00070
00071
00072 theAnalysisModel->setLinks(the_Domain);
00073 theConstraintHandler->setLinks(the_Domain,theModel,theStaticIntegrator);
00074 theDOF_Numberer->setLinks(theModel);
00075
00076 theIntegrator->setLinks(theModel,theLinSOE);
00077 theAlgorithm->setLinks(theModel,theStaticIntegrator,theLinSOE);
00078 }
00079
00080
00081 StaticAnalysis::~StaticAnalysis()
00082 {
00083
00084 }
00085
00086 void
00087 StaticAnalysis::clearAll(void)
00088 {
00089
00090 delete theAnalysisModel;
00091 delete theConstraintHandler;
00092 delete theDOF_Numberer;
00093 delete theIntegrator;
00094 delete theAlgorithm;
00095 delete theSOE;
00096 }
00097
00098
00099 int
00100 StaticAnalysis::analyze(int numSteps)
00101 {
00102 int result = 0;
00103 Domain *the_Domain = this->getDomainPtr();
00104
00105 for (int i=0; i<numSteps; i++) {
00106
00107
00108
00109
00110 int stamp = the_Domain->hasDomainChanged();
00111 if (stamp != domainStamp) {
00112 domainStamp = stamp;
00113 result = this->domainChanged();
00114 if (result < 0) {
00115 cerr << "StaticAnalysis::analyze() - domainChanged failed";
00116 cerr << " at step " << i << " of " << numSteps << endl;
00117 return -1;
00118 }
00119 }
00120
00121 result = theIntegrator->newStep();
00122 if (result < 0) {
00123 cerr << "StaticAnalysis::analyze() - the Integrator failed";
00124 cerr << " at iteration: " << i << " with domain at load factor ";
00125 cerr << the_Domain->getCurrentTime() << endl;
00126 the_Domain->revertToLastCommit();
00127
00128 return -2;
00129 }
00130
00131 result = theAlgorithm->solveCurrentStep();
00132 if (result < 0) {
00133 cerr << "StaticAnalysis::analyze() - the Algorithm failed";
00134 cerr << " at iteration: " << i << " with domain at load factor ";
00135 cerr << the_Domain->getCurrentTime() << endl;
00136 the_Domain->revertToLastCommit();
00137 theIntegrator->revertToLastStep();
00138
00139 return -3;
00140 }
00141
00142 result = theIntegrator->commit();
00143 if (result < 0) {
00144 cerr << "StaticAnalysis::analyze() - ";
00145 cerr << "the Integrator failed to commit";
00146 cerr << " at iteration: " << i << " with domain at load factor ";
00147 cerr << the_Domain->getCurrentTime() << endl;
00148 the_Domain->revertToLastCommit();
00149 theIntegrator->revertToLastStep();
00150
00151 return -4;
00152 }
00153 }
00154
00155 return 0;
00156 }
00157
00158
00159 int
00160 StaticAnalysis::initialize(void)
00161 {
00162 Domain *the_Domain = this->getDomainPtr();
00163
00164
00165 int stamp = the_Domain->hasDomainChanged();
00166 if (stamp != domainStamp) {
00167 domainStamp = stamp;
00168 if (this->domainChanged() < 0) {
00169 cerr << "DirectIntegrationAnalysis::initialize() - domainChanged() failed\n";
00170 return -1;
00171 }
00172 }
00173 if (theIntegrator->initialize() < 0) {
00174 cerr << "DirectIntegrationAnalysis::initialize() - integrator initialize() failed\n";
00175 return -2;
00176 } else
00177 theIntegrator->commit();
00178
00179 return 0;
00180 }
00181
00182 int
00183 StaticAnalysis::domainChanged(void)
00184 {
00185 int result = 0;
00186
00187
00188
00189 theAnalysisModel->clearAll();
00190 theConstraintHandler->clearAll();
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201 result = theConstraintHandler->handle();
00202 if (result < 0) {
00203 cerr << "StaticAnalysis::handle() - ";
00204 cerr << "ConstraintHandler::handle() failed";
00205 return -1;
00206 }
00207
00208
00209
00210
00211
00212 result = theDOF_Numberer->numberDOF();
00213 if (result < 0) {
00214 cerr << "StaticAnalysis::handle() - ";
00215 cerr << "DOF_Numberer::numberDOF() failed";
00216 return -2;
00217 }
00218
00219
00220
00221
00222 Graph &theGraph = theAnalysisModel->getDOFGraph();
00223
00224 result = theSOE->setSize(theGraph);
00225 if (result < 0) {
00226 cerr << "StaticAnalysis::handle() - ";
00227 cerr << "LinearSOE::setSize() failed";
00228 return -3;
00229 }
00230
00231
00232
00233
00234 result = theIntegrator->domainChanged();
00235 if (result < 0) {
00236 cerr << "StaticAnalysis::setAlgorithm() - ";
00237 cerr << "Integrator::domainChanged() failed";
00238 return -4;
00239 }
00240
00241 result = theAlgorithm->domainChanged();
00242 if (result < 0) {
00243 cerr << "StaticAnalysis::setAlgorithm() - ";
00244 cerr << "Algorithm::domainChanged() failed";
00245 return -5;
00246 }
00247
00248
00249 return 0;
00250 }
00251
00252
00253 int
00254 StaticAnalysis::setAlgorithm(EquiSolnAlgo &theNewAlgorithm)
00255 {
00256 int result = 0;
00257
00258
00259 if (theAlgorithm != 0)
00260 delete theAlgorithm;
00261
00262
00263 theAlgorithm = &theNewAlgorithm;
00264 theAlgorithm->setLinks(*theAnalysisModel,*theIntegrator,*theSOE);
00265
00266
00267 Domain *the_Domain = this->getDomainPtr();
00268 int stamp = the_Domain->hasDomainChanged();
00269 if (stamp != domainStamp) {
00270 domainStamp = stamp;
00271 result = this->domainChanged();
00272 if (result < 0) {
00273 cerr << "StaticAnalysis::setAlgorithm() - domainChanged() failed";
00274 return -1;
00275 }
00276 }
00277 else {
00278 result = theAlgorithm->domainChanged();
00279 if (result < 0) {
00280 cerr << "StaticAnalysis::setAlgorithm() - ";
00281 cerr << "algorithm::domainChanged() failed";
00282 return -2;
00283 }
00284 }
00285 return 0;
00286 }
00287
00288 int
00289 StaticAnalysis::setIntegrator(StaticIntegrator &theNewIntegrator)
00290 {
00291 int result = 0;
00292
00293
00294
00295 if (theIntegrator != 0) {
00296 delete theIntegrator;
00297 }
00298
00299
00300 Domain *the_Domain = this->getDomainPtr();
00301
00302 theIntegrator = &theNewIntegrator;
00303 theIntegrator->setLinks(*theAnalysisModel,*theSOE);
00304 theConstraintHandler->setLinks(*the_Domain,*theAnalysisModel,*theIntegrator);
00305 theAlgorithm->setLinks(*theAnalysisModel,*theIntegrator,*theSOE);
00306
00307
00308 int stamp = the_Domain->hasDomainChanged();
00309 if (stamp != domainStamp) {
00310 domainStamp = stamp;
00311 result = this->domainChanged();
00312 if (result < 0) {
00313 cerr << "StaticAnalysis::setAlgorithm() - domainChanged() failed";
00314 return -1;
00315 }
00316 }
00317 else {
00318 result = theIntegrator->domainChanged();
00319 if (result < 0) {
00320 cerr << "StaticAnalysis::setAlgorithm() - ";
00321 cerr << "Integrator::domainChanged() failed";
00322 return -2;
00323 }
00324 }
00325
00326 return 0;
00327
00328 }
00329 int
00330 StaticAnalysis::setLinearSOE(LinearSOE &theNewSOE)
00331 {
00332 int result = 0;
00333
00334 if (theSOE != 0)
00335 delete theSOE;
00336
00337
00338 theSOE = &theNewSOE;
00339 theIntegrator->setLinks(*theAnalysisModel,*theSOE);
00340 theAlgorithm->setLinks(*theAnalysisModel,*theIntegrator,*theSOE);
00341
00342
00343 Domain *the_Domain = this->getDomainPtr();
00344 int stamp = the_Domain->hasDomainChanged();
00345 if (stamp != domainStamp) {
00346 domainStamp = stamp;
00347 result = this->domainChanged();
00348 if (result < 0) {
00349 cerr << "StaticAnalysis::setAlgorithm() - domainChanged failed";
00350 return -1;
00351 }
00352 }
00353 else {
00354 Graph &theGraph = theAnalysisModel->getDOFGraph();
00355 theSOE->setSize(theGraph);
00356 if (result < 0) {
00357 cerr << "StaticAnalysis::setAlgorithm() - ";
00358 cerr << "LinearSOE::setSize() failed\n";
00359 return -2;
00360 }
00361 }
00362 return 0;
00363 }
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377