LoadPath.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.2 $
00022 // $Date: 2003/02/14 23:00:48 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/analysis/integrator/LoadPath.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/analysis/integrator/LoadPath.h
00027 // 
00028 // Written: fmk 
00029 // Created: 07/98
00030 // Revision: A
00031 //
00032 // Description: This file contains the class definition for LoadPath.
00033 // LoadPath is an algorithmic class for perfroming a static analysis
00034 // using a load control integration scheme.
00035 //
00036 // What: "@(#) LoadPath.h, revA"
00037 
00038 
00039 #include <LoadPath.h>
00040 #include <AnalysisModel.h>
00041 #include <Vector.h>
00042 #include <Channel.h>
00043 #include <ID.h>
00044 #include <stdlib.h>
00045 
00046 LoadPath::LoadPath(Vector &theLoadPath)
00047 :StaticIntegrator(INTEGRATOR_TAGS_LoadPath),
00048  loadPath(0), currentStep(0)
00049 {
00050     loadPath = new Vector(theLoadPath);
00051     if (loadPath == 0 || loadPath->Size() == 0) {
00052         opserr << "LoadPath::LoadPath() - ran out of memory\n";
00053         exit(-1);
00054     }
00055 }
00056 
00057 LoadPath::LoadPath()
00058 :StaticIntegrator(INTEGRATOR_TAGS_LoadPath),
00059  loadPath(0), currentStep(0)
00060 {
00061 
00062 }
00063 
00064 
00065 
00066 
00067 LoadPath::~LoadPath()
00068 {
00069     if (loadPath != 0)
00070         delete loadPath;
00071 }
00072 
00073 int 
00074 LoadPath::newStep(void)
00075 {
00076     AnalysisModel *theModel = this->getAnalysisModelPtr();    
00077     if (theModel == 0) {
00078         opserr << "LoadPath::newStep() - no associated AnalysisModel\n";
00079         return -1;
00080     }
00081     
00082     if (loadPath == 0) {
00083         opserr << "LoadPath::newStep() - no load path associated with object\n";
00084         return -2;
00085     }   
00086         
00087 
00088     double modelLambda = theModel->getCurrentDomainTime();
00089 
00090     double currentLambda;
00091     if (currentStep < loadPath->Size()) {
00092       
00093       if (currentStep > 0) {
00094         if (modelLambda == (*loadPath)(currentStep-1))
00095           currentLambda = (*loadPath)(currentStep);  
00096         else
00097           currentLambda = (*loadPath)(currentStep-1);  
00098       } else
00099           currentLambda = (*loadPath)(currentStep);  
00100     }      
00101     else {
00102         currentLambda = 0.0;
00103         opserr << "LoadPath::newStep() - reached end of specified load path";
00104         opserr << " - setting lambda = 0.0 \n";
00105     }
00106     
00107     currentStep++;
00108     theModel->applyLoadDomain(currentLambda);
00109     
00110     return 0;
00111 }
00112     
00113 int
00114 LoadPath::update(const Vector &deltaU)
00115 {
00116     AnalysisModel *myModel = this->getAnalysisModelPtr();
00117     if (myModel == 0) {
00118         opserr << "WARNING LoadPath::update() ";
00119         opserr << "No AnalysisModel has been set\n";
00120         return -1;
00121     }
00122 
00123     myModel->incrDisp(deltaU);    
00124     myModel->updateDomain();
00125     return 0;
00126 }
00127 
00128 
00129 int
00130 LoadPath::sendSelf(int cTag,
00131                    Channel &theChannel)
00132 {
00133   ID data(2);
00134   data(0) = loadPath->Size();
00135   data(1) = currentStep;  
00136   if (theChannel.sendID(this->getDbTag(), cTag, data) < 0) {
00137       opserr << "LoadPath::sendSelf() - failed to send the ID\n";
00138       return -1;
00139   }
00140   
00141   if (theChannel.sendVector(this->getDbTag(), cTag, *loadPath) < 0) {
00142       opserr << "LoadPath::sendSelf() - failed to send the Vector\n";
00143       return -1;
00144   }  
00145   
00146   return 0;
00147 }
00148 
00149 
00150 int
00151 LoadPath::recvSelf(int cTag,
00152                       Channel &theChannel, FEM_ObjectBroker &theBroker)
00153 {
00154   ID data(2);
00155   if (theChannel.recvID(this->getDbTag(), cTag, data) < 0) {
00156       opserr << "LoadPath::sendSelf() - failed to send the ID\n";
00157       return -1;
00158   }      
00159   int size = data(0);
00160   currentStep = data(1);
00161   
00162   loadPath = new Vector(size);
00163   if (loadPath == 0 || loadPath->Size() == 0) {
00164       opserr << "FATAL - LoadPath::recvSelf() - ran out of memory\n";
00165       exit(-1);
00166   }
00167 
00168   if (theChannel.recvVector(this->getDbTag(), cTag, *loadPath) < 0) {
00169       opserr << "LoadPath::sendSelf() - failed to send the Vector\n";
00170       return -1;
00171   }      
00172   
00173   return 0;
00174 }
00175 
00176 
00177 
00178 void
00179 LoadPath::Print(OPS_Stream &s, int flag)
00180 {
00181     AnalysisModel *theModel = this->getAnalysisModelPtr();
00182     if (theModel != 0) {
00183         double currentLambda = theModel->getCurrentDomainTime();
00184         s << "\t LoadPath - currentLambda: " << currentLambda << endln;
00185     } else 
00186         s << "\t LoadPath - no associated AnalysisModel\n";
00187     
00188 }
00189 

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