00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
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
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
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
00112 theSOE->setX(deltaU);
00113
00114 numIncrLastStep++;
00115
00116 return 0;
00117 }
00118
00119
00120 int
00121 LoadControl::setDeltaLambda(double newValue)
00122 {
00123
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