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 #include <GroundMotionRecord.h>
00038 #include <PathSeries.h>
00039 #include <PathTimeSeries.h>
00040 #include <stdlib.h>
00041 #include <math.h>
00042 #include <classTags.h>
00043 #include <Vector.h>
00044 #include <ID.h>
00045 #include <Channel.h>
00046 #include <FEM_ObjectBroker.h>
00047
00048 GroundMotionRecord::GroundMotionRecord()
00049 :GroundMotion(GROUND_MOTION_TAG_GroundMotionRecord),
00050 theAccelTimeSeries(0), theVelTimeSeries(0), theDispTimeSeries(0),
00051 data(3), delta(0.0)
00052 {
00053
00054 }
00055
00056 GroundMotionRecord::GroundMotionRecord(const char *fileNameAccel,
00057 double timeStep,
00058 double theFactor,
00059 double dT)
00060 :GroundMotion(GROUND_MOTION_TAG_GroundMotionRecord),
00061 theAccelTimeSeries(0), theVelTimeSeries(0), theDispTimeSeries(0),
00062 data(3), delta(dT)
00063 {
00064
00065 theAccelTimeSeries = new PathSeries(fileNameAccel, timeStep, theFactor);
00066
00067 if (theAccelTimeSeries == 0) {
00068 opserr << "GroundMotionRecord::GroundMotionRecord() - unable to create PathSeries\n";
00069 }
00070
00071 }
00072
00073 GroundMotionRecord::GroundMotionRecord(const char *fileNameAccel,
00074 const char *fileNameTime,
00075 double theFactor,
00076 double dT)
00077 :GroundMotion(GROUND_MOTION_TAG_GroundMotionRecord),
00078 theAccelTimeSeries(0), theVelTimeSeries(0), theDispTimeSeries(0),
00079 data(3), delta(dT)
00080 {
00081
00082 theAccelTimeSeries = new PathTimeSeries(fileNameAccel, fileNameTime, theFactor);
00083
00084 if (theAccelTimeSeries == 0) {
00085 opserr << "GroundMotionRecord::GroundMotionRecord() - unable to create PathSeries\n";
00086 }
00087 }
00088
00089 GroundMotionRecord::~GroundMotionRecord()
00090 {
00091 if (theAccelTimeSeries != 0)
00092 delete theAccelTimeSeries;
00093 if (theVelTimeSeries != 0)
00094 delete theVelTimeSeries;
00095 if (theDispTimeSeries != 0)
00096 delete theDispTimeSeries;
00097 }
00098
00099 double
00100 GroundMotionRecord::getDuration(void)
00101 {
00102 if (theAccelTimeSeries != 0)
00103 return theAccelTimeSeries->getDuration();
00104 else
00105 return 0.0;
00106 }
00107
00108 double
00109 GroundMotionRecord::getPeakAccel(void)
00110 {
00111 if (theAccelTimeSeries != 0)
00112 return theAccelTimeSeries->getPeakFactor();
00113 else
00114 return 0.0;
00115
00116 }
00117
00118 double
00119 GroundMotionRecord::getPeakVel(void)
00120 {
00121 if (theVelTimeSeries != 0)
00122 return theVelTimeSeries->getPeakFactor();
00123
00124
00125 else if (theAccelTimeSeries != 0) {
00126 theVelTimeSeries = this->integrate(theAccelTimeSeries, delta);
00127 if (theVelTimeSeries != 0)
00128 return theVelTimeSeries->getPeakFactor();
00129 else
00130 return 0.0;
00131 }
00132 return 0.0;
00133 }
00134
00135 double
00136 GroundMotionRecord::getPeakDisp(void)
00137 {
00138 if (theDispTimeSeries != 0)
00139 return theDispTimeSeries->getPeakFactor();
00140
00141
00142 else if (theVelTimeSeries != 0) {
00143 theDispTimeSeries = this->integrate(theVelTimeSeries, delta);
00144 if (theDispTimeSeries != 0)
00145 return theDispTimeSeries->getPeakFactor();
00146 else
00147 return 0.0;
00148 }
00149
00150
00151 else if (theAccelTimeSeries != 0) {
00152 theVelTimeSeries = this->integrate(theAccelTimeSeries, delta);
00153 if (theVelTimeSeries != 0) {
00154 theDispTimeSeries = this->integrate(theVelTimeSeries, delta);
00155 if (theDispTimeSeries != 0)
00156 return theDispTimeSeries->getPeakFactor();
00157 else
00158 return 0.0;
00159 } else
00160 return 0.0;
00161 }
00162
00163 return 0.0;
00164 }
00165
00166 double
00167 GroundMotionRecord::getAccel(double time)
00168 {
00169 if (time < 0.0)
00170 return 0.0;
00171
00172 if (theAccelTimeSeries != 0)
00173 return theAccelTimeSeries->getFactor(time);
00174 else
00175 return 0.0;
00176 }
00177
00178 double
00179 GroundMotionRecord::getVel(double time)
00180 {
00181 if (time < 0.0)
00182 return 0.0;
00183
00184 if (theVelTimeSeries != 0)
00185 return theVelTimeSeries->getFactor(time);
00186
00187
00188 else if (theAccelTimeSeries != 0) {
00189 theVelTimeSeries = this->integrate(theAccelTimeSeries, delta);
00190 if (theVelTimeSeries != 0)
00191 return theVelTimeSeries->getFactor(time);
00192 else
00193 return 0.0;
00194 }
00195
00196 return 0.0;
00197 }
00198
00199 double
00200 GroundMotionRecord::getDisp(double time)
00201 {
00202 if (time < 0.0)
00203 return 0.0;
00204
00205 if (theDispTimeSeries != 0)
00206 return theDispTimeSeries->getFactor(time);
00207
00208
00209 else if (theVelTimeSeries != 0) {
00210 theDispTimeSeries = this->integrate(theVelTimeSeries, delta);
00211 if (theDispTimeSeries != 0)
00212 return theDispTimeSeries->getFactor(time);
00213 else
00214 return 0.0;
00215 }
00216
00217
00218 else if (theAccelTimeSeries != 0) {
00219 theVelTimeSeries = this->integrate(theAccelTimeSeries, delta);
00220 if (theVelTimeSeries != 0) {
00221 theDispTimeSeries = this->integrate(theVelTimeSeries, delta);
00222 if (theDispTimeSeries != 0)
00223 return theDispTimeSeries->getFactor(time);
00224 else
00225 return 0.0;
00226 } else
00227 return 0.0;
00228 }
00229
00230 return 0.0;
00231 }
00232
00233 const Vector &
00234 GroundMotionRecord::getDispVelAccel(double time)
00235 {
00236 if (time < 0.0) {
00237 data(0) = 0.0;
00238 data(1) = 0.0;
00239 data(2) = 0.0;
00240 return data;
00241 }
00242
00243 if (theAccelTimeSeries != 0 && theVelTimeSeries != 0 && theDispTimeSeries != 0) {
00244 data(0) = theDispTimeSeries->getFactor(time);
00245 data(1) = theVelTimeSeries->getFactor(time);
00246 data(2) = theAccelTimeSeries->getFactor(time);
00247 } else {
00248 data(2) = this->getAccel(time);
00249 data(1) = this->getVel(time);
00250 data(0) = this->getDisp(time);
00251 }
00252
00253 return data;
00254 }
00255
00256
00257 int
00258 GroundMotionRecord::sendSelf(int commitTag, Channel &theChannel)
00259 {
00260 int dbTag = this->getDbTag();
00261
00262 static ID idData(6);
00263
00264 if (theAccelTimeSeries != 0) {
00265 idData(0) = theAccelTimeSeries->getClassTag();
00266 int seriesDbTag = theAccelTimeSeries->getDbTag();
00267 if (seriesDbTag == 0) {
00268 seriesDbTag = theChannel.getDbTag();
00269 theAccelTimeSeries->setDbTag(seriesDbTag);
00270 }
00271 idData(1) = seriesDbTag;
00272 } else
00273 idData(0) = -1;
00274
00275 if (theVelTimeSeries != 0) {
00276 idData(2) = theVelTimeSeries->getClassTag();
00277 int seriesDbTag = theVelTimeSeries->getDbTag();
00278 if (seriesDbTag == 0) {
00279 seriesDbTag = theChannel.getDbTag();
00280 theVelTimeSeries->setDbTag(seriesDbTag);
00281 }
00282 idData(3) = seriesDbTag;
00283 } else
00284 idData(2) = -1;
00285
00286 if (theDispTimeSeries != 0) {
00287 idData(4) = theDispTimeSeries->getClassTag();
00288 int seriesDbTag = theDispTimeSeries->getDbTag();
00289 if (seriesDbTag == 0) {
00290 seriesDbTag = theChannel.getDbTag();
00291 theDispTimeSeries->setDbTag(seriesDbTag);
00292 }
00293 idData(5) = seriesDbTag;
00294 } else
00295 idData(4) = -1;
00296
00297 int res = theChannel.sendID(dbTag, commitTag, idData);
00298 if (res < 0) {
00299 opserr << "GroundMotionRecord::sendSelf() - channel failed to send data\n";
00300 return res;
00301 }
00302
00303
00304 if (theAccelTimeSeries != 0) {
00305 res = theAccelTimeSeries->sendSelf(commitTag, theChannel);
00306 if (res < 0) {
00307 opserr << "GroundMotionRecord::sendSelf - failed to send accel series\n";
00308 return res;
00309 }
00310 }
00311
00312 if (theVelTimeSeries != 0) {
00313 res = theVelTimeSeries->sendSelf(commitTag, theChannel);
00314 if (res < 0) {
00315 opserr << "GroundMotionRecord::sendSelf - failed to send velocity series\n";
00316 return res;
00317 }
00318 }
00319
00320 if (theDispTimeSeries != 0) {
00321 res = theDispTimeSeries->sendSelf(commitTag, theChannel);
00322 if (res < 0) {
00323 opserr << "GroundMotionRecord::sendSelf - failed to send disp series\n";
00324 return res;
00325 }
00326 }
00327
00328 return 0;
00329 }
00330
00331
00332 int
00333 GroundMotionRecord::recvSelf(int commitTag, Channel &theChannel, FEM_ObjectBroker &theBroker)
00334 {
00335 int dbTag = this->getDbTag();
00336 static ID idData(6);
00337 int res = theChannel.recvID(dbTag, commitTag, idData);
00338 if (res < 0) {
00339 opserr << "UniformExcitation::sendSelf() - channel failed to send data\n";
00340 return res;
00341 }
00342
00343 int seriesClassTag = idData(0);
00344 if (seriesClassTag != -1) {
00345 int seriesDbTag = idData(1);
00346 if (theAccelTimeSeries == 0 || theAccelTimeSeries->getClassTag() != seriesClassTag) {
00347 if (theAccelTimeSeries != 0)
00348 delete theAccelTimeSeries;
00349 theAccelTimeSeries = theBroker.getNewTimeSeries(seriesClassTag);
00350 if (theAccelTimeSeries == 0) {
00351 opserr << "GroundMotionRecord::sendSelf - could not create a TimeSeries object\n";
00352 return -2;
00353 }
00354 }
00355 theAccelTimeSeries->setDbTag(seriesDbTag);
00356 res = theAccelTimeSeries->recvSelf(commitTag, theChannel, theBroker);
00357 if (res < 0) {
00358 opserr << "UniformExcitation::sendSelf() - accel series failed to send data\n";
00359 return res;
00360 }
00361 }
00362
00363 seriesClassTag = idData(2);
00364 if (seriesClassTag != -1) {
00365 int seriesDbTag = idData(3);
00366 if (theVelTimeSeries == 0 || theVelTimeSeries->getClassTag() != seriesClassTag) {
00367 if (theVelTimeSeries != 0)
00368 delete theVelTimeSeries;
00369 theVelTimeSeries = theBroker.getNewTimeSeries(seriesClassTag);
00370 if (theVelTimeSeries == 0) {
00371 opserr << "GroundMotionRecord::sendSelf - could not create a TimeSeries object\n";
00372 return -2;
00373 }
00374 }
00375 theVelTimeSeries->setDbTag(seriesDbTag);
00376 res = theVelTimeSeries->recvSelf(commitTag, theChannel, theBroker);
00377 if (res < 0) {
00378 opserr << "UniformExcitation::sendSelf() - accel series failed to send data\n";
00379 return res;
00380 }
00381 }
00382
00383 seriesClassTag = idData(4);
00384 if (seriesClassTag != -1) {
00385 int seriesDbTag = idData(5);
00386 if (theDispTimeSeries == 0 || theDispTimeSeries->getClassTag() != seriesClassTag) {
00387 if (theDispTimeSeries != 0)
00388 delete theDispTimeSeries;
00389 theDispTimeSeries = theBroker.getNewTimeSeries(seriesClassTag);
00390 if (theDispTimeSeries == 0) {
00391 opserr << "GroundMotionRecord::sendSelf - could not create a TimeSeries object\n";
00392 return -2;
00393 }
00394 }
00395 theDispTimeSeries->setDbTag(seriesDbTag);
00396 res = theDispTimeSeries->recvSelf(commitTag, theChannel, theBroker);
00397 if (res < 0) {
00398 opserr << "UniformExcitation::sendSelf() - accel series failed to send data\n";
00399 return res;
00400 }
00401 }
00402
00403 return 0;
00404 }
00405