00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include <stdlib.h>
00014
00015 #include <string.h>
00016
00017 #include <Domain.h>
00018
00019
00020
00021 #include <Twenty_Node_Brick.h>
00022
00023
00024
00025 #include <TclModelBuilder.h>
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 extern void printCommand(int argc, TCL_Char **argv);
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 int
00054
00055 TclModelBuilder_addTwentyNodeBrick(ClientData clientData, Tcl_Interp *interp,
00056
00057 int argc,
00058
00059 TCL_Char **argv,
00060
00061 Domain*theTclDomain,
00062
00063 TclModelBuilder *theTclBuilder)
00064
00065 {
00066
00067
00068
00069 if (theTclBuilder == 0) {
00070
00071 opserr << "WARNING builder has been destroyed\n";
00072
00073 return TCL_ERROR;
00074
00075 }
00076
00077
00078
00079 if (theTclBuilder->getNDM() != 3 ) {
00080
00081 opserr << "WARNING -- model dimensions and/or nodal DOF not compatible with 20NodeBrick element\n";
00082
00083 return TCL_ERROR;
00084
00085 }
00086
00087
00088
00089
00090
00091 int argStart = 2;
00092
00093
00094
00095 if ((argc-argStart) < 22) {
00096
00097 opserr << "WARNING insufficient arguments\n";
00098
00099 printCommand(argc, argv);
00100
00101 opserr << "Want: element 20NodeBrick eleTag? N1? N2? N3? N4? N5? N6? N7? N8? N9? N10? N11? N12? N13? N14? N15? N16? N17? N18? N19? N20? matTag? <b1? b2? b3?>\n";
00102
00103 return TCL_ERROR;
00104
00105 }
00106
00107
00108
00109
00110
00111 int brickId, Nod[20], matID;
00112
00113 double b1 = 0.0;
00114
00115 double b2 = 0.0;
00116
00117 double b3 = 0.0;
00118
00119
00120
00121 if (Tcl_GetInt(interp, argv[argStart], &brickId) != TCL_OK) {
00122
00123 opserr << "WARNING invalid 20NodeBrick eleTag" << endln;
00124
00125 return TCL_ERROR;
00126
00127 }
00128
00129
00130
00131 for (int i=0; i<20; i++)
00132
00133 if (Tcl_GetInt(interp, argv[1+argStart+i], &(Nod[i])) != TCL_OK) {
00134
00135 opserr << "WARNING invalid Node number\n";
00136
00137 opserr << "20NodeBrick element: " << brickId << endln;
00138
00139 return TCL_ERROR;
00140
00141 }
00142
00143
00144
00145 if (Tcl_GetInt(interp, argv[21+argStart], &matID) != TCL_OK) {
00146
00147 opserr << "WARNING invalid matID\n";
00148
00149 opserr << "20NodeBrick element: " << brickId << endln;
00150
00151 return TCL_ERROR;
00152
00153 }
00154
00155
00156
00157 if ((argc-argStart) >= 23) {
00158
00159 if (Tcl_GetDouble(interp, argv[22+argStart], &b1) != TCL_OK) {
00160
00161 opserr << "WARNING invalid b1\n";
00162
00163 opserr << "20NodeBrick element: " << brickId << endln;
00164
00165 return TCL_ERROR;
00166
00167 }
00168
00169 }
00170
00171 if ((argc-argStart) >= 24) {
00172
00173 if (Tcl_GetDouble(interp, argv[23+argStart], &b2) != TCL_OK) {
00174
00175 opserr << "WARNING invalid b2\n";
00176
00177 opserr << "20NodeBrick element: " << brickId << endln;
00178
00179 return TCL_ERROR;
00180
00181 }
00182
00183 }
00184
00185 if ((argc-argStart) >= 25) {
00186
00187 if (Tcl_GetDouble(interp, argv[24+argStart], &b3) != TCL_OK) {
00188
00189 opserr << "WARNING invalid b3\n";
00190
00191 opserr << "20NodeBrick element: " << brickId << endln;
00192
00193 return TCL_ERROR;
00194
00195 }
00196
00197 }
00198
00199
00200
00201 NDMaterial *theMaterial = theTclBuilder->getNDMaterial(matID);
00202
00203
00204
00205 if (theMaterial == 0) {
00206
00207 opserr << "WARNING material not found\n";
00208
00209 opserr << "Material: " << matID;
00210
00211 opserr << "\20NodeBrick element: " << brickId << endln;
00212
00213 return TCL_ERROR;
00214
00215 }
00216
00217
00218
00219
00220
00221 Twenty_Node_Brick *theTwentyNodeBrick =
00222
00223 new Twenty_Node_Brick(brickId,Nod[0],Nod[1],Nod[2],Nod[3],Nod[4],Nod[5],Nod[6],Nod[7],
00224
00225 Nod[8],Nod[9],Nod[10],Nod[11],Nod[12],Nod[13],Nod[14],
00226
00227 Nod[15],Nod[16],Nod[17],Nod[18],Nod[19],
00228
00229 *theMaterial, b1, b2, b3);
00230
00231 if (theTwentyNodeBrick == 0) {
00232
00233 opserr << "WARNING ran out of memory creating element\n";
00234
00235 opserr << "20NodeBrick element: " << brickId << endln;
00236
00237 return TCL_ERROR;
00238
00239 }
00240
00241 if (theTclDomain->addElement(theTwentyNodeBrick) == false) {
00242
00243 opserr << "WARNING could not add element to the domain\n";
00244
00245 opserr << "20NodeBrick element: " << brickId << endln;
00246
00247 delete theTwentyNodeBrick;
00248
00249 return TCL_ERROR;
00250
00251 }
00252
00253
00254
00255
00256
00257 return TCL_OK;
00258
00259 }
00260
00261
00262