00001 #include <TclModelBuilder.h>
00002 #include <string.h>
00003 #include <Vector.h>
00004
00005 #include "MultiLinearKp.h"
00006 #include "ExponReducing.h"
00007 #include "NullPlasticMaterial.h"
00008
00009 int TclMultiLinearCommand (ClientData clienData, Tcl_Interp *interp, int argc,
00010 TCL_Char **argv, TclModelBuilder *theTclBuilder)
00011 {
00012
00013 PlasticHardeningMaterial *theMaterial = 0;
00014
00015 if (strcmp(argv[1],"multiLinearKp") == 0)
00016 {
00017 int tag;
00018 int numPoints = (argc - 3)/2;
00019
00020 if(numPoints < 2)
00021 {
00022 opserr << "WARNING invalid uniaxialMaterial MultilinearUniaxial tag" << endln;
00023 opserr << "Minimum of 2 points are required\n";
00024 return TCL_ERROR;
00025 }
00026
00027 if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK)
00028 {
00029 opserr << "WARNING invalid uniaxialMaterial MultilinearUniaxial tag" << endln;
00030 return TCL_ERROR;
00031 }
00032
00033 Vector defo(numPoints);
00034 Vector kp(numPoints);
00035
00036 double temp;
00037 int indx=3, j1, j2;
00038
00039 for (j1 = 0; j1 < numPoints; j1++)
00040 {
00041 if (Tcl_GetDouble(interp, argv[indx], &temp) != TCL_OK)
00042 {
00043 opserr << "WARNING invalid input, data " << temp << '\n';
00044 opserr << "MultilinearUniaxial material: " << tag << endln;
00045 return TCL_ERROR;
00046 }
00047
00048 defo(j1) = temp;
00049 indx++;
00050 }
00051
00052 for (j2 = 0; j2 < numPoints; j2++)
00053 {
00054 if (Tcl_GetDouble(interp, argv[indx], &temp) != TCL_OK)
00055 {
00056 opserr << "WARNING invalid input, data " << temp << '\n';
00057 opserr << "MultilinearUniaxial material: " << tag << endln;
00058 return TCL_ERROR;
00059 }
00060
00061 kp(j2) = temp;
00062 indx++;
00063 }
00064
00065
00066 theMaterial = new MultiLinearKp(tag, defo, kp);
00067 }
00068
00069
00070
00071 if (theMaterial == 0) {
00072 opserr << "WARNING: ran out of memory creating uniaxialMaterial\n";
00073 opserr << argv[1] << endln;
00074 return TCL_ERROR;
00075 }
00076
00077
00078 if (theTclBuilder->addPlasticMaterial(*theMaterial) < 0)
00079 {
00080 opserr << "WARNING could not add uniaxialMaterial to the domain\n";
00081 opserr << *theMaterial << endln;
00082 delete theMaterial;
00083 return TCL_ERROR;
00084 }
00085
00086
00087 return TCL_OK;
00088 }
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131 int TclExponReducingCommand(ClientData clienData, Tcl_Interp *interp, int argc,
00132 TCL_Char **argv, TclModelBuilder *theTclBuilder)
00133 {
00134 if(argc < 5)
00135 {
00136 opserr << "TclExponReducingCommand - argc != 5 \n";
00137 return TCL_ERROR;
00138 }
00139
00140 PlasticHardeningMaterial *theMaterial = 0;
00141
00142 int tag;
00143 double arg1, arg2, arg3;
00144
00145
00146
00147
00148 if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK)
00149 {
00150 opserr << "WARNING invalid PlaticHardening exponReducing tag" << endln;
00151 return TCL_ERROR;
00152 }
00153
00154 if (Tcl_GetDouble(interp, argv[3], &arg1) != TCL_OK)
00155 {
00156 opserr << "WARNING invalid double PlaticHardening exponReducing" << endln;
00157 return TCL_ERROR;
00158 }
00159
00160 if (Tcl_GetDouble(interp, argv[4], &arg2) != TCL_OK)
00161 {
00162 opserr << "WARNING invalid double PlaticHardening exponReducing" << endln;
00163 return TCL_ERROR;
00164 }
00165
00166 if(argc == 6)
00167 {
00168 if (Tcl_GetDouble(interp, argv[5], &arg3) != TCL_OK)
00169 {
00170 opserr << "WARNING invalid double PlaticHardening exponReducing" << endln;
00171 return TCL_ERROR;
00172 }
00173
00174 theMaterial = new ExponReducing(tag, arg1, arg2, arg3);
00175
00176 }
00177 else
00178 theMaterial = new ExponReducing(tag, arg1, arg2);
00179
00180 if (theTclBuilder->addPlasticMaterial(*theMaterial) < 0)
00181 {
00182 opserr << "WARNING could not add uniaxialMaterial to the domain\n";
00183 opserr << *theMaterial << endln;
00184 delete theMaterial;
00185 return TCL_ERROR;
00186 }
00187
00188
00189 return TCL_OK;
00190 }
00191
00192
00193 int TclNullPlasticMaterialCommand(ClientData clienData, Tcl_Interp *interp, int argc,
00194 TCL_Char **argv, TclModelBuilder *theTclBuilder)
00195 {
00196 PlasticHardeningMaterial *theMaterial = 0;
00197
00198 int tag;
00199
00200 if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK)
00201 {
00202 opserr << "WARNING invalid PlaticHardening quadrReducing tag" << endln;
00203 return TCL_ERROR;
00204 }
00205
00206 theMaterial = new NullPlasticMaterial(tag);
00207 if (theTclBuilder->addPlasticMaterial(*theMaterial) < 0)
00208 {
00209 opserr << "WARNING could not add uniaxialMaterial to the domain\n";
00210 opserr << *theMaterial << endln;
00211 delete theMaterial;
00212 return TCL_ERROR;
00213 }
00214
00215 return TCL_OK;
00216 }
00217
00219
00220
00221
00222
00223
00224 int
00225 TclModelBuilderPlasticMaterialCommand (ClientData clientData, Tcl_Interp *interp, int argc,
00226 TCL_Char **argv, TclModelBuilder *theTclBuilder)
00227 {
00228
00229 if (strcmp(argv[1],"multiLinearKp") == 0)
00230 {
00231 return TclMultiLinearCommand(clientData, interp, argc, argv, theTclBuilder);
00232 }
00233
00234
00235
00236
00237 else if(strcmp(argv[1],"exponReducing") == 0)
00238 {
00239 return TclExponReducingCommand(clientData, interp, argc, argv, theTclBuilder);
00240 }
00241 else if(strcmp(argv[1],"null")==0)
00242 {
00243 return TclNullPlasticMaterialCommand(clientData, interp, argc, argv, theTclBuilder);
00244 }
00245 else
00246 {
00247 opserr << "Unknown PlasticMaterial: \nValid types: null, multiLinearKp, "
00248 << "quadrReducing, exponReducing \n";
00249
00250 return TCL_ERROR;
00251 }
00252
00253 }
00254
00255
00257
00258
00259
00260
00261