Rev 36 | Go to most recent revision | Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 2 | fmk | 1 | /* ****************************************************************** ** |
| 2 | ** OpenSees - Open System for Earthquake Engineering Simulation ** |
||
| 3 | ** Pacific Earthquake Engineering Research Center ** |
||
| 4 | ** ** |
||
| 5 | ** ** |
||
| 6 | ** (C) Copyright 1999, The Regents of the University of California ** |
||
| 7 | ** All Rights Reserved. ** |
||
| 8 | ** ** |
||
| 9 | ** Commercial use of this program without express permission of the ** |
||
| 10 | ** University of California, Berkeley, is strictly prohibited. See ** |
||
| 11 | ** file 'COPYRIGHT' in main directory for information on usage and ** |
||
| 12 | ** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. ** |
||
| 13 | ** ** |
||
| 14 | ** Developed by: ** |
||
| 15 | ** Frank McKenna (fmckenna@ce.berkeley.edu) ** |
||
| 16 | ** Gregory L. Fenves (fenves@ce.berkeley.edu) ** |
||
| 17 | ** Filip C. Filippou (filippou@ce.berkeley.edu) ** |
||
| 18 | ** ** |
||
| 19 | ** ****************************************************************** */ |
||
| 20 | |||
| 21 | // $Revision: 1.1.1.1 $ |
||
| 22 | // $Date: 2000-09-15 08:23:19 $ |
||
| 23 | // $Source: /usr/local/cvs/OpenSees/SRC/element/TclElementCommands.cpp,v $ |
||
| 24 | |||
| 25 | |||
| 26 | // File: ~/element/TclElementCommands.C |
||
| 27 | // |
||
| 28 | // Written: fmk |
||
| 29 | // Created: 07/99 |
||
| 30 | // Revision: A |
||
| 31 | // |
||
| 32 | // Description: This file contains the implementation of the TclElementCommands. |
||
| 33 | // The file contains the routine TclElementCommands which is invoked by the |
||
| 34 | // TclModelBuilder. |
||
| 35 | // |
||
| 36 | // What: "@(#) TclModelBuilder.C, revA" |
||
| 37 | |||
| 38 | #include <stdlib.h> |
||
| 39 | #include <string.h> |
||
| 40 | #include <iostream.h> |
||
| 41 | #include <Domain.h> |
||
| 42 | |||
| 43 | #include <fElmt02.h> |
||
| 44 | #include <Truss.h> |
||
| 45 | #include <TrussSection.h> |
||
| 46 | #include <ElasticBeam2d.h> |
||
| 47 | #include <beam2d02.h> |
||
| 48 | #include <ElasticBeam3d.h> |
||
| 49 | |||
| 50 | #include <CrdTransf2d.h> |
||
| 51 | #include <CrdTransf3d.h> |
||
| 52 | |||
| 53 | #include <TclModelBuilder.h> |
||
| 54 | |||
| 55 | // |
||
| 56 | // SOME STATIC POINTERS USED IN THE FUNCTIONS INVOKED BY THE INTERPRETER |
||
| 57 | // |
||
| 58 | |||
| 59 | extern void printCommand(int argc, char **argv); |
||
| 60 | |||
| 61 | // |
||
| 62 | // THE PROTOTYPES OF THE FUNCTIONS INVOKED BY THE INTERPRETER |
||
| 63 | // |
||
| 64 | |||
| 65 | extern int |
||
| 66 | TclModelBuilder_addFeapTruss(ClientData clientData, Tcl_Interp *interp, int argc, |
||
| 67 | char **argv, Domain*, TclModelBuilder *, int argStart); |
||
| 68 | |||
| 69 | extern int |
||
| 70 | TclModelBuilder_addTruss(ClientData clientData, Tcl_Interp *interp, int argc, |
||
| 71 | char **argv, Domain*, TclModelBuilder *, int argStart); |
||
| 72 | |||
| 73 | int |
||
| 74 | TclModelBuilder_addElasticBeam(ClientData clientData, Tcl_Interp *interp, int argc, |
||
| 75 | char **argv, Domain*, TclModelBuilder *, int argStart); |
||
| 76 | |||
| 77 | // GLF |
||
| 78 | extern int |
||
| 79 | TclModelBuilder_addZeroLength(ClientData, Tcl_Interp *, int, char **, |
||
| 80 | Domain*, TclModelBuilder *); |
||
| 81 | |||
| 82 | // REMO |
||
| 83 | extern int |
||
| 84 | TclModelBuilder_addFrameElement(ClientData, Tcl_Interp *, int, char **, |
||
| 85 | Domain*, TclModelBuilder *); |
||
| 86 | |||
| 87 | // MHS |
||
| 88 | extern int |
||
| 89 | TclModelBuilder_addBeamWithHinges(ClientData, Tcl_Interp *, int, char **, |
||
| 90 | Domain*, TclModelBuilder *); |
||
| 91 | extern int |
||
| 92 | TclModelBuilder_addFourNodeQuad(ClientData, Tcl_Interp *, int, char **, |
||
| 93 | Domain*, TclModelBuilder *); |
||
| 94 | |||
| 95 | int |
||
| 96 | TclModelBuilderElementCommand(ClientData clientData, Tcl_Interp *interp, |
||
| 97 | int argc, char **argv, |
||
| 98 | Domain *theTclDomain, TclModelBuilder *theTclBuilder) |
||
| 99 | { |
||
| 100 | // ensure the destructor has not been called - |
||
| 101 | if (theTclBuilder == 0) { |
||
| 102 | cerr << "WARNING builder has been destroyed\n"; |
||
| 103 | return TCL_ERROR; |
||
| 104 | } |
||
| 105 | |||
| 106 | // check at least two arguments so don't segemnt fault on strcmp |
||
| 107 | if (argc < 2) { |
||
| 108 | cerr << "WARNING need to specify an element type\n"; |
||
| 109 | cerr << "Want: element eleType <specific element args>\n"; |
||
| 110 | cerr << "Valid types: truss, elasticBeamColumn, nonlinearBeamColumn\n"; |
||
| 111 | return TCL_ERROR; |
||
| 112 | } |
||
| 113 | |||
| 114 | if (strcmp(argv[1],"fTruss") == 0) { |
||
| 115 | int eleArgStart = 1; |
||
| 116 | int result = TclModelBuilder_addFeapTruss(clientData, interp, argc, argv, |
||
| 117 | theTclDomain, theTclBuilder, eleArgStart); |
||
| 118 | return result; |
||
| 119 | } else if (strcmp(argv[1],"truss") == 0) { |
||
| 120 | int eleArgStart = 1; |
||
| 121 | int result = TclModelBuilder_addTruss(clientData, interp, argc, argv, |
||
| 122 | theTclDomain, theTclBuilder, eleArgStart); |
||
| 123 | return result; |
||
| 124 | }else if (strcmp(argv[1],"elasticBeamColumn") == 0) { |
||
| 125 | int eleArgStart = 1; |
||
| 126 | int result = TclModelBuilder_addElasticBeam(clientData, interp, argc, argv, |
||
| 127 | theTclDomain, theTclBuilder, eleArgStart); |
||
| 128 | return result; |
||
| 129 | } else if (strcmp(argv[1],"nonlinearBeamColumn") == 0) { |
||
| 130 | int result = TclModelBuilder_addFrameElement(clientData, interp, argc, argv, |
||
| 131 | theTclDomain, theTclBuilder); |
||
| 132 | return result; |
||
| 133 | } else if (strcmp(argv[1],"beamWithHinges") == 0) { |
||
| 134 | int result = TclModelBuilder_addBeamWithHinges(clientData, interp, argc, argv, |
||
| 135 | theTclDomain, theTclBuilder); |
||
| 136 | return result; |
||
| 137 | } else if (strcmp(argv[1],"quad") == 0) { |
||
| 138 | int result = TclModelBuilder_addFourNodeQuad(clientData, interp, argc, argv, |
||
| 139 | theTclDomain, theTclBuilder); |
||
| 140 | return result; |
||
| 141 | } else if (strcmp(argv[1],"zeroLength") == 0) { |
||
| 142 | int result = TclModelBuilder_addZeroLength(clientData, interp, argc, argv, |
||
| 143 | theTclDomain, theTclBuilder); |
||
| 144 | return result; |
||
| 145 | |||
| 146 | } else { |
||
| 147 | cerr << "WARNING unknown element type: " << argv[1]; |
||
| 148 | cerr << "Valid types: truss, elasticBeamColumn, nonlinearBeamColumn, beamWithHinges, zeroLength\n"; |
||
| 149 | return TCL_ERROR; |
||
| 150 | } |
||
| 151 | } |
||
| 152 | |||
| 153 | |||
| 154 | |||
| 155 | // |
||
| 156 | // command for the beam2d and beam3d elements |
||
| 157 | // |
||
| 158 | |||
| 159 | |||
| 160 | int |
||
| 161 | TclModelBuilder_addElasticBeam(ClientData clientData, Tcl_Interp *interp, int argc, |
||
| 162 | char **argv, Domain *theTclDomain, TclModelBuilder *theTclBuilder, |
||
| 163 | int eleArgStart) |
||
| 164 | { |
||
| 165 | // ensure the destructor has not been called - |
||
| 166 | if (theTclBuilder == 0) { |
||
| 167 | cerr << "WARNING builder has been destroyed - elasticBeamColumn \n"; |
||
| 168 | return TCL_ERROR; |
||
| 169 | } |
||
| 170 | |||
| 171 | int ndm = theTclBuilder->getNDM(); |
||
| 172 | int ndf = theTclBuilder->getNDF(); |
||
| 173 | |||
| 174 | Element *theBeam = 0; |
||
| 175 | |||
| 176 | if (ndm == 2) { |
||
| 177 | // check plane frame problem has 3 dof per node |
||
| 178 | if (ndf != 3) { |
||
| 179 | cerr << "WARNING invalid ndf: " << ndf; |
||
| 180 | cerr << ", for plane problem need 3 - elasticBeamColumn \n"; |
||
| 181 | return TCL_ERROR; |
||
| 182 | } |
||
| 183 | |||
| 184 | // check the number of arguments |
||
| 185 | if ((argc-eleArgStart) < 8) { |
||
| 186 | cerr << "WARNING bad command - want: elasticBeamColumn beamId iNode jNode A E I transTag\n"; |
||
| 187 | printCommand(argc, argv); |
||
| 188 | return TCL_ERROR; |
||
| 189 | } |
||
| 190 | |||
| 191 | // get the id, end nodes, and section properties |
||
| 192 | int beamId, iNode, jNode, transTag; |
||
| 193 | double A,E,I; |
||
| 194 | if (Tcl_GetInt(interp, argv[1+eleArgStart], &beamId) != TCL_OK) { |
||
| 195 | cerr << "WARNING invalid beamId: " << argv[1+eleArgStart]; |
||
| 196 | cerr << " - elasticBeamColumn beamId iNode jNode A E I\n"; |
||
| 197 | return TCL_ERROR; |
||
| 198 | } |
||
| 199 | if (Tcl_GetInt(interp, argv[2+eleArgStart], &iNode) != TCL_OK) { |
||
| 200 | cerr << "WARNING invalid iNode - elasticBeamColumn " << beamId << " iNode jNode A E I\n"; |
||
| 201 | return TCL_ERROR; |
||
| 202 | } |
||
| 203 | if (Tcl_GetInt(interp, argv[3+eleArgStart], &jNode) != TCL_OK) { |
||
| 204 | cerr << "WARNING invalid jNode - elasticBeamColumn " << beamId << " iNode jNode A E I\n"; |
||
| 205 | return TCL_ERROR; |
||
| 206 | } |
||
| 207 | |||
| 208 | if (Tcl_GetDouble(interp, argv[4+eleArgStart], &A) != TCL_OK) { |
||
| 209 | cerr << "WARNING invalid A - elasticBeamColumn " << beamId << " iNode jNode A E I\n"; |
||
| 210 | return TCL_ERROR; |
||
| 211 | } |
||
| 212 | if (Tcl_GetDouble(interp, argv[5+eleArgStart], &E) != TCL_OK) { |
||
| 213 | cerr << "WARNING invalid E - elasticBeam " << beamId << " iNode jNode A E I\n"; |
||
| 214 | return TCL_ERROR; |
||
| 215 | } |
||
| 216 | |||
| 217 | if (Tcl_GetDouble(interp, argv[6+eleArgStart], &I) != TCL_OK) { |
||
| 218 | cerr << "WARNING invalid I - elasticBeamColumn " << beamId << " iNode jNode A E I\n"; |
||
| 219 | return TCL_ERROR; |
||
| 220 | } |
||
| 221 | if (Tcl_GetInt(interp, argv[7+eleArgStart], &transTag) != TCL_OK) { |
||
| 222 | cerr << "WARNING invalid transTag - elasticBeamColumn " << beamId << " iNode jNode A E I\n"; |
||
| 223 | return TCL_ERROR; |
||
| 224 | } |
||
| 225 | |||
| 226 | CrdTransf2d *theTrans = theTclBuilder->getCrdTransf2d(transTag); |
||
| 227 | |||
| 228 | if (theTrans == 0) { |
||
| 229 | cerr << "WARNING transformation object not found - elasticBeamColumn " << beamId; |
||
| 230 | return TCL_ERROR; |
||
| 231 | } |
||
| 232 | |||
| 233 | // now create the beam and add it to the Domain |
||
| 234 | theBeam = new ElasticBeam2d (beamId,A,E,I,iNode,jNode, *theTrans); |
||
| 235 | |||
| 236 | if (theBeam == 0) { |
||
| 237 | cerr << "WARNING ran out of memory creating beam - elasticBeamColumn "; |
||
| 238 | cerr << beamId << " iNode jNode A E I\n"; |
||
| 239 | return TCL_ERROR; |
||
| 240 | } |
||
| 241 | } |
||
| 242 | |||
| 243 | else if (ndm == 3) { |
||
| 244 | // check space frame problem has 6 dof per node |
||
| 245 | if (ndf != 6) { |
||
| 246 | cerr << "WARNING invalid ndof: " << ndf; |
||
| 247 | cerr << ", for 3d problem need 6 - elasticBeamColumn \n"; |
||
| 248 | return TCL_ERROR; |
||
| 249 | } |
||
| 250 | |||
| 251 | // check the number of arguments |
||
| 252 | if ((argc-eleArgStart) < 11) { |
||
| 253 | cerr << "WARNING bad command - want: elasticBeamColumn beamId iNode jNode"; |
||
| 254 | cerr << " A E G Jx Iy Iz transTag" << endl; |
||
| 255 | printCommand(argc, argv); |
||
| 256 | return TCL_ERROR; |
||
| 257 | } |
||
| 258 | |||
| 259 | // get the id, end nodes, and section properties |
||
| 260 | int beamId, iNode, jNode, transTag; |
||
| 261 | double A,E,G,Jx,Iy,Iz; |
||
| 262 | if (Tcl_GetInt(interp, argv[1+eleArgStart], &beamId) != TCL_OK) { |
||
| 263 | cerr << "WARNING invalid beamId: " << argv[1+eleArgStart]; |
||
| 264 | cerr << " - elasticBeamColumn beamId iNode jNode A E G Jx Iy Iz\n "; |
||
| 265 | return TCL_ERROR; |
||
| 266 | } |
||
| 267 | if (Tcl_GetInt(interp, argv[2+eleArgStart], &iNode) != TCL_OK) { |
||
| 268 | cerr << "WARNING invalid iNode - elasticBeamColumn " << beamId; |
||
| 269 | cerr << " iNode jNode A E G Jx Iy Iz\n"; |
||
| 270 | return TCL_ERROR; |
||
| 271 | } |
||
| 272 | if (Tcl_GetInt(interp, argv[3+eleArgStart], &jNode) != TCL_OK) { |
||
| 273 | cerr << "WARNING invalid jNode - elasticBeamColumn " << beamId; |
||
| 274 | cerr << " iNode jNode A E G Jx Iy Iz\n"; |
||
| 275 | return TCL_ERROR; |
||
| 276 | } |
||
| 277 | |||
| 278 | if (Tcl_GetDouble(interp, argv[4+eleArgStart], &A) != TCL_OK) { |
||
| 279 | cerr << "WARNING invalid A - elasticBeamColumn " << beamId; |
||
| 280 | cerr << " iNode jNode A E G Jx Iy Iz\n"; |
||
| 281 | return TCL_ERROR; |
||
| 282 | } |
||
| 283 | if (Tcl_GetDouble(interp, argv[5+eleArgStart], &E) != TCL_OK) { |
||
| 284 | cerr << "WARNING invalid E - elasticBeamColumn " << beamId; |
||
| 285 | cerr << " iNode jNode A E G Jx Iy Iz\n"; |
||
| 286 | return TCL_ERROR; |
||
| 287 | } |
||
| 288 | if (Tcl_GetDouble(interp, argv[6+eleArgStart], &G) != TCL_OK) { |
||
| 289 | cerr << "WARNING invalid G - elasticBeamColumn " << beamId; |
||
| 290 | cerr << " iNode jNode A E G Jx Iy Iz\n"; |
||
| 291 | return TCL_ERROR; |
||
| 292 | } |
||
| 293 | if (Tcl_GetDouble(interp, argv[7+eleArgStart], &Jx) != TCL_OK) { |
||
| 294 | cerr << "WARNING invalid Jx - elasticBeamColumn " << beamId; |
||
| 295 | cerr << " iNode jNode A E G Jx Iy Iz\n"; |
||
| 296 | return TCL_ERROR; |
||
| 297 | } |
||
| 298 | if (Tcl_GetDouble(interp, argv[8+eleArgStart], &Iy) != TCL_OK) { |
||
| 299 | cerr << "WARNING invalid Iy - elasticBeamColumn " << beamId; |
||
| 300 | cerr << " iNode jNode A E G Jx Iy Iz\n"; |
||
| 301 | return TCL_ERROR; |
||
| 302 | } |
||
| 303 | if (Tcl_GetDouble(interp, argv[9+eleArgStart], &Iz) != TCL_OK) { |
||
| 304 | cerr << "WARNING invalid Iz - elasticBeamColumn " << beamId; |
||
| 305 | cerr << " iNode jNode A E G Jx Iy Iz\n"; |
||
| 306 | return TCL_ERROR; |
||
| 307 | } |
||
| 308 | if (Tcl_GetInt(interp, argv[10+eleArgStart], &transTag) != TCL_OK) { |
||
| 309 | cerr << "WARNING invalid transTag - elasticBeamColumn " << beamId; |
||
| 310 | cerr << " iNode jNode A E G Jx Iy Iz\n"; |
||
| 311 | return TCL_ERROR; |
||
| 312 | } |
||
| 313 | |||
| 314 | CrdTransf3d *theTrans = theTclBuilder->getCrdTransf3d(transTag); |
||
| 315 | |||
| 316 | if (theTrans == 0) { |
||
| 317 | cerr << "WARNING transformation object not found - elasticBeamColumn " << beamId; |
||
| 318 | return TCL_ERROR; |
||
| 319 | } |
||
| 320 | |||
| 321 | // now create the beam and add it to the Domain |
||
| 322 | theBeam = new ElasticBeam3d (beamId,A,E,G,Jx,Iy,Iz,iNode,jNode, *theTrans); |
||
| 323 | |||
| 324 | if (theBeam == 0) { |
||
| 325 | cerr << "WARNING ran out of memory creating beam - elasticBeamColumn "; |
||
| 326 | cerr << beamId << " iNode jNode A E G Jx Iy Iz\n"; |
||
| 327 | return TCL_ERROR; |
||
| 328 | } |
||
| 329 | |||
| 330 | } |
||
| 331 | |||
| 332 | else { |
||
| 333 | cerr << "WARNING elasticBeamColumn command only works when ndm is 2 or 3, ndm: "; |
||
| 334 | cerr << ndm << endl; |
||
| 335 | return TCL_ERROR; |
||
| 336 | } |
||
| 337 | |||
| 338 | // now add the beam to the domain |
||
| 339 | if (theTclDomain->addElement(theBeam) == false) { |
||
| 340 | cerr << "WARNING TclModelBuilder - addBeam - could not add beam to domain "; |
||
| 341 | cerr << *theBeam; |
||
| 342 | delete theBeam; // clean up the memory to avoid leaks |
||
| 343 | return TCL_ERROR; |
||
| 344 | } |
||
| 345 | |||
| 346 | // if get here we have sucessfully created the node and added it to the domain |
||
| 347 | return TCL_OK; |
||
| 348 | } |