DirectIntegrationAnalysis.cpp

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 1999, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** ****************************************************************** */
00020                                                                         
00021 // $Revision: 1.8 $
00022 // $Date: 2005/11/29 23:36:47 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/analysis/analysis/DirectIntegrationAnalysis.cpp,v $
00024                                                                         
00025                                                                         
00026 // Written: fmk 
00027 // Created: 11/96
00028 // Revision: A
00029 //
00030 // Description: This file contains the implementation of the
00031 // DirectIntegrationAnalysis class.
00032 //
00033 // What: "@(#) DirectIntegrationAnalysis.C, revA"
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 // AddingSensitivity:BEGIN //////////////////////////////////
00058 #ifdef _RELIABILITY
00059 #include <SensitivityAlgorithm.h>
00060 #endif
00061 // AddingSensitivity:END ////////////////////////////////////
00062 
00063 // Constructor
00064 //    sets theModel and theSysOFEqn to 0 and the Algorithm to the one supplied
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   // first we set up the links needed by the elements in the 
00085   // aggregation
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 // AddingSensitivity:BEGIN ////////////////////////////////////
00098 #ifdef _RELIABILITY
00099         theSensitivityAlgorithm = 0;
00100 #endif
00101 // AddingSensitivity:END //////////////////////////////////////
00102 }    
00103 
00104 DirectIntegrationAnalysis::~DirectIntegrationAnalysis()
00105 {
00106   // we don't invoke the destructors in case user switching
00107   // from a static to a direct integration analysis 
00108   // clearAll() must be invoked if user wishes to invoke destructor
00109 }    
00110 
00111 void
00112 DirectIntegrationAnalysis::clearAll(void)
00113 {
00114   // invoke the destructor on all the objects in the aggregation
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 // AddingSensitivity:BEGIN ////////////////////////////////////
00131 #ifdef _RELIABILITY
00132         delete theSensitivityAlgorithm;
00133 #endif
00134 // AddingSensitivity:END //////////////////////////////////////
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     // check if domain has undergone change
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       // check if domain has undergone change
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 // AddingSensitivity:BEGIN ////////////////////////////////////
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       // AddingSensitivity:END //////////////////////////////////////
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       // opserr << "DirectIntegrationAnalysis - time: " << the_Domain->getCurrentTime() << endln;
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     // now we invoke handle() on the constraint handler which
00255     // causes the creation of FE_Element and DOF_Group objects
00256     // and their addition to the AnalysisModel.
00257 
00258     theConstraintHandler->handle();
00259     // we now invoke number() on the numberer which causes
00260     // equation numbers to be assigned to all the DOFs in the
00261     // AnalysisModel.
00262 
00263     // opserr << theAnalysisModel->getDOFGroupGraph();
00264 
00265     /*
00266     DOF_GrpIter &theDOFs = theAnalysisModel->getDOFs();
00267     DOF_Group *dofPtr;
00268     while ((dofPtr = theDOFs()) != 0) 
00269       opserr << dofPtr->getID();
00270     */
00271 
00272     theDOF_Numberer->numberDOF();
00273 
00274 
00275     theConstraintHandler->doneNumberingDOF();
00276 
00277     /*
00278     DOF_GrpIter &theDOFs1 = theAnalysisModel->getDOFs();
00279     while ((dofPtr = theDOFs1()) != 0) 
00280       opserr << dofPtr->getID();
00281 
00282 
00283     FE_EleIter &theEles = theAnalysisModel->getFEs();    
00284     FE_Element *elePtr;
00285     while((elePtr = theEles()) != 0)     
00286        opserr << elePtr->getID();
00287     */
00288 
00289     // we invoke setGraph() on the LinearSOE which
00290     // causes that object to determine its size
00291 
00292     theSOE->setSize(theAnalysisModel->getDOFGraph());
00293 
00294     // we invoke domainChange() on the integrator and algorithm
00295     theIntegrator->domainChanged();
00296     theAlgorithm->domainChanged();
00297 
00298 
00299     return 0;
00300 }    
00301 
00302 // AddingSensitivity:BEGIN //////////////////////////////
00303 #ifdef _RELIABILITY
00304 int 
00305 DirectIntegrationAnalysis::setSensitivityAlgorithm(SensitivityAlgorithm *passedSensitivityAlgorithm)
00306 {
00307     int result = 0;
00308 
00309     // invoke the destructor on the old one
00310     if (theSensitivityAlgorithm != 0) {
00311       delete theSensitivityAlgorithm;
00312     }
00313 
00314     theSensitivityAlgorithm = passedSensitivityAlgorithm;
00315     
00316     return 0;
00317 }
00318 #endif
00319 // AddingSensitivity:END ///////////////////////////////
00320 
00321 
00322 int 
00323 DirectIntegrationAnalysis::setNumberer(DOF_Numberer &theNewNumberer) 
00324 {
00325     int result = 0;
00326 
00327     // invoke the destructor on the old one
00328     if (theDOF_Numberer != 0)
00329         delete theDOF_Numberer;
00330 
00331     // first set the links needed by the Algorithm
00332     theDOF_Numberer = &theNewNumberer;
00333     theDOF_Numberer->setLinks(*theAnalysisModel);
00334 
00335     // invoke domainChanged() either indirectly or directly
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     // invoke the destructor on the old one
00354     if (theAlgorithm != 0)
00355         delete theAlgorithm;
00356 
00357     // first set the links needed by the Algorithm
00358     theAlgorithm = &theNewAlgorithm;
00359     theAlgorithm->setLinks(*theAnalysisModel,*theIntegrator,*theSOE);
00360 
00361     // invoke domainChanged() either indirectly or directly
00362     Domain *the_Domain = this->getDomainPtr();
00363     // check if domain has undergone change
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   // set the links needed by the other objects in the aggregation
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   // invoke domainChanged() either indirectly or directly
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   // invoke the destructor on the old one
00418   if (theSOE != 0)
00419     delete theSOE;
00420 
00421   // set the links needed by the other objects in the aggregation
00422   theSOE = &theNewSOE;
00423   theIntegrator->setLinks(*theAnalysisModel,*theSOE);
00424   theAlgorithm->setLinks(*theAnalysisModel,*theIntegrator,*theSOE);
00425 
00426   // set the size either indirectly or directly
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   // invoke the destructor on the old one
00453   if (theTest != 0)
00454     delete theTest;
00455   
00456   // set the links needed by the other objects in the aggregation
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   // check if domain has undergone change
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 

Generated on Mon Oct 23 15:04:57 2006 for OpenSees by doxygen 1.5.0