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 #include <EarthquakePattern.h>
00035 #include <GroundMotion.h>
00036
00037 #include <Domain.h>
00038 #include <NodeIter.h>
00039 #include <Node.h>
00040 #include <ElementIter.h>
00041 #include <Element.h>
00042 #include <stdlib.h>
00043 #include <Channel.h>
00044 #include <ErrorHandler.h>
00045
00046 EarthquakePattern::EarthquakePattern(int tag, int _classTag)
00047 :LoadPattern(tag, _classTag), theMotions(0), numMotions(0), uDotG(0), uDotDotG(0)
00048 {
00049
00050 }
00051
00052
00053 EarthquakePattern::~EarthquakePattern()
00054 {
00055
00056 for (int i=0; i<numMotions; i++)
00057 delete theMotions[i];
00058
00059 if (theMotions != 0)
00060
00061 delete [] theMotions;
00062 }
00063
00064
00065
00066 void
00067 EarthquakePattern::applyLoad(double time)
00068 {
00069
00070 if (numMotions == 0)
00071 return;
00072
00073 Domain *theDomain = this->getDomain();
00074 if (theDomain == 0)
00075 return;
00076
00077
00078
00079 for (int i=0; i<numMotions; i++) {
00080 (*uDotG)(i) = theMotions[i]->getVel(time);
00081 (*uDotDotG)(i) = theMotions[i]->getAccel(time);
00082 }
00083
00084 NodeIter &theNodes = theDomain->getNodes();
00085 Node *theNode;
00086 while ((theNode = theNodes()) != 0)
00087 theNode->addInertiaLoadToUnbalance(*uDotDotG, 1.0);
00088
00089
00090 ElementIter &theElements = theDomain->getElements();
00091 Element *theElement;
00092 while ((theElement = theElements()) != 0)
00093 theElement->addInertiaLoadToUnbalance(*uDotDotG);
00094 }
00095
00096 int
00097 EarthquakePattern::addMotion(GroundMotion &theMotion)
00098 {
00099
00100 GroundMotion **newMotions = new GroundMotion *[numMotions+1];
00101
00102 if (newMotions == 0) {
00103 cerr << "EarthquakePattern::addMotion - could not add new, out of mem\n";
00104 return -1;
00105 }
00106
00107
00108 for (int i=0; i<numMotions; i++)
00109 newMotions[i] = theMotions[i];
00110
00111
00112 newMotions[numMotions] = &theMotion;
00113
00114
00115 if (theMotions != 0)
00116 delete [] theMotions;
00117
00118
00119 theMotions = newMotions;
00120 numMotions++;
00121
00122
00123 if (uDotG != 0)
00124 delete uDotG;
00125 uDotG = new Vector(numMotions);
00126
00127 if (uDotDotG != 0)
00128 delete uDotDotG;
00129 uDotDotG = new Vector(numMotions);
00130
00131 if (uDotDotG == 0 || uDotDotG->Size() == 0 || uDotG == 0 || uDotG->Size() == 0) {
00132 cerr << "EarthquakePattern::addMotion - ran out of memory creating vectors\n";
00133 numMotions = 0;
00134 return -2;
00135 }
00136 return 0;
00137 }
00138
00139
00140 bool
00141 EarthquakePattern::addSP_Constraint(SP_Constraint *)
00142 {
00143 cerr << "EarthquakePattern::addSP_Constraint() - cannot add SP_Constraint to EQ pattern\n";
00144 return false;
00145 }
00146
00147 bool
00148 EarthquakePattern::addNodalLoad(NodalLoad *)
00149 {
00150 cerr << "EarthquakePattern::addNodalLoad() - cannot add NodalLoad to EQ pattern\n";
00151 return false;
00152 }
00153
00154 bool
00155 EarthquakePattern::addElementalLoad(ElementalLoad *)
00156 {
00157 cerr << "EarthquakePattern::addElementalLoad() - cannot add ElementalLoad to EQ pattern\n";
00158 return false;
00159 }
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301 void
00302 EarthquakePattern::Print(ostream &s, int flag)
00303 {
00304 cerr << "EarthquakePattern::Print() - not yet implemented\n";
00305 }
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321