Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

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.3 $
00022 // $Date: 2001/05/03 06:15:34 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/analysis/analysis/DirectIntegrationAnalysis.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/analysis/analysis/DirectIntegrationAnalysis.C
00027 // 
00028 // Written: fmk 
00029 // Created: 11/96
00030 // Revision: A
00031 //
00032 // Description: This file contains the implementation of the
00033 // DirectIntegrationAnalysis class.
00034 //
00035 // What: "@(#) DirectIntegrationAnalysis.C, revA"
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 // Constructor
00060 //    sets theModel and theSysOFEqn to 0 and the Algorithm to the one supplied
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     // first we set up the links needed by the elements in the 
00079     // aggregation
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     // invoke the destructor on all the objects in the aggregation
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     // check if domain has undergone change
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  // check if domain has undergone change
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  // cerr << "DirectIntegrationAnalysis - time: " << the_Domain->getCurrentTime() << endl;
00174  }    
00175     return result;
00176 }
00177 
00178 
00179 int
00180 DirectIntegrationAnalysis::domainChanged(void)
00181 {
00182    
00183     theAnalysisModel->clearAll();    
00184     theConstraintHandler->clearAll();
00185     
00186     // now we invoke handle() on the constraint handler which
00187     // causes the creation of FE_Element and DOF_Group objects
00188     // and their addition to the AnalysisModel.
00189 
00190     theConstraintHandler->handle();
00191     // we now invoke number() on the numberer which causes
00192     // equation numbers to be assigned to all the DOFs in the
00193     // AnalysisModel.
00194 
00195     // cerr << theAnalysisModel->getDOFGroupGraph();
00196 
00197     /*
00198     DOF_GrpIter &theDOFs = theAnalysisModel->getDOFs();
00199     DOF_Group *dofPtr;
00200     while ((dofPtr = theDOFs()) != 0) 
00201       cerr << dofPtr->getID();
00202     */
00203 
00204     theDOF_Numberer->numberDOF();
00205 
00206     // cerr << theAnalysisModel->getDOFGraph();
00207 
00208 
00209     /*
00210     DOF_GrpIter &theDOFs1 = theAnalysisModel->getDOFs();
00211     while ((dofPtr = theDOFs1()) != 0) 
00212       cerr << dofPtr->getID();
00213 
00214 
00215     FE_EleIter &theEles = theAnalysisModel->getFEs();    
00216     FE_Element *elePtr;
00217     while((elePtr = theEles()) != 0)     
00218        cerr << elePtr->getID();
00219     */
00220 
00221     // we invoke setGraph() on the LinearSOE which
00222     // causes that object to determine its size
00223 
00224     theSOE->setSize(theAnalysisModel->getDOFGraph());
00225 
00226     // we invoke domainChange() on the integrator and algorithm
00227     theIntegrator->domainChanged();
00228     theAlgorithm->domainChanged();
00229 
00230 
00231     return 0;
00232 }    
00233 
00234 
00235 
00236 int 
00237 DirectIntegrationAnalysis::setAlgorithm(EquiSolnAlgo &theNewAlgorithm) 
00238 {
00239     // invoke the destructor on the old one
00240     if (theAlgorithm != 0)
00241  delete theAlgorithm;
00242 
00243     // first set the links needed by the Algorithm
00244     theAlgorithm = &theNewAlgorithm;
00245     theAlgorithm->setLinks(*theAnalysisModel,*theIntegrator,*theSOE);
00246 
00247     // invoke domainChanged() either indirectly or directly
00248     Domain *the_Domain = this->getDomainPtr();
00249     // check if domain has undergone change
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   // set the links needed by the other objects in the aggregation
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   // invoke domainChanged() either indirectly or directly
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   // invoke the destructor on the old one
00304   if (theSOE != 0)
00305     delete theSOE;
00306 
00307   // set the links needed by the other objects in the aggregation
00308   theSOE = &theNewSOE;
00309   theIntegrator->setLinks(*theAnalysisModel,*theSOE);
00310   theAlgorithm->setLinks(*theAnalysisModel,*theIntegrator,*theSOE);
00311 
00312   // set the size either indirectly or directly
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   // check if domain has undergone change
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 
Copyright Contact Us