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.5 $
00022 // $Date: 2005/10/19 21:53:57 $
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 <LinearSOE.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     opserr << "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         opserr << "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     LinearSOE *theSOE = this->getLinearSOEPtr();
00099     if (myModel == 0 || theSOE == 0) {
00100         opserr << "WARNING LoadControl::update() ";
00101         opserr << "No AnalysisModel or LinearSOE has been set\n";
00102         return -1;
00103     }
00104 
00105     myModel->incrDisp(deltaU);    
00106     if (myModel->updateDomain() < 0) {
00107       opserr << "LoadControl::update - model failed to update for new dU\n";
00108       return -1;
00109     }
00110 
00111     // Set deltaU for the convergence test
00112     theSOE->setX(deltaU);
00113 
00114     numIncrLastStep++;
00115 
00116     return 0;
00117 }
00118 
00119 
00120 int
00121 LoadControl::setDeltaLambda(double newValue)
00122 {
00123   // we set the #incr at last step = #incr so get newValue incr
00124   numIncrLastStep = specNumIncrStep;
00125   deltaLambda = newValue;
00126   return 0;
00127 }
00128 
00129 
00130 int
00131 LoadControl::sendSelf(int cTag,
00132                       Channel &theChannel)
00133 {
00134   Vector data(5);
00135   data(0) = deltaLambda;
00136   data(1) = specNumIncrStep;
00137   data(2) = numIncrLastStep;
00138   data(3) = dLambdaMin;
00139   data(4) = dLambdaMax;
00140   if (theChannel.sendVector(this->getDbTag(), cTag, data) < 0) {
00141       opserr << "LoadControl::sendSelf() - failed to send the Vector\n";
00142       return -1;
00143   }
00144   return 0;
00145 }
00146 
00147 
00148 int
00149 LoadControl::recvSelf(int cTag,
00150                       Channel &theChannel, FEM_ObjectBroker &theBroker)
00151 {
00152   Vector data(5);
00153   if (theChannel.recvVector(this->getDbTag(), cTag, data) < 0) {
00154       opserr << "LoadControl::sendSelf() - failed to send the Vector\n";
00155       deltaLambda = 0;
00156       return -1;
00157   }      
00158   deltaLambda = data(0);
00159   specNumIncrStep = data(1);
00160   numIncrLastStep = data(2);
00161   dLambdaMin = data(3);
00162   dLambdaMax = data(4);
00163   return 0;
00164 }
00165 
00166 
00167 
00168 void
00169 LoadControl::Print(OPS_Stream &s, int flag)
00170 {
00171     AnalysisModel *theModel = this->getAnalysisModelPtr();
00172     if (theModel != 0) {
00173         double currentLambda = theModel->getCurrentDomainTime();
00174         s << "\t LoadControl - currentLambda: " << currentLambda;
00175         s << "  deltaLambda: " << deltaLambda << endln;
00176     } else 
00177         s << "\t LoadControl - no associated AnalysisModel\n";
00178     
00179 }
00180 

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