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 #include <stdlib.h>
00032 #include <string.h>
00033
00034 #include <Domain.h>
00035 #include <Node.h>
00036 #include <Matrix.h>
00037
00038 #include <SectionForceDeformation.h>
00039
00040 #include <NLBeamColumn2d.h>
00041 #include <NLBeamColumn3d.h>
00042
00043 #include <LobattoBeamIntegration.h>
00044 #include <ForceBeamColumn2d.h>
00045 #include <ForceBeamColumn3d.h>
00046
00047
00048
00049 #include <GaussLobattoQuadRule1d01.h>
00050 #include <TclModelBuilder.h>
00051
00052
00053
00054
00055
00056 static Domain *theTclModelBuilderDomain = 0;
00057 static TclModelBuilder *theTclModelBuilder =0;
00058
00059
00060
00061
00062 int
00063 TclModelBuilder_addNLBeamColumn(ClientData clientData, Tcl_Interp *interp,
00064 int inArgc, TCL_Char **inArgv,
00065 Domain *theDomain,
00066 TclModelBuilder *theBuilder)
00067
00068 {
00069 theTclModelBuilderDomain = theDomain;
00070 theTclModelBuilder = theBuilder;
00071
00072 int NDM, NDF;
00073
00074 NDM = theTclModelBuilder->getNDM();
00075 NDF = theTclModelBuilder->getNDF();
00076
00077
00078 char *List;
00079
00080 List = Tcl_Merge (inArgc, inArgv);
00081 if (List == 0)
00082 {
00083 opserr << "WARNING - TclModelBuilder_addFrameElement - problem merging list\n";
00084 return TCL_ERROR;
00085 }
00086
00087
00088
00089
00090 for (int i = 0; List[i] != '\0'; i++)
00091 {
00092 if ((List[i] == '{') || (List[i] == '}'))
00093 List[i] = ' ';
00094 }
00095
00096 int argc;
00097 TCL_Char **argv;
00098
00099 if (Tcl_SplitList(interp, List, &argc, &argv) != TCL_OK)
00100 {
00101 opserr << "WARNING - TclModelBuilder_addFrameElement - problem spliting list\n";
00102 return TCL_ERROR;
00103 }
00104
00105 Tcl_Free (List);
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115 if ((NDM == 2 && NDF == 3) || (NDM == 3 && NDF == 6)) {
00116
00117 int eleTag, iNode, jNode, numIntgrPts, transfTag;
00118 int secTag[10];
00119
00120 if (argc < 8) {
00121 opserr << "WARNING bad command - want: element nonlinearBeamColumn eleTag? iNode? jNode? numIntgrPts? secTag? transfTag? <-mass massDens?> <-iter nMaxLocIters? locToler?>\n";
00122 return TCL_ERROR;
00123 }
00124 int argi = 2;
00125 if (Tcl_GetInt(interp, argv[argi++], &eleTag) != TCL_OK) {
00126 opserr << "WARNING invalid eleTag: element nonlinearBeamColumn eleTag? iNode? jNode? numIntgrPts? secTag? transfTag? <-mass massDens?> <-iter nMaxLocIters? locToler?>\n";
00127 return TCL_ERROR;
00128 }
00129
00130 if (Tcl_GetInt(interp, argv[argi++], &iNode) != TCL_OK) {
00131 opserr << "WARNING invalid iNode: element nonlinearBeamColumn eleTag? iNode? jNode? numIntgrPts? secTag? transfTag? <-mass massDens?> <-iter nMaxLocIters? locToler?>\n";
00132 return TCL_ERROR;
00133 }
00134
00135 if (Tcl_GetInt(interp, argv[argi++], &jNode) != TCL_OK) {
00136 opserr << "WARNING invalid jNode: element nonlinearBeamColumn eleTag? iNode? jNode? numIntgrPts? secTag? transfTag? <-mass massDens?> <-iter nMaxLocIters? locToler?>\n";
00137 return TCL_ERROR;
00138 }
00139
00140 if (Tcl_GetInt(interp, argv[argi++], &numIntgrPts) != TCL_OK) {
00141 opserr << "WARNING invalid numIntgrPts: element nonlinearBeamColumn eleTag? iNode? jNode? numIntgrPts? secTag? transfTag? <-mass massDens?> <-iter nMaxLocIters? locToler?>\n";
00142 return TCL_ERROR;
00143 }
00144
00145 if (strcmp(argv[argi], "-sections") == 0) {
00146 argi++;
00147 if (argi+numIntgrPts > argc) {
00148 opserr << "WARNING insufficient number of section tags - element nonlinearBeamColumn eleTag? iNode? jNode? numIntgrPts? secTag? transfTag? <-mass massDens?> <-iter nMaxLocIters? locToler?>\n";
00149 return TCL_ERROR;
00150 }
00151 int section;
00152 for (int i = 0; i < numIntgrPts; i++) {
00153 if (Tcl_GetInt(interp, argv[argi+i], §ion) != TCL_OK) {
00154 opserr << "WARNING invalid secTag - element nonlinearBeamColumn eleTag? iNode? jNode? numIntgrPts? secTag? transfTag? <-mass massDens?> <-iter nMaxLocIters? locToler?>\n";
00155 return TCL_ERROR;
00156 }
00157 secTag[i] = section;
00158 }
00159 argi += numIntgrPts;
00160 }
00161
00162 else {
00163 int section;
00164 if (Tcl_GetInt(interp, argv[argi++], §ion) != TCL_OK) {
00165 opserr << "WARNING invalid secTag - element nonlinearBeamColumn eleTag? iNode? jNode? numIntgrPts? secTag? transfTag? <-mass massDens?> <-iter nMaxLocIters? locToler?>\n";
00166 return TCL_ERROR;
00167 }
00168 for (int i = 0; i < numIntgrPts; i++)
00169 secTag[i] = section;
00170 }
00171
00172 if (argi >= argc || Tcl_GetInt(interp, argv[argi++], &transfTag) != TCL_OK) {
00173 opserr << "WARNING invalid transfTag? - element nonlinearBeamColumn eleTag? iNode? jNode? numIntgrPts? secTag? transfTag? <-mass massDens?> <-iter nMaxLocIters? locToler?>\n";
00174 return TCL_ERROR;
00175 }
00176
00177
00178 double massDens = 0.0;
00179 int nMaxLocIters = 10;
00180 double locToler = 1e-08;
00181
00182 while (argi != argc) {
00183 if (strcmp(argv[argi],"-mass") == 0) {
00184
00185 argi++;
00186 if (argi == argc || Tcl_GetDouble(interp, argv[argi++], &massDens) != TCL_OK) {
00187 opserr << "WARNING invalid massDens - element nonlinearBeamColumn eleTag? iNode? jNode? numIntgrPts? secTag? transfTag? <-mass massDens?> <-iter nMaxLocIters? locToler?>\n";
00188 return TCL_ERROR;
00189 }
00190 }
00191
00192 else if (strcmp(argv[argi],"-iter") == 0) {
00193
00194 argi++;
00195 if (argi == argc || Tcl_GetInt(interp, argv[argi++], &nMaxLocIters) != TCL_OK) {
00196 opserr << "WARNING invalid nMaxLocIters - element nonlinearBeamColumn eleTag? iNode? jNode? numIntgrPts? secTag? transfTag? <-mass massDens?> <-iter nMaxLocIters? locToler?>\n";
00197 return TCL_ERROR;
00198 }
00199
00200
00201 if (argi == argc || Tcl_GetDouble(interp, argv[argi++], &locToler) != TCL_OK) {
00202 opserr << "WARNING invalid locToler - element nonlinearBeamColumn eleTag? iNode? jNode? numIntgrPts? secTag? transfTag? <-mass massDens?> <-iter nMaxLocIters? locToler?>\n";
00203 return TCL_ERROR;
00204 }
00205 }
00206 else {
00207 opserr << "WARNING bad command - element nonlinearBeamColumn eleTag? iNode? jNode? numIntgrPts? secTag? transfTag? <-mass massDens?> <-iter nMaxLocIters? locToler?>\n";
00208 opserr << "invalid: " << argv[argi] << endln;
00209 return TCL_ERROR;
00210 }
00211 }
00212
00213
00214
00215
00216
00217 SectionForceDeformation **sections = new SectionForceDeformation* [numIntgrPts];
00218
00219 if (!sections) {
00220 opserr << "WARNING TclElmtBuilder - addFrameElement - Insufficient memory to create sections\n";
00221 return TCL_ERROR;
00222 }
00223
00224 for (int j=0; j<numIntgrPts; j++) {
00225 SectionForceDeformation *theSection = theTclModelBuilder->getSection(secTag[j]);
00226
00227 if (theSection == 0) {
00228 opserr << "WARNING TclElmtBuilder - frameElement - no Section found with tag ";
00229 opserr << secTag[j] << endln;
00230 delete [] sections;
00231 return TCL_ERROR;
00232 }
00233
00234 sections[j] = theSection;
00235 }
00236
00237
00238
00239
00240
00241 Element *element = 0;
00242 if (NDM == 2) {
00243 CrdTransf2d *theCrdTransf = theTclModelBuilder->getCrdTransf2d(transfTag);
00244
00245 if (theCrdTransf == 0) {
00246 opserr << "WARNING TclElmtBuilder - frameElement - no geometric transformation found with tag ";
00247 opserr << transfTag << endln;
00248 return TCL_ERROR;
00249 }
00250
00251
00252
00253 LobattoBeamIntegration beamIntegr;
00254 element = new ForceBeamColumn2d(eleTag, iNode, jNode, numIntgrPts,
00255 sections, beamIntegr, *theCrdTransf,
00256 massDens, nMaxLocIters, locToler);
00257
00258 delete [] sections;
00259 }
00260 else {
00261 CrdTransf3d *theCrdTransf = theTclModelBuilder->getCrdTransf3d(transfTag);
00262
00263 if (theCrdTransf == 0) {
00264 opserr << "WARNING TclElmtBuilder - frameElement - no geometric transformation found with tag ";
00265 opserr << transfTag << endln;
00266 return TCL_ERROR;
00267 }
00268
00269
00270
00271
00272 LobattoBeamIntegration beamIntegr;
00273 element = new ForceBeamColumn3d(eleTag, iNode, jNode, numIntgrPts,
00274 sections, beamIntegr, *theCrdTransf,
00275 massDens, nMaxLocIters, locToler);
00276
00277 delete [] sections;
00278 }
00279
00280 if (element == 0) {
00281 opserr << "WARNING TclElmtBuilder - addFrameElement - ran out of memory to create element\n";
00282 return TCL_ERROR;
00283 }
00284
00285 if (theTclModelBuilderDomain->addElement(element) == false) {
00286 opserr << "WARNING TclElmtBuilder - addFrameElement - could not add element to domain ";
00287 opserr << eleTag << endln;
00288 return TCL_ERROR;
00289 }
00290
00291 }
00292 else {
00293 opserr << "WARNING NDM = " << NDM << " and NDF = " << NDF << "is imcompatible with available frame elements\n";
00294 return TCL_ERROR;
00295 }
00296
00297 Tcl_Free ((char *)argv);
00298
00299
00300
00301 return TCL_OK;
00302 }