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 #include <CentralDifferenceNoDamping.h>
00034 #include <FE_Element.h>
00035 #include <LinearSOE.h>
00036 #include <AnalysisModel.h>
00037 #include <Vector.h>
00038 #include <DOF_Group.h>
00039 #include <DOF_GrpIter.h>
00040 #include <AnalysisModel.h>
00041 #include <Channel.h>
00042 #include <FEM_ObjectBroker.h>
00043
00044 CentralDifferenceNoDamping::CentralDifferenceNoDamping()
00045 :TransientIntegrator(INTEGRATOR_TAGS_CentralDifferenceNoDamping),
00046 updateCount(0),
00047 U(0), Udot(0), Udotdot(0), deltaT(0)
00048 {
00049
00050 }
00051
00052 CentralDifferenceNoDamping::~CentralDifferenceNoDamping()
00053 {
00054
00055 if (U != 0)
00056 delete U;
00057 if (Udot != 0)
00058 delete Udot;
00059 if (Udotdot != 0)
00060 delete Udotdot;
00061 }
00062
00063 int
00064 CentralDifferenceNoDamping::newStep(double _deltaT)
00065 {
00066 updateCount = 0;
00067
00068 deltaT = _deltaT;
00069
00070 if (deltaT <= 0.0) {
00071 opserr << "CentralDifference::newStep() - error in variable\n";
00072 opserr << "dT = " << deltaT << endln;
00073 return -2;
00074 }
00075
00076 AnalysisModel *theModel = this->getAnalysisModelPtr();
00077 double time = theModel->getCurrentDomainTime();
00078 theModel->applyLoadDomain(time);
00079
00080 return 0;
00081 }
00082
00083 int
00084 CentralDifferenceNoDamping::formEleTangent(FE_Element *theEle)
00085 {
00086 theEle->zeroTangent();
00087 theEle->addMtoTang();
00088
00089 return 0;
00090 }
00091
00092 int
00093 CentralDifferenceNoDamping::formNodTangent(DOF_Group *theDof)
00094 {
00095 theDof->zeroTangent();
00096 theDof->addMtoTang();
00097 return(0);
00098 }
00099
00100 int
00101 CentralDifferenceNoDamping::formEleResidual(FE_Element *theEle)
00102 {
00103 theEle->zeroResidual();
00104 theEle->addRtoResidual();
00105 return 0;
00106 }
00107
00108 int
00109 CentralDifferenceNoDamping::formNodUnbalance(DOF_Group *theDof)
00110 {
00111 theDof->zeroUnbalance();
00112 theDof->addPtoUnbalance();
00113 return 0;
00114 }
00115
00116
00117 int
00118 CentralDifferenceNoDamping::domainChanged()
00119 {
00120 AnalysisModel *myModel = this->getAnalysisModelPtr();
00121 LinearSOE *theLinSOE = this->getLinearSOEPtr();
00122 const Vector &x = theLinSOE->getX();
00123 int size = x.Size();
00124
00125
00126 if (U == 0 || U->Size() != size) {
00127
00128
00129 if (U != 0)
00130 delete U;
00131 if (Udot != 0)
00132 delete Udot;
00133 if (Udotdot != 0)
00134 delete Udotdot;
00135
00136
00137 U = new Vector(size);
00138 Udot = new Vector(size);
00139 Udotdot = new Vector(size);
00140
00141
00142 if (U == 0 || U->Size() != size ||
00143 Udot == 0 || Udot->Size() != size ||
00144 Udotdot == 0 || Udotdot->Size() != size) {
00145
00146 opserr << "CentralDifferenceNoDamping::domainChanged - ran out of memory\n";
00147
00148
00149 if (U != 0)
00150 delete U;
00151 if (Udot != 0)
00152 delete U;
00153 if (Udotdot != 0)
00154 delete Udot;
00155
00156 U = 0; Udot = 0; Udotdot = 0;
00157 return -1;
00158 }
00159 }
00160
00161
00162
00163
00164 DOF_GrpIter &theDOFs = myModel->getDOFs();
00165 DOF_Group *dofPtr;
00166
00167 while ((dofPtr = theDOFs()) != 0) {
00168 const ID &id = dofPtr->getID();
00169 int idSize = id.Size();
00170 int i;
00171 const Vector &disp = dofPtr->getCommittedDisp();
00172 for (i=0; i < idSize; i++) {
00173 int loc = id(i);
00174 if (loc >= 0) {
00175 (*U)(loc) = disp(i);
00176 }
00177 }
00178
00179 const Vector &vel = dofPtr->getCommittedVel();
00180 for (i=0; i < idSize; i++) {
00181 int loc = id(i);
00182 if (loc >= 0) {
00183 (*Udot)(loc) = vel(i);
00184 }
00185 }
00186 }
00187
00188 return 0;
00189 }
00190
00191
00192 int
00193 CentralDifferenceNoDamping::update(const Vector &X)
00194 {
00195 updateCount++;
00196 if (updateCount > 1) {
00197 opserr << "ERROR CentralDifferenceNoDamping::update() - called more than once -";
00198 opserr << " Central Difference integraion schemes require a LINEAR solution algorithm\n";
00199 return -1;
00200 }
00201
00202 AnalysisModel *theModel = this->getAnalysisModelPtr();
00203
00204 if (theModel == 0) {
00205 opserr << "ERROR CentralDifferenceNoDamping::update() - no AnalysisModel set\n";
00206 return -2;
00207 }
00208
00209
00210 if (U == 0) {
00211 opserr << "WARNING CentralDifferenceNoDamping::update() - domainChange() failed or not called\n";
00212 return -2;
00213 }
00214
00215
00216 if (X.Size() != U->Size()) {
00217 opserr << "WARNING CentralDifferenceNoDamping::update() - Vectors of incompatable size ";
00218 opserr << " expecting " << U->Size() << " obtained " << X.Size() << endln;
00219 return -3;
00220 }
00221
00222
00223 (*Udotdot) = X;
00224
00225
00226 Udot->addVector(1.0, X, deltaT);
00227
00228
00229 U->addVector(1.0, *Udot, deltaT);
00230
00231
00232 theModel->setDisp(*U);
00233 theModel->updateDomain();
00234
00235 return 0;
00236 }
00237
00238 int
00239 CentralDifferenceNoDamping::commit(void)
00240 {
00241 AnalysisModel *theModel = this->getAnalysisModelPtr();
00242 if (theModel == 0) {
00243 opserr << "WARNING CentralDifferenceNoDamping::commit() - no AnalysisModel set\n";
00244 return -1;
00245 }
00246
00247
00248 double time = theModel->getCurrentDomainTime() + deltaT;
00249 theModel->setCurrentDomainTime(time);
00250
00251 return theModel->commitDomain();
00252
00253 return 0;
00254 }
00255
00256 int
00257 CentralDifferenceNoDamping::sendSelf(int cTag, Channel &theChannel)
00258 {
00259 return 0;
00260 }
00261
00262 int
00263 CentralDifferenceNoDamping::recvSelf(int cTag, Channel &theChannel, FEM_ObjectBroker &theBroker)
00264 {
00265 return 0;
00266 }
00267
00268 void
00269 CentralDifferenceNoDamping::Print(OPS_Stream &s, int flag)
00270 {
00271 AnalysisModel *theModel = this->getAnalysisModelPtr();
00272 if (theModel != 0) {
00273 double currentTime = theModel->getCurrentDomainTime();
00274 s << "\t CentralDifferenceNoDamping - currentTime: " << currentTime;
00275 } else
00276 s << "\t CentralDifferenceNoDamping - no associated AnalysisModel\n";
00277 }
00278