00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include <TclModelBuilder.h>
00014
00015 #include <PressureIndependMultiYield.h>
00016
00017 #include <PressureDependMultiYield.h>
00018
00019 #include <FluidSolidPorousMaterial.h>
00020
00021 #include <Information.h>
00022
00023 #include <UniaxialMaterial.h>
00024
00025
00026
00027 #include <PyLiq1.h>
00028
00029 #include <TzLiq1.h>
00030
00031
00032
00033 #include <string.h>
00034
00035
00036
00037
00038
00039
00040
00041 int
00042
00043 TclModelBuilderUpdateMaterialStageCommand(ClientData clientData,
00044
00045 Tcl_Interp *interp,
00046
00047 int argc,
00048
00049 TCL_Char **argv,
00050
00051 TclModelBuilder *theTclBuilder)
00052
00053 {
00054
00055 if (argc < 5) {
00056
00057 opserr << "WARNING insufficient number of UpdateMaterialStage arguments\n";
00058
00059 opserr << "Want: UpdateMaterialStage material matTag? stage value?" << endln;
00060
00061 return TCL_ERROR;
00062
00063 }
00064
00065
00066
00067 if (strcmp(argv[1],"-material") != 0) {
00068
00069 opserr << "WARNING UpdateMaterialStage: Only accept parameter '-material' for now" << endln;
00070
00071 return TCL_ERROR;
00072
00073 }
00074
00075
00076
00077 int tag, value;
00078
00079
00080
00081 if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK) {
00082
00083 opserr << "WARNING MYSstage: invalid material tag" << endln;
00084
00085 return TCL_ERROR;
00086
00087 }
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097 NDMaterial * a = theTclBuilder->getNDMaterial(tag);
00098
00099 UniaxialMaterial * b = theTclBuilder->getUniaxialMaterial(tag);
00100
00101
00102
00103 if (a==0 && b==0) {
00104
00105 opserr << "WARNING UpdateMaterialStage: couldn't get NDmaterial tagged: " << tag << endln;
00106
00107 opserr << " or appropriate UniaxialMaterial tagged: " << tag << endln;
00108
00109 return TCL_ERROR;
00110
00111 }
00112
00113
00114
00115 if (strcmp(argv[3],"-stage") != 0) {
00116
00117 opserr << "WARNING UpdateMaterialStage: Only accept parameter '-stage' for now" << endln;
00118
00119 return TCL_ERROR;
00120
00121 }
00122
00123
00124
00125
00126
00127 if (Tcl_GetInt(interp, argv[4], &value) != TCL_OK) {
00128
00129 opserr << "WARNING UpdateMaterialStage: invalid parameter value" << endln;
00130
00131 return TCL_ERROR;
00132
00133 }
00134
00135
00136
00137
00138
00139 if(a){
00140
00141 const char * c = a->getType();
00142
00143 if (strcmp(c, "PlaneStrain") == 0 || strcmp(c, "ThreeDimensional") == 0 ) {
00144
00145 Information info;
00146
00147 a->updateParameter(value,info);
00148
00149 }
00150
00151 else {
00152
00153 opserr << "WARNING UpdateMaterialStage: The tagged is not a "<<endln;
00154
00155 opserr << "PressureDependMultiYield/PressureIndependMultiYield/FluidSolidPorous material. " << endln;
00156
00157 return TCL_ERROR;
00158
00159 }
00160
00161 }
00162
00163
00164
00165
00166
00167 if(b){
00168
00169 PyLiq1 *thePyLiq1 = dynamic_cast<PyLiq1*>(b);
00170
00171 TzLiq1 *theTzLiq1 = dynamic_cast<TzLiq1*>(b);
00172
00173 if(thePyLiq1 == 0 && theTzLiq1 == 0){
00174
00175 opserr << "WARNING UpdateMaterialStage: The tagged UniaxialMaterial is not a "<<endln;
00176
00177 opserr << "PyLiq1 or TzLiq1 material. " << endln;
00178
00179 return TCL_ERROR;
00180
00181 }
00182
00183 Information info;
00184
00185 if(thePyLiq1) b->updateParameter(value,info);
00186
00187 if(theTzLiq1) b->updateParameter(value,info);
00188
00189 }
00190
00191
00192
00193 return TCL_OK;
00194
00195 }
00196
00197
00198
00199
00200
00201 int
00202
00203 TclModelBuilderUpdateParameterCommand(ClientData clientData,
00204
00205 Tcl_Interp *interp,
00206
00207 int argc,
00208
00209 TCL_Char **argv,
00210
00211 TclModelBuilder *theTclBuilder)
00212
00213 {
00214
00215 if (argc < 5) {
00216
00217 opserr << "WARNING insufficient number of updateParameter arguments\n";
00218
00219 opserr << "Want: updateParameter -material matNum? -param? newValue?" << endln;
00220
00221 return TCL_ERROR;
00222
00223 }
00224
00225
00226
00227 if (strcmp(argv[1],"-material") != 0) {
00228
00229 opserr << "WARNING UpdateParameter: Only accept parameter '-material' for now" << endln;
00230
00231 return TCL_ERROR;
00232
00233 }
00234
00235
00236
00237 int tag, id; double value;
00238
00239
00240
00241 if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK) {
00242
00243 opserr << "WARNING UpdateParameter: invalid material tag" << endln;
00244
00245 return TCL_ERROR;
00246
00247 }
00248
00249
00250
00251 NDMaterial * a = theTclBuilder->getNDMaterial(tag);
00252
00253
00254
00255 if (a==0) {
00256
00257
00258
00259
00260
00261 UniaxialMaterial * a = theTclBuilder->getUniaxialMaterial(tag);
00262
00263 if (a==0) {
00264
00265 opserr << "WARNING UpdateParameter: couldn't get Uniaxialmaterial tagged: " << tag << endln;
00266
00267 return TCL_ERROR;
00268
00269 }
00270
00271 if (strcmp(argv[3],"-E") == 0) {
00272
00273 if (Tcl_GetDouble(interp, argv[4], &value) != TCL_OK) {
00274
00275 opserr << "WARNING UpdateParameter: invalid parameter value" << endln;
00276
00277 return TCL_ERROR;
00278
00279 }
00280
00281 Information info;
00282
00283 info.setDouble(value);
00284
00285 a->updateParameter(0,info);
00286
00287 }
00288
00289 else if (strcmp(argv[3],"-fy") == 0) {
00290
00291 if (Tcl_GetDouble(interp, argv[4], &value) != TCL_OK) {
00292
00293 opserr << "WARNING UpdateParameter: invalid parameter value" << endln;
00294
00295 return TCL_ERROR;
00296
00297 }
00298
00299 Information info;
00300
00301 info.setDouble(value);
00302
00303 a->updateParameter(1,info);
00304
00305 }
00306
00307 else {
00308
00309 opserr << "WARNING UpdateParameter: Only accept parameter '-E' or '-fy' for now" << endln;
00310
00311 return TCL_ERROR;
00312
00313 }
00314
00315 return TCL_OK;
00316
00317 }
00318
00319
00320
00321 if (strcmp(argv[3],"-refG") == 0)
00322
00323 id = 10;
00324
00325 else if (strcmp(argv[3],"-refB") == 0)
00326
00327 id = 11;
00328
00329 else {
00330
00331 opserr << "WARNING UpdateParameter: Only accept parameter '-refG' or '-refB' for now" << endln;
00332
00333 return TCL_ERROR;
00334
00335 }
00336
00337
00338
00339
00340
00341 if (Tcl_GetDouble(interp, argv[4], &value) != TCL_OK) {
00342
00343 opserr << "WARNING UpdateParameter: invalid parameter value" << endln;
00344
00345 return TCL_ERROR;
00346
00347 }
00348
00349
00350
00351 const char * c = a->getType();
00352
00353
00354
00355 if (strcmp(c, "PlaneStrain") == 0 ||
00356
00357 strcmp(c, "ThreeDimensional") == 0 ) {
00358
00359 Information info;
00360
00361 info.setDouble(value);
00362
00363 a->updateParameter(id,info);
00364
00365 }
00366
00367 else {
00368
00369 opserr << "WARNING UpdateParameter: The tagged is not a "<<endln;
00370
00371 opserr << "PressureDependMultiYield/PressureIndependMultiYield/FluidSolidPorous material. " << endln;
00372
00373 return TCL_ERROR;
00374
00375 }
00376
00377
00378
00379 return TCL_OK;
00380
00381 }
00382
00383
00384