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 #include <stdlib.h>
00029 #include <string.h>
00030
00031 #include <Domain.h>
00032
00033 #include <ErrorHandler.h>
00034 #include <TclModelBuilder.h>
00035
00036 #include <NDMaterial.h>
00037 #include <FiniteDeformationEP3D.h>
00038 #include <FiniteDeformationElastic3D.h>
00039
00040 #include <fdYield.h>
00041 #include <fdYieldVM.h>
00042 #include <fdYieldDP.h>
00043
00044 #include <fdFlow.h>
00045 #include <fdFlowVM.h>
00046 #include <fdFlowDP.h>
00047
00048 #include <fdEvolution_S.h>
00049 #include <fdEvolution_SLS.h>
00050
00051 #include <fdEvolution_T.h>
00052 #include <fdEvolution_TL.h>
00053
00054
00055
00056 fdYield *EvaluatefdYield(ClientData, Tcl_Interp *, TCL_Char *tclString);
00057 fdFlow *EvaluatefdFlow(ClientData, Tcl_Interp *, TCL_Char *tclString);
00058 fdEvolution_S *EvaluatefdEvolution_S(ClientData, Tcl_Interp *, TCL_Char *tclString);
00059 fdEvolution_T *EvaluatefdEvolution_T(ClientData, Tcl_Interp *, TCL_Char *tclString);
00060
00061
00062 static void cleanup(TCL_Char **argv) {
00063 Tcl_Free((char *) argv);
00064 }
00065
00066
00067
00068
00069 FiniteDeformationEP3D *
00070 TclModelBuilder_addFiniteDeformationEP3D(ClientData clientData, Tcl_Interp *interp, int argc,
00071 TCL_Char **argv, TclModelBuilder *theTclBuilder, int eleArgStart)
00072 {
00073 int tag = 0;
00074 int tagElasticFD = 0;
00075 fdYield *fdY = 0;
00076 fdFlow *fdF = 0;
00077 fdEvolution_S *fdES = 0;
00078 fdEvolution_T *fdET = 0;
00079
00080 NDMaterial *matFDElastic = 0;
00081
00082 int loc = eleArgStart;
00083
00084 if (Tcl_GetInt(interp, argv[loc++], &tag) != TCL_OK) {
00085 opserr << "Warning: nDMaterial FDEP3D - invalid tag " << argv[loc] << "\n";
00086 exit (-1);
00087 }
00088
00089 if (Tcl_GetInt(interp, argv[loc++], &tagElasticFD) != TCL_OK) {
00090 opserr << "Warning: nDMaterial FDEP3D - invalid elastic material tag " << argv[loc] << "\n";
00091 exit (-1);
00092 }
00093
00094 if (tagElasticFD == tag) {
00095 opserr << "Error: nDMaterial FDEP3D, elastic matTag is the same with FDEP3D matTag" << argv[loc] << "\n";
00096 exit (-1);
00097 }
00098
00099 matFDElastic = theTclBuilder->getNDMaterial(tagElasticFD);
00100
00101 if (tagElasticFD == 0) {
00102 opserr << "WARNING: nD FD elastic material does not exist\n";
00103 opserr << "nD FD material: " << tagElasticFD;
00104 opserr << "\n FDEP3D nDMaterial: " << tag << "\n";
00105 exit (-1);
00106 }
00107
00108 while (loc < argc) {
00109
00110 if ((strcmp(argv[loc],"-fdYield") == 0) || (strcmp(argv[loc],"-fdY") == 0)) {
00111 fdY = EvaluatefdYield(clientData, interp, argv[loc+1]);
00112 if (fdY == 0) {
00113 opserr << "Warning: nDMaterial FDEP3D - could not create a fdYield from" << argv[loc+1] << "\n";
00114 exit (-1);
00115 }
00116 }
00117
00118 else if ((strcmp(argv[loc],"-fdFlow") == 0) || (strcmp(argv[loc],"-fdF") == 0)) {
00119 fdF = EvaluatefdFlow(clientData, interp, argv[loc+1]);
00120 if (fdF == 0) {
00121 opserr << "Warning: nDMaterial FDEP3D - could not create a fdFlow from" << argv[loc+1] << "\n";
00122 exit (-1);
00123 }
00124 }
00125
00126 else if ((strcmp(argv[loc],"-fdEvolution_S") == 0) || (strcmp(argv[loc],"-fdES") == 0)) {
00127 fdES = EvaluatefdEvolution_S(clientData, interp, argv[loc+1]);
00128 if (fdES == 0) {
00129 opserr << "Warning: nDMaterial FDEP3D - could not create a fdES from" << argv[loc+1] << "\n";
00130 exit (-1);
00131 }
00132 }
00133
00134 else if ((strcmp(argv[loc],"-fdEvolution_T") == 0) || (strcmp(argv[loc],"-fdET") == 0)) {
00135 fdET = EvaluatefdEvolution_T(clientData, interp, argv[loc+1]);
00136 if (fdET == 0) {
00137 opserr << "Warning: nDMaterial FDEP3D - could not create a fdET from" << argv[loc+1] << "\n";
00138 exit (-1);
00139 }
00140 }
00141
00142 else {
00143 opserr << "Warning: nDMaterial FDEP3D - don't understand %s\n";
00144 exit (-1);
00145 }
00146
00147
00148 loc += 2;
00149 }
00150
00151 FiniteDeformationEP3D *theMaterial = 0;
00152
00153 if ( (fdY != 0) && (fdF != 0) && (fdES != 0) && (fdET != 0) && (matFDElastic != 0) )
00154 theMaterial = new FiniteDeformationEP3D(tag, matFDElastic, fdY, fdF, fdES, fdET);
00155 else if ( (fdY != 0) && (fdF != 0) && (fdES != 0) && (fdET == 0) && (matFDElastic != 0) )
00156 theMaterial = new FiniteDeformationEP3D(tag, matFDElastic, fdY, fdF, fdES);
00157 else if ( (fdY != 0) && (fdF != 0) && (fdES == 0) && (fdET != 0) && (matFDElastic != 0) )
00158 theMaterial = new FiniteDeformationEP3D(tag, matFDElastic, fdY, fdF, fdET);
00159 else if ( (fdY != 0) && (fdF != 0) && (fdES == 0) && (fdET == 0) && (matFDElastic != 0) )
00160 theMaterial = new FiniteDeformationEP3D(tag, matFDElastic, fdY, fdF);
00161 else
00162 opserr << "Warning: invalid args used to create a FiniteDeformationEP3D material\n";
00163
00164 return theMaterial;
00165 }
00166
00167
00168
00169
00170
00171 fdYield *EvaluatefdYield(ClientData clientData, Tcl_Interp *interp, TCL_Char *tclString)
00172 {
00173 int argc;
00174 TCL_Char **argv;
00175
00176
00177 if (Tcl_SplitList(interp, tclString, &argc, &argv) != TCL_OK) {
00178 exit (-1);
00179 }
00180
00181 if (argc == 0)
00182 exit (-1);
00183
00184
00185 fdYield *fdY = 0;
00186
00187
00188
00189 if ((strcmp(argv[0],"-VM") == 0) || (strcmp(argv[0],"-vM") == 0) || (strcmp(argv[0],"-J2") == 0)) {
00190 double Y0 = 0.0;
00191
00192 if (argc == 2) {
00193 if (Tcl_GetDouble(interp, argv[1], &Y0) != TCL_OK) {
00194 opserr << "Warning: nDMaterial FDEP3D - invalid Y0 " << argv[1] << "\n";
00195 exit (-1);
00196 }
00197 }
00198
00199 fdY = new fdYieldVM(Y0);
00200 }
00201
00202
00203
00204 else if ((strcmp(argv[0],"-DP") == 0) || (strcmp(argv[0],"-dp") == 0) ) {
00205 double FrictionAng_in = 0.0;
00206 double k_in = 0.0;
00207
00208 if (argc >= 3) {
00209 if (Tcl_GetDouble(interp, argv[1], &FrictionAng_in) != TCL_OK) {
00210 opserr << "Warning: nDMaterial FDEP3D - invalid Friction Angle " << argv[1] << "\n";
00211 exit (-1);
00212 }
00213 if (Tcl_GetDouble(interp, argv[2], &k_in) != TCL_OK) {
00214 opserr << "Warning: nDMaterial FDEP3D - invalid Conhesion " << argv[2] << "\n";
00215 exit (-1);
00216 }
00217 }
00218
00219 fdY = new fdYieldDP(FrictionAng_in, k_in);
00220 }
00221
00222 else {
00223 opserr << "Warning: invalid fd yield function: " << argv[0] << "\n";
00224 exit (-1);
00225 }
00226
00227 cleanup(argv);
00228 return fdY;
00229 }
00230
00231
00232
00233
00234
00235 fdFlow *EvaluatefdFlow(ClientData clientData, Tcl_Interp *interp, TCL_Char *tclString)
00236 {
00237 int argc;
00238 TCL_Char **argv;
00239
00240
00241 if (Tcl_SplitList(interp, tclString, &argc, &argv) != TCL_OK) {
00242 exit (-1);
00243 }
00244
00245 if (argc == 0)
00246 exit (-1);
00247
00248 fdFlow *fdF = 0;
00249
00250
00251
00252 if ((strcmp(argv[0],"-VM") == 0) || (strcmp(argv[0],"-vM") == 0) || (strcmp(argv[0],"-J2") == 0)) {
00253 double Y0 = 0.0;
00254
00255 if (argc == 2) {
00256 if (Tcl_GetDouble(interp, argv[1], &Y0) != TCL_OK) {
00257 opserr << "Warning: nDMaterial FDEP3D - invalid Y0 " << argv[1] << "\n";
00258 exit (-1);
00259 }
00260 }
00261
00262 fdF = new fdFlowVM(Y0);
00263 }
00264
00265
00266
00267 else if ((strcmp(argv[0],"-DP") == 0) || (strcmp(argv[0],"-dp") == 0) ) {
00268 double DilatedAngle_in = 0.0;
00269 double k_in = 0.0;
00270
00271 if (argc >= 3) {
00272 if (Tcl_GetDouble(interp, argv[1], &DilatedAngle_in) != TCL_OK) {
00273 opserr << "Warning: nDMaterial FDEP3D - invalid Dilated Angle " << argv[1] << "\n";
00274 exit (-1);
00275 }
00276 if (Tcl_GetDouble(interp, argv[2], &k_in) != TCL_OK) {
00277 opserr << "Warning: nDMaterial FDEP3D - invalid Conhesion " << argv[2] << "\n";
00278 exit (-1);
00279 }
00280 }
00281
00282 fdF = new fdFlowDP(DilatedAngle_in, k_in);
00283 }
00284
00285 else {
00286 opserr << "Warning: invalid fd flow rule: " << argv[0] << "\n";
00287 exit (-1);
00288 }
00289
00290 cleanup(argv);
00291 return fdF;
00292 }
00293
00294
00295
00296
00297
00298 fdEvolution_S *EvaluatefdEvolution_S(ClientData clientData, Tcl_Interp *interp, TCL_Char *tclString)
00299 {
00300 int argc;
00301 TCL_Char **argv;
00302
00303
00304 if (Tcl_SplitList(interp, tclString, &argc, &argv) != TCL_OK) {
00305 exit (-1);
00306 }
00307
00308 fdEvolution_S *fdES = 0;
00309
00310
00311
00312 if ((strcmp(argv[0],"-LS") == 0) || (strcmp(argv[0],"-LinearSaturated") == 0)) {
00313
00314 double H_linear = 0.0;
00315 double q_saturated = 0.0;
00316 double beta = 0.0;
00317
00318 if (argc >= 2) {
00319 if (Tcl_GetDouble(interp, argv[1], &H_linear) != TCL_OK) {
00320 opserr << "Warning: nDMaterial FDEP3D - invalid H_linear " << argv[1] << "\n";
00321 cleanup(argv);
00322 exit (-1);
00323 }
00324 }
00325
00326 if (argc >= 4) {
00327 if (Tcl_GetDouble(interp, argv[2], &q_saturated) != TCL_OK) {
00328 opserr << "Warning: nDMaterial FDEP3D - invalid q_saturated " << argv[2] << "\n";
00329 cleanup(argv);
00330 exit (-1);
00331 }
00332 if (Tcl_GetDouble(interp, argv[3], &beta) != TCL_OK) {
00333 opserr << "Warning: nDMaterial FDEP3D - invalid beta " << argv[3] << "\n";
00334 cleanup(argv);
00335 exit (-1);
00336 }
00337 }
00338
00339 fdES = new fdEvolution_SLS(H_linear, q_saturated, beta);
00340 }
00341
00342 cleanup(argv);
00343 return fdES;
00344 }
00345
00346
00347
00348
00349 fdEvolution_T *EvaluatefdEvolution_T(ClientData clientData, Tcl_Interp *interp, TCL_Char *tclString)
00350 {
00351 int argc;
00352 TCL_Char **argv;
00353
00354
00355 if (Tcl_SplitList(interp, tclString, &argc, &argv) != TCL_OK) {
00356 exit (-1);
00357 }
00358
00359 fdEvolution_T *fdET = 0;
00360
00361
00362
00363 if ((strcmp(argv[0],"-Linear") == 0) ) {
00364
00365 double H_linear = 0.0;
00366
00367 if (argc >= 2) {
00368 if (Tcl_GetDouble(interp, argv[1], &H_linear) != TCL_OK) {
00369 opserr << "Warning: nDMaterial FDEP3D - invalid H_linear " << argv[1] << "\n";
00370 cleanup(argv);
00371 exit (-1);
00372 }
00373 }
00374
00375 fdET = new fdEvolution_TL(H_linear);
00376 }
00377
00378 cleanup(argv);
00379 return fdET;
00380 }
00381
00382