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

LoadControl.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.1.1.1 $
00022 // $Date: 2000/09/15 08:23:17 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/analysis/integrator/LoadControl.cpp,v $
00024                                                                         
00025                                                                         
00026 // 
00027 // Written: fmk 
00028 // Created: 07/98
00029 // Revision: A
00030 //
00031 // Description: This file contains the class definition for LoadControl.
00032 // LoadControl is an algorithmic class for perfroming a static analysis
00033 // using a load control integration scheme.
00034 //
00035 // What: "@(#) LoadControl.h, revA"
00036 
00037 
00038 
00039 #include <LoadControl.h>
00040 #include <AnalysisModel.h>
00041 #include <iostream.h>
00042 #include <Vector.h>
00043 #include <Channel.h>
00044 
00045 
00046 LoadControl::LoadControl(double dLambda, int numIncr, double min, double max)
00047 :StaticIntegrator(INTEGRATOR_TAGS_LoadControl),
00048  deltaLambda(dLambda), 
00049  specNumIncrStep(numIncr), numIncrLastStep(numIncr),
00050  dLambdaMin(min), dLambdaMax(max)
00051 {
00052   // to avoid divide-by-zero error on first update() ensure numIncr != 0
00053   if (numIncr == 0) {
00054     cerr << "WARNING LoadControl::LoadControl() - numIncr set to 0, 1 assumed\n";
00055     specNumIncrStep = 1.0;
00056     numIncrLastStep = 1.0;
00057   }
00058 }
00059 
00060 
00061 LoadControl::~LoadControl()
00062 {
00063     
00064 }
00065 
00066 int 
00067 LoadControl::newStep(void)
00068 {
00069     AnalysisModel *theModel = this->getAnalysisModelPtr();    
00070     if (theModel == 0) {
00071  cerr << "LoadControl::newStep() - no associated AnalysisModel\n";
00072  return -1;
00073     }
00074 
00075     // determine delta lambda for this step based on dLambda and #iter of last step
00076     double factor = specNumIncrStep/numIncrLastStep;
00077     deltaLambda *=factor;
00078 
00079     if (deltaLambda < dLambdaMin)
00080       deltaLambda = dLambdaMin;
00081     else if (deltaLambda > dLambdaMax)
00082       deltaLambda = dLambdaMax;
00083     
00084     double currentLambda = theModel->getCurrentDomainTime();
00085 
00086     currentLambda += deltaLambda;
00087     theModel->applyLoadDomain(currentLambda);
00088 
00089     numIncrLastStep = 0;
00090     
00091     return 0;
00092 }
00093     
00094 int
00095 LoadControl::update(const Vector &deltaU)
00096 {
00097     AnalysisModel *myModel = this->getAnalysisModelPtr();
00098     if (myModel == 0) {
00099  cerr << "WARNING LoadControl::update() ";
00100  cerr << "No AnalysisModel has been set\n";
00101  return -1;
00102     }
00103 
00104     myModel->incrDisp(deltaU);    
00105     myModel->updateDomain();
00106 
00107     numIncrLastStep++;
00108 
00109     return 0;
00110 }
00111 
00112 
00113 int
00114 LoadControl::setDeltaLambda(double newValue)
00115 {
00116   // we set the #incr at last step = #incr so get newValue incr
00117   numIncrLastStep = specNumIncrStep;
00118   deltaLambda = newValue;
00119   return 0;
00120 }
00121 
00122 
00123 int
00124 LoadControl::sendSelf(int cTag,
00125         Channel &theChannel)
00126 {
00127   Vector data(5);
00128   data(0) = deltaLambda;
00129   data(1) = specNumIncrStep;
00130   data(2) = numIncrLastStep;
00131   data(3) = dLambdaMin;
00132   data(4) = dLambdaMax;
00133   if (theChannel.sendVector(this->getDbTag(), cTag, data) < 0) {
00134       cerr << "LoadControl::sendSelf() - failed to send the Vector\n";
00135       return -1;
00136   }
00137   return 0;
00138 }
00139 
00140 
00141 int
00142 LoadControl::recvSelf(int cTag,
00143         Channel &theChannel, FEM_ObjectBroker &theBroker)
00144 {
00145   Vector data(5);
00146   if (theChannel.recvVector(this->getDbTag(), cTag, data) < 0) {
00147       cerr << "LoadControl::sendSelf() - failed to send the Vector\n";
00148       deltaLambda = 0;
00149       return -1;
00150   }      
00151   deltaLambda = data(0);
00152   specNumIncrStep = data(1);
00153   numIncrLastStep = data(2);
00154   dLambdaMin = data(3);
00155   dLambdaMax = data(4);
00156   return 0;
00157 }
00158 
00159 
00160 
00161 void
00162 LoadControl::Print(ostream &s, int flag)
00163 {
00164     AnalysisModel *theModel = this->getAnalysisModelPtr();
00165     if (theModel != 0) {
00166  double currentLambda = theModel->getCurrentDomainTime();
00167  s << "\t LoadControl - currentLambda: " << currentLambda;
00168  s << "  deltaLambda: " << deltaLambda << endl;
00169     } else 
00170  s << "\t LoadControl - no associated AnalysisModel\n";
00171     
00172 }
00173 
Copyright Contact Us