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

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