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

IncrementalIntegrator.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/03/29 05:23:32 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/analysis/integrator/IncrementalIntegrator.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/analysis/integrator/IncrementalIntegrator.C
00027 // 
00028 // Written: fmk 
00029 // Created: 11/96
00030 // Revision: A
00031 //
00032 // Description: This file contains the implementation of IncrementalIntegrator.
00033 //
00034 // What: "@(#) IncrementalIntegrator.C, revA"
00035 
00036 #include <IncrementalIntegrator.h>
00037 #include <FE_Element.h>
00038 #include <LinearSOE.h>
00039 #include <AnalysisModel.h>
00040 #include <Vector.h>
00041 #include <DOF_Group.h>
00042 #include <FE_EleIter.h>
00043 #include <DOF_GrpIter.h>
00044 
00045 IncrementalIntegrator::IncrementalIntegrator(int clasTag)
00046 :Integrator(clasTag),
00047  statusFlag(CURRENT_TANGENT),
00048  theSOE(0),theAnalysisModel(0)
00049 {
00050 
00051 }
00052 
00053 IncrementalIntegrator::~IncrementalIntegrator()
00054 {
00055 
00056 }
00057 
00058 void
00059 IncrementalIntegrator::setLinks(AnalysisModel &theModel, LinearSOE &theLinSOE)
00060 {
00061     theAnalysisModel = &theModel;
00062     theSOE = &theLinSOE;
00063 }
00064 
00065 
00066 int 
00067 IncrementalIntegrator::formTangent(int statFlag)
00068 {
00069     int result = 0;
00070     statusFlag = statFlag;
00071 
00072     if (theAnalysisModel == 0 || theSOE == 0) {
00073  cerr << "WARNING IncrementalIntegrator::formTangent() -";
00074  cerr << " no AnalysisModel or LinearSOE have been set\n";
00075  return -1;
00076     }
00077 
00078     // zero the A matrix of the linearSOE
00079     theSOE->zeroA();
00080     
00081     // the loops to form and add the tangents are broken into two for 
00082     // efficiency when performing parallel computations - CHANGE
00083 
00084     // loop through the FE_Elements adding their contributions to the tangent
00085     FE_Element *elePtr;
00086     FE_EleIter &theEles2 = theAnalysisModel->getFEs();    
00087     while((elePtr = theEles2()) != 0)     
00088  if (theSOE->addA(elePtr->getTangent(this),elePtr->getID()) < 0) {
00089      cerr << "WARNING IncrementalIntegrator::formTangent -";
00090      cerr << " failed in addA for ID " << elePtr->getID();     
00091      result = -3;
00092  }
00093 
00094     return result;
00095 }
00096 
00097 
00098 int 
00099 IncrementalIntegrator::formUnbalance(void)
00100 {
00101     if (theAnalysisModel == 0 || theSOE == 0) {
00102  cerr << "WARNING IncrementalIntegrator::formUnbalance -";
00103  cerr << " no AnalysisModel or LinearSOE has been set\n";
00104  return -1;
00105     }
00106     
00107     theSOE->zeroB();
00108     
00109     if (this->formElementResidual() < 0) {
00110  cerr << "WARNING IncrementalIntegrator::formUnbalance ";
00111  cerr << " - this->formElementResidual failed\n";
00112  return -1;
00113     }
00114     
00115     if (this->formNodalUnbalance() < 0) {
00116  cerr << "WARNING IncrementalIntegrator::formUnbalance ";
00117  cerr << " - this->formNodalUnbalance failed\n";
00118  return -2;
00119     }    
00120 
00121     return 0;
00122 }
00123     
00124 int
00125 IncrementalIntegrator::getLastResponse(Vector &result, const ID &id)
00126 {
00127   
00128     if (theSOE == 0) {
00129  cerr << "WARNING IncrementalIntegrator::getLastResponse() -";
00130  cerr << "no LineaerSOE object associated with this object\n"; 
00131  return -1;
00132     }
00133 
00134     int res = 0; 
00135     int size = theSOE->getNumEqn() -1;
00136     const Vector &X = theSOE->getX();
00137     for (int i=0; i<id.Size(); i++) {
00138  int loc = id(i);
00139  if (loc < 0 )
00140    result(i) = 0.0;
00141  else if (loc <= size) {
00142    result(i) = X(loc); 
00143  }
00144  else {
00145      cerr << "WARNING IncrementalIntegrator::getLastResponse() -";
00146      cerr << "location " << loc << "in ID ouside bounds ";
00147      cerr << size << "\n"; 
00148      res = -2;
00149  }
00150     }     
00151     return res;
00152 }
00153 
00154 int
00155 IncrementalIntegrator::initialize(void)
00156 {
00157   return 0;
00158 }
00159 
00160 int
00161 IncrementalIntegrator::commit(void) 
00162 {
00163     if (theAnalysisModel == 0) {
00164  cerr << "WARNING IncrementalIntegrator::commit() -";
00165  cerr << "no AnalysisModel object associated with this object\n"; 
00166  return -1;
00167     }    
00168 
00169     return theAnalysisModel->commitDomain();
00170 }   
00171 
00172 
00173 int
00174 IncrementalIntegrator::revertToLastStep(void) 
00175 {
00176   return 0;
00177 }   
00178 
00179 
00180 LinearSOE *
00181 IncrementalIntegrator::getLinearSOEPtr(void) const
00182 {
00183     return theSOE;
00184 }   
00185 
00186 AnalysisModel *
00187 IncrementalIntegrator::getAnalysisModelPtr(void) const
00188 {
00189     return theAnalysisModel;
00190 }
00191 
00192 int 
00193 IncrementalIntegrator::formNodalUnbalance(void)
00194 {
00195     // loop through the DOF_Groups and add the unbalance
00196     DOF_GrpIter &theDOFs = theAnalysisModel->getDOFs();
00197     DOF_Group *dofPtr;
00198     int res = 0;
00199     while ((dofPtr = theDOFs()) != 0) {
00200  if (theSOE->addB(dofPtr->getUnbalance(this),dofPtr->getID()) <0) {
00201      cerr << "WARNING IncrementalIntegrator::formNodalUnbalance -";
00202      cerr << " failed in addB for ID " << dofPtr->getID();
00203      res = -2;
00204  }
00205     }
00206  
00207     return res;
00208 }
00209 
00210 int 
00211 IncrementalIntegrator::formElementResidual(void)
00212 {
00213     // loop through the FE_Elements and add the residual
00214     FE_Element *elePtr;
00215 
00216     int res = 0;    
00217 
00218     FE_EleIter &theEles2 = theAnalysisModel->getFEs();    
00219     while((elePtr = theEles2()) != 0) {
00220  if (theSOE->addB(elePtr->getResidual(this),elePtr->getID()) <0) {
00221      cerr << "WARNING IncrementalIntegrator::formElementResidual -";
00222      cerr << " failed in addB for ID " << elePtr->getID();
00223      res = -2;
00224  }
00225     }
00226 
00227     return res;     
00228 }
00229 
Copyright Contact Us