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

StaticAnalysis.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/StaticAnalysis.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/analysis/analysis/StaticAnalysis.C
00027 // 
00028 // Written: fmk 
00029 // Created: 11/96
00030 // Revision: A
00031 //
00032 // Description: This file contains the implementation of StaticAnalysis.
00033 //
00034 // What: "@(#) StaticAnalysis.C, revA"
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 // Constructor
00055 //    sets theModel and theSysOFEqn to 0 and the Algorithm to the one supplied
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     // first we set up the links needed by the elements in the 
00071     // aggregation
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     // invoke the destructor on all the objects in the aggregation
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  // check for change in Domain since last step. As a change can
00108  // occur in a commit() in a domaindecomp with load balancing
00109  // this must now be inside the loop
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     // check if domain has undergone change
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     // Timer theTimer; theTimer.start();
00188 
00189     theAnalysisModel->clearAll();    
00190     theConstraintHandler->clearAll();
00191 
00192      // theTimer.pause(); 
00193     // cout <<  "StaticAnalysis::clearAll() " << theTimer.getReal();
00194     // cout << theTimer.getCPU() << endl;
00195     // theTimer.start();    
00196 
00197     // now we invoke handle() on the constraint handler which
00198     // causes the creation of FE_Element and DOF_Group objects
00199     // and their addition to the AnalysisModel.
00200     
00201     result = theConstraintHandler->handle();
00202     if (result < 0) {
00203  cerr << "StaticAnalysis::handle() - ";
00204  cerr << "ConstraintHandler::handle() failed";
00205  return -1;
00206     } 
00207     
00208     // we now invoke number() on the numberer which causes
00209     // equation numbers to be assigned to all the DOFs in the
00210     // AnalysisModel.
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     // we invoke setSize() on the LinearSOE which
00220     // causes that object to determine its size
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     // finally we invoke domainChanged on the Integrator and Algorithm
00232     // objects .. informing them that the model has changed
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     // if get here successfull
00249     return 0;
00250 }    
00251 
00252 
00253 int 
00254 StaticAnalysis::setAlgorithm(EquiSolnAlgo &theNewAlgorithm) 
00255 {
00256     int result = 0;
00257 
00258     // invoke the destructor on the old one
00259     if (theAlgorithm != 0)
00260  delete theAlgorithm;
00261 
00262     // first set the links needed by the Algorithm
00263     theAlgorithm = &theNewAlgorithm;
00264     theAlgorithm->setLinks(*theAnalysisModel,*theIntegrator,*theSOE);
00265 
00266     // invoke domainChanged() either indirectly or directly
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     // invoke the destructor on the old one
00294     
00295     if (theIntegrator != 0) {
00296  delete theIntegrator;
00297     }
00298 
00299     // set the links needed by the other objects in the aggregation
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     // invoke domainChanged() either indirectly or directly
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     // invoke the destructor on the old one
00334     if (theSOE != 0)
00335  delete theSOE;
00336 
00337     // set the links needed by the other objects in the aggregation
00338     theSOE = &theNewSOE;
00339     theIntegrator->setLinks(*theAnalysisModel,*theSOE);
00340     theAlgorithm->setLinks(*theAnalysisModel,*theIntegrator,*theSOE);
00341 
00342     // set the size either indirectly or directly
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 
Copyright Contact Us