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
00040
00041
00042
00043 #include <TclModelBuilder.h>
00044
00045 #include <tcl.h>
00046 #include <Domain.h>
00047 #include <LoadPattern.h>
00048 #include <LinearSeries.h>
00049 #include <ConstantSeries.h>
00050 #include <RectangularSeries.h>
00051 #include <TrigSeries.h>
00052 #include <PathTimeSeries.h>
00053 #include <PathSeries.h>
00054 #include <UniformExcitation.h>
00055 #include <MultiSupportPattern.h>
00056 #include <GroundMotion.h>
00057 #include <GroundMotionRecord.h>
00058 #include <TimeSeriesIntegrator.h>
00059 #include <PBowlLoading.h>
00060
00061 #include <string.h>
00062
00063
00064
00065 LoadPattern *theTclLoadPattern =0;
00066 MultiSupportPattern *theTclMultiSupportPattern =0;
00067
00068
00069 extern TimeSeriesIntegrator *
00070 TclSeriesIntegratorCommand(ClientData clientData, Tcl_Interp *interp, TCL_Char *arg);
00071
00072 extern TimeSeries *
00073 TclSeriesCommand(ClientData clientData, Tcl_Interp *interp, TCL_Char *arg);
00074
00075
00076 int
00077 TclPatternCommand(ClientData clientData, Tcl_Interp *interp,
00078 int argc, TCL_Char **argv, Domain *theDomain)
00079 {
00080 LoadPattern *thePattern = 0;
00081
00082
00083 if (argc < 4) {
00084 opserr << "WARNING invalid command - want: pattern type ";
00085 opserr << " <type args> {list of load and sp constraints commands}\n";
00086 opserr << " valid types: Plain, UniformExcitation, MultiSupport\n";
00087 return TCL_ERROR;
00088 }
00089
00090 TimeSeries *theSeries = 0;
00091 int patternID =0;
00092
00093 if (Tcl_GetInt(interp, argv[2], &patternID) != TCL_OK) {
00094 opserr << "WARNING invalid patternID: pattern type " << argv[2]
00095 << "<type args>\n";
00096 return TCL_ERROR;
00097 }
00098
00099 int commandEndMarker = 0;
00100
00101 if (strcmp(argv[1],"Plain") == 0) {
00102
00103 thePattern = new LoadPattern(patternID);
00104 theSeries = TclSeriesCommand(clientData, interp, argv[3]);
00105
00106
00107 if (thePattern == 0 || theSeries == 0) {
00108
00109 if (thePattern == 0) {
00110 opserr << "WARNING - out of memory creating LoadPattern ";
00111 opserr << patternID << endln;
00112 } else {
00113 opserr << "WARNING - problem creating TimeSeries for LoadPattern ";
00114 opserr << patternID << endln;
00115 }
00116
00117
00118 if (thePattern != 0)
00119 delete thePattern;
00120 if (theSeries != 0)
00121 delete theSeries;
00122 return TCL_ERROR;
00123 }
00124
00125 thePattern->setTimeSeries(theSeries);
00126
00127 }
00128
00129 else if (strcmp(argv[1],"UniformExcitation") == 0) {
00130
00131 int dir;
00132
00133 if (Tcl_GetInt(interp, argv[3], &dir) != TCL_OK) {
00134 opserr << "WARNING invalid patternID: pattern type " << argv[2]
00135 << "<type args>\n";
00136 return TCL_ERROR;
00137 }
00138
00139 dir--;
00140
00141 TimeSeries *accelSeries = 0;
00142 TimeSeries *velSeries = 0;
00143 TimeSeries *dispSeries = 0;
00144 TimeSeriesIntegrator *seriesIntegrator = 0;
00145 double vel0 = 0.0;
00146
00147 int currentArg = 4;
00148 bool doneSeries = false;
00149 while (currentArg < argc-1 && doneSeries == false) {
00150
00151 if ((strcmp(argv[currentArg],"-vel0") == 0) ||
00152 (strcmp(argv[currentArg],"-initialVel") == 0)) {
00153
00154 currentArg++;
00155 if ((currentArg < argc) &&
00156 (Tcl_GetDouble(interp, argv[currentArg], &vel0) != TCL_OK)) {
00157 opserr << "WARNING invalid vel0: pattern type UniformExciation\n";
00158 return TCL_ERROR;
00159 }
00160
00161 currentArg++;
00162 }
00163
00164
00165 else if ((strcmp(argv[currentArg],"-accel") == 0) ||
00166 (strcmp(argv[currentArg],"-acceleration") == 0)) {
00167
00168 currentArg++;
00169 accelSeries = TclSeriesCommand(clientData, interp, argv[currentArg]);
00170 if (accelSeries == 0) {
00171 opserr << "WARNING invalid accel series: pattern UniformExcitation -accel <args>\n";
00172 return TCL_ERROR;
00173 }
00174
00175 currentArg++;
00176
00177 } else if ((strcmp(argv[currentArg],"-vel") == 0) ||
00178 (strcmp(argv[currentArg],"-velocity") == 0)) {
00179
00180 currentArg++;
00181 velSeries = TclSeriesCommand(clientData, interp, argv[currentArg]);
00182
00183 if (velSeries == 0) {
00184 opserr << "WARNING invalid vel series: " << argv[currentArg];
00185 opserr << " pattern UniformExcitation -vel {series}\n";
00186 return TCL_ERROR;
00187 }
00188
00189 currentArg++;
00190
00191 } else if ((strcmp(argv[currentArg],"-disp") == 0) ||
00192 (strcmp(argv[currentArg],"-displacement") == 0)) {
00193
00194 currentArg++;
00195 dispSeries = TclSeriesCommand(clientData, interp, argv[currentArg]);
00196
00197 if (dispSeries == 0) {
00198 opserr << "WARNING invalid vel series: " << argv[currentArg];
00199 opserr << " pattern UniformExcitation -vel {series}\n";
00200 return TCL_ERROR;
00201 }
00202
00203 currentArg++;
00204 } else if ((strcmp(argv[currentArg],"-int") == 0) ||
00205 (strcmp(argv[currentArg],"-integrator") == 0)) {
00206
00207 currentArg++;
00208 seriesIntegrator = TclSeriesIntegratorCommand(clientData, interp,
00209 argv[currentArg]);
00210 if (seriesIntegrator == 0) {
00211 opserr << "WARNING invalid series integrator: " << argv[currentArg];
00212 opserr << " - pattern UniformExcitation -int {Series Integrator}\n";
00213 return TCL_ERROR;
00214 }
00215 currentArg++;
00216 }
00217
00218 else
00219 doneSeries = true;
00220 }
00221
00222 if (dispSeries == 0 && velSeries == 0 && accelSeries == 0) {
00223 opserr << "WARNING invalid series, want - pattern UniformExcitation";
00224 opserr << "-disp {dispSeries} -vel {velSeries} -accel {accelSeries} ";
00225 opserr << "-int {Series Integrator}\n";
00226 return TCL_ERROR;
00227 }
00228
00229 GroundMotion *theMotion = new GroundMotion(dispSeries, velSeries,
00230 accelSeries, seriesIntegrator);
00231
00232 if (theMotion == 0) {
00233 opserr << "WARNING ran out of memory creating ground motion - pattern UniformExcitation ";
00234 opserr << patternID << endln;
00235
00236 return TCL_ERROR;
00237 }
00238
00239
00240 thePattern = new UniformExcitation(*theMotion, dir, patternID, vel0);
00241
00242 if (thePattern == 0) {
00243 opserr << "WARNING ran out of memory creating load pattern - pattern UniformExcitation ";
00244 opserr << patternID << endln;
00245
00246
00247 if (theMotion != 0)
00248 delete theMotion;
00249
00250 return TCL_ERROR;
00251 }
00252
00253
00254 commandEndMarker = currentArg;
00255 }
00256
00257 else if (strcmp(argv[1],"Uniform") == 0) {
00258
00259
00260 int numInputs = argc;
00261 TCL_Char *accelFileName = 0;
00262 double dt = 0.0;
00263 for (int i = 5; i < argc; i++)
00264 {
00265 if (strcmp (argv[i],"-accel") == 0 && i+2 < argc)
00266 {
00267
00268 accelFileName = argv[i+1];
00269
00270
00271 if (Tcl_GetDouble(interp, argv[i+2], &dt) != TCL_OK)
00272 {
00273 opserr << "WARNING problem reading ground motion "
00274 << "time interval - pattern UniformExcitation: "
00275 << patternID << endln;
00276 return TCL_ERROR;
00277 }
00278 numInputs -= 3;
00279
00280 }
00281 }
00282
00283 if (numInputs < 5) {
00284 opserr << "WARNING insufficient number of arguments - want: pattern ";
00285 opserr << "UniformExcitation " << patternID << " dir factor\n";
00286 return TCL_ERROR;
00287 }
00288
00289 int dir;
00290 if (Tcl_GetInt(interp, argv[3], &dir) != TCL_OK) {
00291
00292 char inputDir;
00293 inputDir = argv[3][0];
00294 switch (inputDir)
00295 {
00296 case 'X': case 'x': case '1':
00297 dir = 0;
00298 break;
00299 case 'Y': case 'y': case '2':
00300 dir = 1;
00301 break;
00302 case 'Z': case 'z': case '3':
00303 dir = 2;
00304 break;
00305 default:
00306 opserr << "WARNING cannot read direction for excitation \n";
00307 opserr << "UniformExcitation " << patternID << " dir factor" << endln;
00308 return TCL_ERROR;
00309 break;
00310 }
00311 } else
00312 dir--;
00313
00314 double factor;
00315 if (Tcl_GetDouble(interp, argv[4], &factor) != TCL_OK) {
00316 opserr << "WARNING insufficient number of arguments - want: pattern ";
00317 opserr << "UniformExcitation " << patternID << " dir factor\n";
00318 return TCL_ERROR;
00319 }
00320
00321 GroundMotionRecord *theMotion;
00322
00323
00324
00325 if (accelFileName == 0)
00326 {
00327 opserr << "WARNING -- No ground motion data provided\n";
00328 opserr << "UniformExcitation tag: " << patternID << endln;
00329 return TCL_ERROR;
00330 }
00331
00332 theMotion = new GroundMotionRecord(accelFileName, dt, factor);
00333
00334 if (theMotion == 0) {
00335 opserr << "WARNING ran out of memory creating ground motion - pattern UniformExcitation ";
00336 opserr << patternID << endln;
00337
00338 return TCL_ERROR;
00339 }
00340
00341
00342 thePattern = new UniformExcitation(*theMotion, dir, patternID);
00343
00344 if (thePattern == 0) {
00345 opserr << "WARNING ran out of memory creating load pattern - pattern UniformExcitation ";
00346 opserr << patternID << endln;
00347
00348
00349 if (theMotion != 0)
00350 delete theMotion;
00351
00352 return TCL_ERROR;
00353 }
00354 }
00355
00356 else if ((strcmp(argv[1],"MultipleSupportExcitation") == 0) ||
00357 (strcmp(argv[1],"MultipleSupport") == 0) ||
00358 (strcmp(argv[1],"MultiSupport") == 0)) {
00359
00360 theTclMultiSupportPattern = new MultiSupportPattern(patternID);
00361 thePattern = theTclMultiSupportPattern;
00362
00363 if (thePattern == 0) {
00364 opserr << "WARNING ran out of memory creating load pattern - pattern MultipleSupportExcitation ";
00365 opserr << patternID << endln;
00366
00367 }
00368 commandEndMarker = 2;
00369 }
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379 else if (strcmp(argv[1],"PBowlLoading") == 0) {
00380
00381
00382 TCL_Char * PBEleFileName = 0;
00383 TCL_Char * accelFileName = 0;
00384 TCL_Char * displFileName = 0;
00385
00386 double dt = 0.02;
00387 double cf = 1.00;
00388 double xp = 0.0;
00389 double xm = 0.0;
00390 double yp = 0.0;
00391 double ym = 0.0;
00392 double zp = 0.0;
00393 double zm = 0.0;
00394
00395 int currentArg = 3;
00396
00397 while (currentArg < argc-1)
00398 {
00399 if ((strcmp(argv[currentArg],"-pbele") == 0) ||
00400 (strcmp(argv[currentArg],"-PBEle") == 0)) {
00401
00402 currentArg++;
00403 PBEleFileName = argv[currentArg];
00404 currentArg++;
00405 }
00406 else if ((strcmp(argv[currentArg],"-acce") == 0) ||
00407 (strcmp(argv[currentArg],"-acceleration") == 0)) {
00408
00409 currentArg++;
00410 accelFileName = argv[currentArg];
00411 currentArg++;
00412 }
00413 else if ((strcmp(argv[currentArg],"-disp") == 0) ||
00414 (strcmp(argv[currentArg],"-displacement") == 0)) {
00415
00416 currentArg++;
00417 displFileName = argv[currentArg];
00418 currentArg++;
00419 }
00420 else if (strcmp(argv[currentArg],"-dt") == 0) {
00421
00422 currentArg++;
00423 if (Tcl_GetDouble(interp, argv[currentArg], &dt) != TCL_OK)
00424 {
00425 opserr << "WARNING problem reading ground motion "
00426 << "time interval - pattern PBowlLoading: "
00427 << patternID << endln;
00428 return TCL_ERROR;
00429 }
00430 currentArg++;
00431 }
00432 else if ((strcmp(argv[currentArg],"-factor") == 0)||
00433 (strcmp(argv[currentArg],"-Factor") == 0 )) {
00434
00435 currentArg++;
00436 if (Tcl_GetDouble(interp, argv[currentArg], &cf) != TCL_OK)
00437 {
00438 opserr << "WARNING problem reading ground motion "
00439 << "load factor - pattern PBowlLoading: "
00440 << patternID << endln;
00441 return TCL_ERROR;
00442 }
00443 currentArg++;
00444 }
00445
00446 else if ((strcmp(argv[currentArg],"-xminus") == 0)||
00447 (strcmp(argv[currentArg],"-xm" ) == 0 )) {
00448
00449 currentArg++;
00450 if (Tcl_GetDouble(interp, argv[currentArg], &xm) != TCL_OK)
00451 {
00452 opserr << "WARNING problem reading ground motion "
00453 << "Left x - pattern PBowlLoading: "
00454 << patternID << endln;
00455 return TCL_ERROR;
00456 }
00457 currentArg++;
00458 }
00459
00460 else if ((strcmp(argv[currentArg],"-xplus") == 0)||
00461 (strcmp(argv[currentArg],"-xp" ) == 0 )) {
00462
00463 currentArg++;
00464 if (Tcl_GetDouble(interp, argv[currentArg], &xp) != TCL_OK)
00465 {
00466 opserr << "WARNING problem reading ground motion "
00467 << "Right x - pattern PBowlLoading: "
00468 << patternID << endln;
00469 return TCL_ERROR;
00470 }
00471 currentArg++;
00472 }
00473
00474 else if ((strcmp(argv[currentArg],"-yminus") == 0)||
00475 (strcmp(argv[currentArg],"-ym" ) == 0 )) {
00476
00477 currentArg++;
00478 if (Tcl_GetDouble(interp, argv[currentArg], &ym) != TCL_OK)
00479 {
00480 opserr << "WARNING problem reading ground motion "
00481 << "Left y - pattern PBowlLoading: "
00482 << patternID << endln;
00483 return TCL_ERROR;
00484 }
00485 currentArg++;
00486 }
00487
00488 else if ((strcmp(argv[currentArg],"-yplus") == 0)||
00489 (strcmp(argv[currentArg],"-yp" ) == 0 )) {
00490
00491 currentArg++;
00492 if (Tcl_GetDouble(interp, argv[currentArg], &yp) != TCL_OK)
00493 {
00494 opserr << "WARNING problem reading ground motion "
00495 << "Right y - pattern PBowlLoading: "
00496 << patternID << endln;
00497 return TCL_ERROR;
00498 }
00499 currentArg++;
00500 }
00501
00502 else if ((strcmp(argv[currentArg],"-zminus") == 0)||
00503 (strcmp(argv[currentArg],"-zm" ) == 0 )) {
00504
00505 currentArg++;
00506 if (Tcl_GetDouble(interp, argv[currentArg], &zm) != TCL_OK)
00507 {
00508 opserr << "WARNING problem reading ground motion "
00509 << "Left z - pattern PBowlLoading: "
00510 << patternID << endln;
00511 return TCL_ERROR;
00512 }
00513 currentArg++;
00514 }
00515
00516 else if ((strcmp(argv[currentArg],"-zplus") == 0)||
00517 (strcmp(argv[currentArg],"-zp" ) == 0 )) {
00518
00519 currentArg++;
00520 if (Tcl_GetDouble(interp, argv[currentArg], &zp) != TCL_OK)
00521 {
00522 opserr << "WARNING problem reading ground motion "
00523 << "Right y - pattern PBowlLoading: "
00524 << patternID << endln;
00525 return TCL_ERROR;
00526 }
00527 currentArg++;
00528 }
00529
00530 }
00531
00532
00533 thePattern = new PBowlLoading(patternID, PBEleFileName, displFileName, accelFileName, dt, cf, xp, xm, yp, ym, zp, zm);
00534 if (thePattern == 0) {
00535 opserr << "WARNING ran out of memory creating load pattern - pattern PBowlLoading ";
00536 opserr << patternID << endln;
00537
00538 }
00539
00540 commandEndMarker = currentArg;
00541 }
00542
00543 else {
00544 opserr << "WARNING unknown pattern type " << argv[1];
00545 opserr << " - want: pattern patternType " << patternID ;
00546 opserr << " \t valid types: Plain, UniformExcitation, MultiSupportExciatation \n";
00547 return TCL_ERROR;
00548 }
00549
00550
00551 if (theDomain->addLoadPattern(thePattern) == false) {
00552 opserr << "WARNING could not add load pattern to the domain " << *thePattern;
00553 delete thePattern;
00554 return TCL_ERROR;
00555 }
00556
00557 theTclLoadPattern = thePattern;
00558
00559
00560 if (commandEndMarker < (argc-1)) {
00561 if (Tcl_Eval(interp, argv[argc-1]) != TCL_OK) {
00562 opserr << "WARNING - error reading load pattern information in { } ";
00563 return TCL_ERROR;
00564 }
00565 }
00566
00567 theTclMultiSupportPattern = 0;
00568
00569 return TCL_OK;
00570 }
00571
00572
00573
00574