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