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