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 <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
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
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
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