TclDispBeamColumnCommand.cpp

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 1999, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** ****************************************************************** */
00020                                                                         
00021 // $Revision: 1.7 $
00022 // $Date: 2006/09/26 18:38:29 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/element/dispBeamColumn/TclDispBeamColumnCommand.cpp,v $
00024                                                                         
00025 // Written: MHS
00026 // Created: Feb 2001
00027 //
00028 // Description: This file contains the implementation of the 
00029 // TclModelBuilder_addDispBeamColumn() command. 
00030 
00031 #include <stdlib.h>
00032 #include <string.h>
00033 #include <Domain.h>
00034 
00035 #include <TclModelBuilder.h>
00036 
00037 #include <DispBeamColumn2d.h>
00038 #include <DispBeamColumn3d.h>
00039 
00040 #include <LobattoBeamIntegration.h>
00041 #include <LegendreBeamIntegration.h>
00042 #include <RadauBeamIntegration.h>
00043 #include <NewtonCotesBeamIntegration.h>
00044 #include <UserDefinedBeamIntegration.h>
00045 
00046 #include <HingeMidpointBeamIntegration.h>
00047 #include <HingeEndpointBeamIntegration.h>
00048 #include <HingeRadauBeamIntegration.h>
00049 #include <HingeRadauTwoBeamIntegration.h>
00050 #include <UserDefinedHingeIntegration.h>
00051 #include <DistHingeIntegration.h>
00052 
00053 //#include <TrapezoidalBeamIntegration.h>
00054 //#include <FixedLocationBeamIntegration.h>
00055 //#include <LowOrderBeamIntegration.h>
00056 //#include <MidDistanceBeamIntegration.h>
00057 
00058 #include <ElasticSection2d.h>
00059 #include <ElasticSection3d.h>
00060 
00061 extern void printCommand(int argc, TCL_Char **argv);
00062 
00063 int
00064 TclModelBuilder_addDispBeamColumn(ClientData clientData, Tcl_Interp *interp,  
00065                                    int inArgc, 
00066                                    TCL_Char **inArgv, 
00067                                    Domain*theTclDomain,
00068                                    TclModelBuilder *theTclBuilder)
00069 {
00070   // ensure the destructor has not been called - 
00071   if (theTclBuilder == 0) {
00072     opserr << "WARNING builder has been destroyed\n";    
00073     return TCL_ERROR;
00074   }
00075   
00076   int ndm = theTclBuilder->getNDM();
00077   int ndf = theTclBuilder->getNDF();
00078   
00079   int ok = 0;
00080   if (ndm == 2 && ndf == 3)
00081     ok = 1;
00082   if (ndm == 3 && ndf == 6)
00083     ok = 1;
00084   
00085   if (ok == 0) {
00086     opserr << "WARNING -- NDM = " << ndm << " and NDF = " << ndf
00087          << " not compatible with dispBeamColumn element" << endln;
00088     return TCL_ERROR;
00089   }
00090   
00091   // split possible lists present in argv
00092   char *List;
00093 
00094   List = Tcl_Merge (inArgc, inArgv);
00095   if (List == 0) {
00096     opserr << "WARNING - TclModelBuilder_addDispBeamColumn - problem merging list\n";
00097     return TCL_ERROR;
00098   }
00099 
00100   //  opserr << "List :" << List << endln;
00101 
00102   // remove braces from list
00103   for (int i = 0; List[i] != '\0'; i++) {
00104     if ((List[i] == '{')  ||  (List[i] == '}'))
00105       List[i] = ' ';
00106   }
00107   
00108   int argc;
00109   TCL_Char **argv;
00110        
00111   if (Tcl_SplitList(interp, List, &argc, &argv) != TCL_OK) {
00112     opserr <<  "WARNING - TclModelBuilder_addDispBeamColumn - problem spliting list\n";
00113     return TCL_ERROR;
00114   }
00115       
00116   Tcl_Free (List);
00117 
00118 
00119   if (argc < 6) {
00120     opserr << "WARNING insufficient arguments\n";
00121     printCommand(argc, argv);
00122     opserr << "Want: element dispBeamColumn eleTag? iNode? jNode? transfTag? ...\n";
00123     return TCL_ERROR;
00124   }
00125 
00126   int eleTag, iNode, jNode, transfTag;
00127   CrdTransf2d *theTransf2d = 0;
00128   CrdTransf3d *theTransf3d = 0;
00129   Element *theElement = 0;
00130 
00131 
00132   if (Tcl_GetInt(interp, argv[2], &eleTag) != TCL_OK) {
00133     opserr << "WARNING invalid dispBeamColumn eleTag" << endln;
00134     return TCL_ERROR;
00135   }
00136   
00137   if (Tcl_GetInt(interp, argv[3], &iNode) != TCL_OK) {
00138     opserr << "WARNING invalid iNode\n";
00139     opserr << "dispBeamColumn element: " << eleTag << endln;
00140     return TCL_ERROR;
00141   }
00142   
00143   if (Tcl_GetInt(interp, argv[4], &jNode) != TCL_OK) {
00144     opserr << "WARNING invalid jNode\n";
00145     opserr << "dispBeamColumn element: " << eleTag << endln;
00146     return TCL_ERROR;
00147   }
00148 
00149 
00150   //
00151   // fmk UNDOCUMENTED FEATURE - 
00152   // all to take similar command to nonlinearBeamColumn & dispBeamColumn 
00153   // 
00154 
00155   if ((strcmp(argv[6],"Lobatto") != 0) &&
00156       (strcmp(argv[6],"Legendre") != 0) &&
00157       (strcmp(argv[6],"Radau") != 0) &&
00158       (strcmp(argv[6],"NewtonCotes") != 0) &&
00159       (strcmp(argv[6],"UserDefined") != 0) &&
00160       (strcmp(argv[6],"HingeMidpoint") != 0) &&
00161       (strcmp(argv[6],"HingeEndpoint") != 0) &&
00162       (strcmp(argv[6],"HingeRadau") != 0) &&
00163       (strcmp(argv[6],"HingeRadauTwo") != 0) &&
00164       (strcmp(argv[6],"UserHinge") != 0) &&
00165       (strcmp(argv[6],"DistHinge") != 0) &&
00166       (strcmp(argv[6],"Trapezoidal") != 0) &&
00167       (strcmp(argv[6],"FixedLocation") != 0) &&
00168       (strcmp(argv[6],"LowOrder") != 0) &&
00169       (strcmp(argv[6],"MidDistance") != 0)) {
00170 
00171     int nIP, secTag;
00172 
00173     if (Tcl_GetInt(interp, argv[5], &nIP) != TCL_OK) {
00174       opserr << "WARNING invalid nIP\n";
00175       opserr << "dispBeamColumn element: " << eleTag << endln;
00176       return TCL_ERROR;
00177     }
00178 
00179     if (Tcl_GetInt(interp, argv[6], &secTag) != TCL_OK) {
00180       opserr << "WARNING invalid secTag\n";
00181       opserr << "dispBeamColumn element: " << eleTag << endln;
00182       return TCL_ERROR;
00183     }
00184 
00185     SectionForceDeformation *theSection = theTclBuilder->getSection(secTag);
00186     if (theSection == 0) {
00187       opserr << "WARNING section not found\n";
00188       opserr << "Section: " << secTag;
00189       opserr << "\ndispBeamColumn element: " << eleTag << endln;
00190       return TCL_ERROR;
00191     }
00192 
00193     if (Tcl_GetInt(interp, argv[7], &transfTag) != TCL_OK) {
00194       opserr << "WARNING invalid transfTag\n";
00195       opserr << "dispBeamColumn element: " << eleTag << endln;
00196       return TCL_ERROR;
00197     }
00198     
00199     int argi = 8;
00200     int numIter = 0;
00201     double tol = 0.0;
00202     if (argc > argi) {
00203       if (strcmp(argv[argi],"-iter") == 0) {
00204         if (argc < argi+3) {
00205           opserr << "WARNING not enough -iter args need -iter numIter? tol?\n";
00206           opserr << "dispBeamColumn element: " << eleTag << endln;
00207           return TCL_ERROR;
00208         }
00209         if (Tcl_GetInt(interp, argv[argi+1], &numIter) != TCL_OK) {
00210           opserr << "WARNING invalid numIter\n";
00211           opserr << "dispBeamColumn element: " << eleTag << endln;
00212           return TCL_ERROR;
00213         }
00214         if (Tcl_GetDouble(interp, argv[argi+2], &tol) != TCL_OK) {
00215           opserr << "WARNING invalid tol\n";
00216           opserr << "dispBeamColumn element: " << eleTag << endln;
00217           return TCL_ERROR;
00218         }
00219       }
00220     }
00221         
00222       
00223     if (ndm == 2) {
00224       
00225       theTransf2d = theTclBuilder->getCrdTransf2d(transfTag);
00226       
00227       if (theTransf2d == 0) {
00228         opserr << "WARNING transformation not found\n";
00229         opserr << "transformation: " << transfTag;
00230         opserr << "\ndispBeamColumn element: " << eleTag << endln;
00231         return TCL_ERROR;
00232       }
00233     }
00234     
00235     if (ndm == 3) {
00236       
00237       theTransf3d = theTclBuilder->getCrdTransf3d(transfTag);
00238       
00239       if (theTransf3d == 0) {
00240         opserr << "WARNING transformation not found\n";
00241         opserr << "transformation: " << transfTag;
00242         opserr << "\ndispBeamColumn element: " << eleTag << endln;
00243         return TCL_ERROR;
00244       }
00245     }
00246 
00247     
00248     SectionForceDeformation **sections = new SectionForceDeformation *[nIP];
00249     for (int i = 0; i < nIP; i++)
00250       sections[i] = theSection;
00251 
00252     LegendreBeamIntegration beamIntegr;
00253 
00254     if (ndm == 2) {
00255       if (tol == 0.0)
00256         theElement = new DispBeamColumn2d(eleTag, iNode, jNode, nIP, sections,
00257                                            beamIntegr, *theTransf2d);
00258       else
00259         theElement = new DispBeamColumn2d(eleTag, iNode, jNode, nIP, sections,
00260                                            beamIntegr, *theTransf2d);
00261     }
00262     else {
00263       if (tol == 0.0)      
00264         theElement = new DispBeamColumn3d(eleTag, iNode, jNode, nIP, sections,
00265                                           *theTransf3d);
00266       else
00267         theElement = new DispBeamColumn3d(eleTag, iNode, jNode, nIP, sections,
00268                                           *theTransf3d);
00269     }
00270 
00271     delete [] sections;    
00272     if (theElement == 0) {
00273       opserr << "WARNING ran out of memory creating element\n";
00274       opserr << "dispBeamColumn element: " << eleTag << endln;
00275       return TCL_ERROR;
00276     }
00277     
00278     if (theTclDomain->addElement(theElement) == false) {
00279       opserr << "WARNING could not add element to the domain\n";
00280       opserr << "dispBeamColumn element: " << eleTag << endln;
00281       delete theElement;
00282       return TCL_ERROR;
00283     }
00284 
00285     return TCL_OK;
00286   } 
00287 
00288   
00289   //
00290   // otherwise use correct format of command as found in current documentation
00291   //
00292 
00293   if (Tcl_GetInt(interp, argv[5], &transfTag) != TCL_OK) {
00294     opserr << "WARNING invalid transfTag\n";
00295     opserr << "dispBeamColumn element: " << eleTag << endln;
00296     return TCL_ERROR;
00297   }
00298   
00299   if (ndm == 2) {
00300     
00301     theTransf2d = theTclBuilder->getCrdTransf2d(transfTag);
00302     
00303     if (theTransf2d == 0) {
00304       opserr << "WARNING transformation not found\n";
00305       opserr << "transformation: " << transfTag;
00306       opserr << "\ndispBeamColumn element: " << eleTag << endln;
00307       return TCL_ERROR;
00308     }
00309   }
00310   
00311   if (ndm == 3) {
00312     
00313     theTransf3d = theTclBuilder->getCrdTransf3d(transfTag);
00314     
00315     if (theTransf3d == 0) {
00316       opserr << "WARNING transformation not found\n";
00317       opserr << "transformation: " << transfTag;
00318       opserr << "\ndispBeamColumn element: " << eleTag << endln;
00319       return TCL_ERROR;
00320     }
00321   }
00322   
00323   if (strcmp(argv[6],"Lobatto") == 0 || strcmp(argv[6],"Legendre") == 0 
00324       || strcmp(argv[6],"Radau") == 0 || strcmp(argv[6],"NewtonCotes") == 0
00325       || strcmp(argv[6],"Trapezoidal") == 0) {
00326     int secTag, nIP;
00327     
00328     if (argc < 9) {
00329       opserr << "WARNING insufficient arguments\n";
00330       printCommand(argc, argv);
00331       opserr << "Want: element dispBeamColumn eleTag? iNode? jNode? transfTag? Lobatto secTag? nIP?\n";
00332       return TCL_ERROR;
00333     }
00334 
00335     if (Tcl_GetInt(interp, argv[7], &secTag) != TCL_OK) {
00336       opserr << "WARNING invalid secTag\n";
00337       opserr << "dispBeamColumn element: " << eleTag << endln;
00338       return TCL_ERROR;
00339     }
00340     if (Tcl_GetInt(interp, argv[8], &nIP) != TCL_OK) {
00341       opserr << "WARNING invalid nIP\n";
00342       opserr << "dispBeamColumn element: " << eleTag << endln;
00343       return TCL_ERROR;
00344     }
00345     
00346     SectionForceDeformation *theSection = theTclBuilder->getSection(secTag);
00347     if (theSection == 0) {
00348       opserr << "WARNING section not found\n";
00349       opserr << "Section: " << secTag;
00350       opserr << "\ndispBeamColumn element: " << eleTag << endln;
00351       return TCL_ERROR;
00352     }
00353     
00354     SectionForceDeformation **sections = new SectionForceDeformation *[nIP];
00355     for (int i = 0; i < nIP; i++)
00356       sections[i] = theSection;
00357     
00358     BeamIntegration *beamIntegr = 0;
00359     if (strcmp(argv[6],"Lobatto") == 0)
00360       beamIntegr = new LobattoBeamIntegration();
00361     else if (strcmp(argv[6],"Legendre") == 0)
00362       beamIntegr = new LegendreBeamIntegration();
00363     else if (strcmp(argv[6],"Radau") == 0)
00364       beamIntegr = new RadauBeamIntegration();
00365     else if (strcmp(argv[6],"NewtonCotes") == 0)
00366       beamIntegr = new NewtonCotesBeamIntegration();
00367     //else if (strcmp(argv[6],"Trapezoidal") == 0)
00368     //  beamIntegr = new TrapezoidalBeamIntegration();
00369     else {
00370       opserr << "ERROR: invalid integration type: " << argv[6] << endln;
00371       return TCL_ERROR;
00372     }
00373 
00374     if (ndm == 2)
00375       theElement = new DispBeamColumn2d(eleTag, iNode, jNode, nIP, sections,
00376                                          *beamIntegr, *theTransf2d);
00377     else
00378       theElement = new DispBeamColumn3d(eleTag, iNode, jNode, nIP, sections,
00379                                         *theTransf3d);
00380     
00381     delete beamIntegr;
00382     delete [] sections;
00383   }
00384 
00385   else if (strcmp(argv[6],"UserDefined") == 0) {
00386 
00387     if (argc < 9) {
00388       opserr << "WARNING insufficient arguments\n";
00389       printCommand(argc, argv);
00390       opserr << "Want: element dispBeamColumn eleTag? iNode? jNode? transfTag? UserDefined nIP? secTag1? ... pt1? ... wt1? ...\n";
00391       return TCL_ERROR;
00392     }
00393 
00394     int nIP;
00395     
00396     if (Tcl_GetInt(interp, argv[7], &nIP) != TCL_OK) {
00397       opserr << "WARNING invalid nIP\n";
00398       opserr << "dispBeamColumn element: " << eleTag << endln;
00399       return TCL_ERROR;
00400     }
00401     
00402     ID secs(nIP);
00403     Vector pts(nIP);
00404     Vector wts(nIP);
00405 
00406     int i, j;
00407     for (i = 0, j = 8; i < nIP; i++, j++) {
00408       int sec;
00409       double pt, wt;
00410       if (Tcl_GetInt(interp, argv[j], &sec) != TCL_OK) {
00411         opserr << "WARNING invalid sec\n";
00412         opserr << "dispBeamColumn element: " << eleTag << endln;
00413         return TCL_ERROR;
00414       }
00415       if (Tcl_GetDouble(interp, argv[j+nIP], &pt) != TCL_OK) {
00416         opserr << "WARNING invalid pt\n";
00417         opserr << "dispBeamColumn element: " << eleTag << endln;
00418         return TCL_ERROR;
00419       }
00420       if (Tcl_GetDouble(interp, argv[j+2*nIP], &wt) != TCL_OK) {
00421         opserr << "WARNING invalid wt\n";
00422         opserr << "dispBeamColumn element: " << eleTag << endln;
00423         return TCL_ERROR;
00424       }
00425       secs(i) = sec;
00426       pts(i)  = pt;
00427       wts(i)  = wt;
00428     }
00429     
00430     SectionForceDeformation **sections = new SectionForceDeformation *[nIP];
00431     for (i = 0; i < nIP; i++) {
00432       SectionForceDeformation *theSection = theTclBuilder->getSection(secs(i));
00433       if (theSection == 0) {
00434         opserr << "WARNING section not found\n";
00435         opserr << "Section: " << secs(i);
00436         opserr << "\ndispBeamColumn element: " << eleTag << endln;
00437         return TCL_ERROR;
00438       }
00439       sections[i] = theSection;
00440     }
00441     
00442     UserDefinedBeamIntegration beamIntegr(nIP, pts, wts);
00443 
00444     if (ndm == 2)
00445       theElement = new DispBeamColumn2d(eleTag, iNode, jNode, nIP, sections,
00446                                          beamIntegr, *theTransf2d);
00447     else
00448       theElement = new DispBeamColumn3d(eleTag, iNode, jNode, nIP, sections,
00449                                         *theTransf3d);
00450     
00451     delete [] sections;
00452   }
00453 
00454   else if (strcmp(argv[6],"HingeMidpoint") == 0 ||
00455            strcmp(argv[6],"HingeRadau") == 0 ||
00456            strcmp(argv[6],"HingeRadauTwo") == 0 ||
00457            strcmp(argv[6],"HingeEndpoint") == 0) {
00458     
00459     if (argc < 12) {
00460       opserr << "WARNING insufficient arguments\n";
00461       printCommand(argc, argv);
00462       opserr << "Want: element dispBeamColumn eleTag? iNode? jNode? transfTag? type secTagI? lpI? secTagJ? lpJ? secTagE?\n";
00463       return TCL_ERROR;
00464     }
00465 
00466     int secTagI, secTagJ, secTagE;
00467     double lpI, lpJ;
00468     
00469     if (Tcl_GetInt(interp, argv[7], &secTagI) != TCL_OK) {
00470       opserr << "WARNING invalid secTagI\n";
00471       opserr << "dispBeamColumn element: " << eleTag << endln;
00472       return TCL_ERROR;
00473     }
00474     if (Tcl_GetDouble(interp, argv[8], &lpI) != TCL_OK) {
00475       opserr << "WARNING invalid lpI\n";
00476       opserr << "dispBeamColumn element: " << eleTag << endln;
00477       return TCL_ERROR;
00478     }
00479     if (Tcl_GetInt(interp, argv[9], &secTagJ) != TCL_OK) {
00480       opserr << "WARNING invalid secTagJ\n";
00481       opserr << "dispBeamColumn element: " << eleTag << endln;
00482       return TCL_ERROR;
00483     }
00484     if (Tcl_GetDouble(interp, argv[10], &lpJ) != TCL_OK) {
00485       opserr << "WARNING invalid lpJ\n";
00486       opserr << "dispBeamColumn element: " << eleTag << endln;
00487       return TCL_ERROR;
00488     }
00489     if (Tcl_GetInt(interp, argv[11], &secTagE) != TCL_OK) {
00490       opserr << "WARNING invalid secTagE\n";
00491       opserr << "forceBeamColumn element: " << eleTag << endln;
00492       return TCL_ERROR;
00493     }
00494     
00495     SectionForceDeformation *sectionI = theTclBuilder->getSection(secTagI);
00496     if (sectionI == 0) {
00497       opserr << "WARNING section not found\n";
00498       opserr << "Section: " << secTagI;
00499       opserr << "\ndispBeamColumn element: " << eleTag << endln;
00500       return TCL_ERROR;
00501     }
00502     SectionForceDeformation *sectionJ = theTclBuilder->getSection(secTagJ);
00503     if (sectionJ == 0) {
00504       opserr << "WARNING section not found\n";
00505       opserr << "Section: " << secTagJ;
00506       opserr << "\ndispBeamColumn element: " << eleTag << endln;
00507       return TCL_ERROR;
00508     }
00509     
00510     SectionForceDeformation *sectionE = theTclBuilder->getSection(secTagE);
00511     if (sectionJ == 0) {
00512       opserr << "WARNING section not found\n";
00513       opserr << "Section: " << secTagE;
00514       opserr << "\nforceBeamColumn element: " << eleTag << endln;
00515       return TCL_ERROR;
00516     }
00517 
00518     BeamIntegration *beamIntegr = 0;
00519 
00520     SectionForceDeformation *sections[6];
00521 
00522     int Np;
00523     if (strcmp(argv[6],"HingeMidpoint") == 0) {
00524       beamIntegr = new HingeMidpointBeamIntegration(lpI, lpJ);
00525       Np = 4;
00526       sections[0] = sectionI;
00527       sections[1] = sectionE;
00528       sections[2] = sectionE;
00529       sections[3] = sectionJ;
00530     }
00531     else if (strcmp(argv[6],"HingeRadau") == 0) {
00532       beamIntegr = new HingeRadauBeamIntegration(lpI, lpJ);
00533       Np = 6;
00534       sections[0] = sectionI;
00535       sections[1] = sectionE;
00536       sections[2] = sectionE;
00537       sections[3] = sectionE;
00538       sections[4] = sectionE;
00539       sections[5] = sectionJ;
00540     }
00541     else if (strcmp(argv[6],"HingeRadauTwo") == 0) {
00542       beamIntegr = new HingeRadauTwoBeamIntegration(lpI, lpJ);
00543       Np = 6;
00544       sections[0] = sectionI;
00545       sections[1] = sectionI;
00546       sections[2] = sectionE;
00547       sections[3] = sectionE;
00548       sections[4] = sectionJ;
00549       sections[5] = sectionJ;
00550     }
00551     else {
00552       beamIntegr = new HingeEndpointBeamIntegration(lpI, lpJ);
00553       Np = 4;
00554       sections[0] = sectionI;
00555       sections[1] = sectionE;
00556       sections[2] = sectionE;
00557       sections[3] = sectionJ;
00558     }
00559 
00560     if (ndm == 2)
00561       theElement = new DispBeamColumn2d(eleTag, iNode, jNode, Np, sections,
00562                                         *beamIntegr, *theTransf2d);
00563     else
00564       theElement = new DispBeamColumn3d(eleTag, iNode, jNode, Np, sections,
00565                                         *theTransf3d);
00566 
00567     delete beamIntegr;
00568   }
00569 
00570   else if (strcmp(argv[6],"UserHinge") == 0) {
00571 
00572     if (argc < 9) {
00573       opserr << "WARNING insufficient arguments\n";
00574       printCommand(argc, argv);
00575       opserr << "Want: element dispBeamColumn eleTag? iNode? jNode? transfTag? UserHinge E? A? Iz? <Iy? G? J?> npL? secTagL1? ... ptL1? ... wtL1? ... npR? secTagR1? ... ptR1? ... wtR1? ...\n";
00576       return TCL_ERROR;
00577     }
00578 
00579     double E, A, Iz, Iy, G, J;
00580     
00581     if (Tcl_GetDouble(interp, argv[7], &E) != TCL_OK) {
00582       opserr << "WARNING invalid E\n";
00583       opserr << "dispBeamColumn element: " << eleTag << endln;
00584       return TCL_ERROR;
00585     }
00586     if (Tcl_GetDouble(interp, argv[8], &A) != TCL_OK) {
00587       opserr << "WARNING invalid A\n";
00588       opserr << "dispBeamColumn element: " << eleTag << endln;
00589       return TCL_ERROR;
00590     }
00591     if (Tcl_GetDouble(interp, argv[9], &Iz) != TCL_OK) {
00592       opserr << "WARNING invalid I\n";
00593       opserr << "dispBeamColumn element: " << eleTag << endln;
00594       return TCL_ERROR;
00595     }
00596 
00597     int argStart = 10;
00598     if (ndm == 3) {
00599       if (Tcl_GetDouble(interp, argv[10], &Iy) != TCL_OK) {
00600         opserr << "WARNING invalid I\n";
00601         opserr << "dispBeamColumn element: " << eleTag << endln;
00602         return TCL_ERROR;
00603       }
00604       if (Tcl_GetDouble(interp, argv[11], &G) != TCL_OK) {
00605         opserr << "WARNING invalid G\n";
00606         opserr << "dispBeamColumn element: " << eleTag << endln;
00607         return TCL_ERROR;
00608       }
00609       if (Tcl_GetDouble(interp, argv[12], &J) != TCL_OK) {
00610         opserr << "WARNING invalid J\n";
00611         opserr << "dispBeamColumn element: " << eleTag << endln;
00612         return TCL_ERROR;
00613       }
00614       argStart = 13;
00615     }
00616 
00617     int npL, npR;
00618       
00619     if (Tcl_GetInt(interp, argv[argStart], &npL) != TCL_OK) {
00620       opserr << "WARNING invalid npL\n";
00621       opserr << "dispBeamColumn element: " << eleTag << endln;
00622       return TCL_ERROR;
00623     }
00624     if (Tcl_GetInt(interp, argv[argStart+3*npL+1], &npR) != TCL_OK) {
00625       opserr << "WARNING invalid npR\n";
00626       opserr << "dispBeamColumn element: " << eleTag << endln;
00627       return TCL_ERROR;
00628     }
00629 
00630     int nIP = npL+npR;
00631 
00632     ID secs(nIP);
00633     Vector ptsL(npL);
00634     Vector wtsL(npL);
00635     Vector ptsR(npR);
00636     Vector wtsR(npR);
00637 
00638     int i, j;
00639     for (i = 0, j = argStart+1; i < npL; i++, j++) {
00640       int sec;
00641       double pt, wt;
00642       if (Tcl_GetInt(interp, argv[j], &sec) != TCL_OK) {
00643         opserr << "WARNING invalid sec\n";
00644         opserr << "dispBeamColumn element: " << eleTag << endln;
00645         return TCL_ERROR;
00646       }
00647       if (Tcl_GetDouble(interp, argv[j+npL], &pt) != TCL_OK) {
00648         opserr << "WARNING invalid pt\n";
00649         opserr << "dispBeamColumn element: " << eleTag << endln;
00650         return TCL_ERROR;
00651       }
00652       if (Tcl_GetDouble(interp, argv[j+2*npL], &wt) != TCL_OK) {
00653         opserr << "WARNING invalid wt\n";
00654         opserr << "dispBeamColumn element: " << eleTag << endln;
00655         return TCL_ERROR;
00656       }
00657       secs(i) = sec;
00658       ptsL(i) = pt;
00659       wtsL(i) = wt;
00660     }
00661     for (i = 0, j = 1+(argStart+1)+3*npL; i < npR; i++, j++) {
00662       int sec;
00663       double pt, wt;
00664       if (Tcl_GetInt(interp, argv[j], &sec) != TCL_OK) {
00665         opserr << "WARNING invalid sec\n";
00666         opserr << "dispBeamColumn element: " << eleTag << endln;
00667         return TCL_ERROR;
00668       }
00669       if (Tcl_GetDouble(interp, argv[j+npR], &pt) != TCL_OK) {
00670         opserr << "WARNING invalid pt\n";
00671         opserr << "dispBeamColumn element: " << eleTag << endln;
00672         return TCL_ERROR;
00673       }
00674       if (Tcl_GetDouble(interp, argv[j+2*npR], &wt) != TCL_OK) {
00675         opserr << "WARNING invalid wt\n";
00676         opserr << "dispBeamColumn element: " << eleTag << endln;
00677         return TCL_ERROR;
00678       }
00679       secs(i+npL) = sec;
00680       ptsR(i)     = pt;
00681       wtsR(i)     = wt;
00682     }
00683     
00684     SectionForceDeformation **sections = new SectionForceDeformation *[nIP+2];
00685     for (i = 0; i < nIP; i++) {
00686       SectionForceDeformation *theSection = theTclBuilder->getSection(secs(i));
00687       if (theSection == 0) {
00688         opserr << "WARNING section not found\n";
00689         opserr << "Section: " << secs(i);
00690         opserr << "\ndispBeamColumn element: " << eleTag << endln;
00691         return TCL_ERROR;
00692       }
00693       sections[i] = theSection;
00694     }
00695     
00696     UserDefinedHingeIntegration beamIntegr(npL, ptsL, wtsL,
00697                                            npR, ptsR, wtsR);
00698                                 
00699     ElasticSection2d section2d(0, E, A, Iz);
00700     ElasticSection3d section3d(0, E, A, Iz, Iy, G, J);
00701           
00702     if (ndm == 2) {
00703       sections[nIP]   = &section2d;
00704       sections[nIP+1] = &section2d;
00705       theElement = new DispBeamColumn2d(eleTag, iNode, jNode, nIP+2, sections,
00706                                          beamIntegr, *theTransf2d);
00707     }
00708     else {
00709       sections[nIP]   = &section3d;
00710       sections[nIP+1] = &section3d;
00711       theElement = new DispBeamColumn3d(eleTag, iNode, jNode, nIP+2, sections,
00712                                         *theTransf3d);
00713     }
00714     
00715     delete [] sections;
00716   }
00717 
00718   else if (strcmp(argv[6],"DistHinge") == 0) {
00719     
00720     if (argc < 16) {
00721       opserr << "WARNING insufficient arguments\n";
00722       printCommand(argc, argv);
00723       opserr << "Want: element dispBeamColumn eleTag? iNode? jNode? transfTag? type type nIP? secTagI? lpI? secTagJ? lpJ? E? A? Iz? <Iy? G? J?>\n";
00724       return TCL_ERROR;
00725     }
00726 
00727     int secTagI, secTagJ;
00728     double lpI, lpJ;
00729     double E, A, Iz, Iy, G, J;
00730     int nIP;
00731 
00732     BeamIntegration *otherBeamInt = 0;
00733     if (strcmp(argv[7],"Lobatto") == 0)
00734       otherBeamInt = new LobattoBeamIntegration();
00735     else if (strcmp(argv[7],"Legendre") == 0)
00736       otherBeamInt = new LegendreBeamIntegration();
00737     else if (strcmp(argv[7],"Radau") == 0)
00738       otherBeamInt = new RadauBeamIntegration();
00739     else if (strcmp(argv[7],"NewtonCotes") == 0)
00740       otherBeamInt = new NewtonCotesBeamIntegration();
00741     //else if (strcmp(argv[7],"Trapezoidal") == 0)
00742     //  otherBeamInt = new TrapezoidalBeamIntegration();
00743     else {
00744       opserr << "ERROR: invalid integration type: " << argv[7] << endln;
00745       return TCL_ERROR;
00746     }
00747 
00748     if (Tcl_GetInt(interp, argv[8], &nIP) != TCL_OK) {
00749       opserr << "WARNING invalid nIP\n";
00750       opserr << "dispBeamColumn element: " << eleTag << endln;
00751       return TCL_ERROR;
00752     }
00753     if (Tcl_GetInt(interp, argv[9], &secTagI) != TCL_OK) {
00754       opserr << "WARNING invalid secTagI\n";
00755       opserr << "dispBeamColumn element: " << eleTag << endln;
00756       return TCL_ERROR;
00757     }
00758     if (Tcl_GetDouble(interp, argv[10], &lpI) != TCL_OK) {
00759       opserr << "WARNING invalid lpI\n";
00760       opserr << "dispBeamColumn element: " << eleTag << endln;
00761       return TCL_ERROR;
00762     }
00763     if (Tcl_GetInt(interp, argv[11], &secTagJ) != TCL_OK) {
00764       opserr << "WARNING invalid secTagJ\n";
00765       opserr << "dispBeamColumn element: " << eleTag << endln;
00766       return TCL_ERROR;
00767     }
00768     if (Tcl_GetDouble(interp, argv[12], &lpJ) != TCL_OK) {
00769       opserr << "WARNING invalid lpJ\n";
00770       opserr << "dispBeamColumn element: " << eleTag << endln;
00771       return TCL_ERROR;
00772     }
00773     if (Tcl_GetDouble(interp, argv[13], &E) != TCL_OK) {
00774       opserr << "WARNING invalid E\n";
00775       opserr << "dispBeamColumn element: " << eleTag << endln;
00776       return TCL_ERROR;
00777     }
00778     if (Tcl_GetDouble(interp, argv[14], &A) != TCL_OK) {
00779       opserr << "WARNING invalid A\n";
00780       opserr << "dispBeamColumn element: " << eleTag << endln;
00781       return TCL_ERROR;
00782     }
00783     if (Tcl_GetDouble(interp, argv[15], &Iz) != TCL_OK) {
00784       opserr << "WARNING invalid I\n";
00785       opserr << "dispBeamColumn element: " << eleTag << endln;
00786       return TCL_ERROR;
00787     }
00788     
00789     if (ndm == 3 && argc > 18) {
00790       if (Tcl_GetDouble(interp, argv[16], &Iy) != TCL_OK) {
00791         opserr << "WARNING invalid Iy\n";
00792         opserr << "dispBeamColumn element: " << eleTag << endln;
00793         return TCL_ERROR;
00794       }
00795       if (Tcl_GetDouble(interp, argv[17], &G) != TCL_OK) {
00796         opserr << "WARNING invalid G\n";
00797         opserr << "dispBeamColumn element: " << eleTag << endln;
00798         return TCL_ERROR;
00799       }
00800       if (Tcl_GetDouble(interp, argv[18], &J) != TCL_OK) {
00801         opserr << "WARNING invalid J\n";
00802         opserr << "dispBeamColumn element: " << eleTag << endln;
00803         return TCL_ERROR;
00804       }
00805     }
00806 
00807     SectionForceDeformation *sectionI = theTclBuilder->getSection(secTagI);
00808     if (sectionI == 0) {
00809       opserr << "WARNING section not found\n";
00810       opserr << "Section: " << secTagI;
00811       opserr << "\ndispBeamColumn element: " << eleTag << endln;
00812       return TCL_ERROR;
00813     }
00814     SectionForceDeformation *sectionJ = theTclBuilder->getSection(secTagJ);
00815     if (sectionJ == 0) {
00816       opserr << "WARNING section not found\n";
00817       opserr << "Section: " << secTagJ;
00818       opserr << "\ndispBeamColumn element: " << eleTag << endln;
00819       return TCL_ERROR;
00820     }
00821     
00822     int numSections = 2*nIP;
00823     SectionForceDeformation **sections = new SectionForceDeformation *[numSections];
00824     for (int i = 0; i < nIP; i++) {
00825       sections[i] = sectionI;
00826       sections[numSections-1-i] = sectionJ;
00827     }
00828     
00829     DistHingeIntegration beamIntegr(lpI, lpJ, *otherBeamInt);
00830 
00831     ElasticSection2d section2d(0, E, A, Iz);
00832     ElasticSection3d section3d(0, E, A, Iz, Iy, G, J);
00833 
00834     if (ndm == 2) {
00835       sections[numSections]   = &section2d;
00836       sections[numSections+1] = &section2d;
00837       theElement = new DispBeamColumn2d(eleTag, iNode, jNode, numSections+2,
00838                                          sections, beamIntegr, *theTransf2d);
00839     }
00840     else {
00841       sections[numSections]   = &section3d;
00842       sections[numSections+1] = &section3d;
00843       theElement = new DispBeamColumn3d(eleTag, iNode, jNode, numSections+2,
00844                                          sections, *theTransf3d);
00845     }
00846 
00847     if (otherBeamInt != 0)
00848       delete otherBeamInt;
00849     delete [] sections;
00850   }
00851 
00852   else if (strcmp(argv[6],"FixedLocation") == 0) {
00853 
00854     if (argc < 9) {
00855       opserr << "WARNING insufficient arguments\n";
00856       printCommand(argc, argv);
00857       opserr << "Want: element dispBeamColumn eleTag? iNode? jNode? transfTag? FixedLocation nIP? secTag1? ... pt1? ... \n";
00858       return TCL_ERROR;
00859     }
00860 
00861     int nIP;
00862     
00863     if (Tcl_GetInt(interp, argv[7], &nIP) != TCL_OK) {
00864       opserr << "WARNING invalid nIP\n";
00865       opserr << "dispBeamColumn element: " << eleTag << endln;
00866       return TCL_ERROR;
00867     }
00868     
00869     ID secs(nIP);
00870     Vector pts(nIP);
00871     Vector wts(nIP);
00872 
00873     int i, j;
00874     for (i = 0, j = 8; i < nIP; i++, j++) {
00875       int sec;
00876       double pt;
00877       if (Tcl_GetInt(interp, argv[j], &sec) != TCL_OK) {
00878         opserr << "WARNING invalid sec\n";
00879         opserr << "dispBeamColumn element: " << eleTag << endln;
00880         return TCL_ERROR;
00881       }
00882       if (Tcl_GetDouble(interp, argv[j+nIP], &pt) != TCL_OK) {
00883         opserr << "WARNING invalid pt\n";
00884         opserr << "dispBeamColumn element: " << eleTag << endln;
00885         return TCL_ERROR;
00886       }
00887       secs(i) = sec;
00888       pts(i)  = pt;
00889     }
00890     
00891     SectionForceDeformation **sections = new SectionForceDeformation *[nIP];
00892     for (i = 0; i < nIP; i++) {
00893       SectionForceDeformation *theSection = theTclBuilder->getSection(secs(i));
00894       if (theSection == 0) {
00895         opserr << "WARNING section not found\n";
00896         opserr << "Section: " << secs(i);
00897         opserr << "\ndispBeamColumn element: " << eleTag << endln;
00898         return TCL_ERROR;
00899       }
00900       sections[i] = theSection;
00901     }
00902     
00903     /*
00904     FixedLocationBeamIntegration beamIntegr(nIP, pts);
00905 
00906     if (ndm == 2)
00907       theElement = new DispBeamColumn2d(eleTag, iNode, jNode, nIP, sections,
00908                                          beamIntegr, *theTransf2d);
00909     else
00910       theElement = new DispBeamColumn3d(eleTag, iNode, jNode, nIP, sections,
00911                                         *theTransf3d);
00912                                         */
00913 
00914     delete [] sections;
00915   }
00916 
00917   else if (strcmp(argv[6],"LowOrder") == 0) {
00918 
00919     if (argc < 9) {
00920       opserr << "WARNING insufficient arguments\n";
00921       printCommand(argc, argv);
00922       opserr << "Want: element dispBeamColumn eleTag? iNode? jNode? transfTag? LowOrder nIP? secTag1? ... pt1? ... wt1? ...\n";
00923       return TCL_ERROR;
00924     }
00925 
00926     int nIP;
00927     
00928     if (Tcl_GetInt(interp, argv[7], &nIP) != TCL_OK) {
00929       opserr << "WARNING invalid nIP\n";
00930       opserr << "dispBeamColumn element: " << eleTag << endln;
00931       return TCL_ERROR;
00932     }
00933     
00934     ID secs(nIP);
00935     Vector pts(nIP);
00936     Vector wts(nIP);
00937 
00938     int i, j;
00939     int nc = 0;
00940     for (i = 0, j = 8; i < nIP; i++, j++) {
00941       int sec;
00942       double pt, wt;
00943       if (Tcl_GetInt(interp, argv[j], &sec) != TCL_OK) {
00944         opserr << "WARNING invalid sec\n";
00945         opserr << "dispBeamColumn element: " << eleTag << endln;
00946         return TCL_ERROR;
00947       }
00948       secs(i) = sec;
00949 
00950       if (Tcl_GetDouble(interp, argv[j+nIP], &pt) != TCL_OK) {
00951         opserr << "WARNING invalid pt\n";
00952         opserr << "dispBeamColumn element: " << eleTag << endln;
00953         return TCL_ERROR;
00954       }
00955       pts(i)  = pt;
00956 
00957       if (j+2*nIP < argc) {
00958         if (Tcl_GetDouble(interp, argv[j+2*nIP], &wt) != TCL_OK) {
00959           opserr << "WARNING invalid wt\n";
00960           opserr << "dispBeamColumn element: " << eleTag << endln;
00961           return TCL_ERROR;
00962         }
00963         else {
00964           wts(i)  = wt;
00965           nc++;
00966         }
00967       }
00968     }
00969     
00970     SectionForceDeformation **sections = new SectionForceDeformation *[nIP];
00971     for (i = 0; i < nIP; i++) {
00972       SectionForceDeformation *theSection = theTclBuilder->getSection(secs(i));
00973       if (theSection == 0) {
00974         opserr << "WARNING section not found\n";
00975         opserr << "Section: " << secs(i);
00976         opserr << "\ndispBeamColumn element: " << eleTag << endln;
00977         return TCL_ERROR;
00978       }
00979       sections[i] = theSection;
00980     }
00981     /*
00982     LowOrderBeamIntegration beamIntegr(nIP, pts, nc, wts);
00983 
00984     if (ndm == 2)
00985       theElement = new DispBeamColumn2d(eleTag, iNode, jNode, nIP, sections,
00986                                          beamIntegr, *theTransf2d);
00987     else
00988       theElement = new DispBeamColumn3d(eleTag, iNode, jNode, nIP, sections,
00989                                         *theTransf3d);
00990                                         */
00991 
00992     delete [] sections;
00993   }
00994 
00995   else if (strcmp(argv[6],"MidDistance") == 0) {
00996 
00997     if (argc < 9) {
00998       opserr << "WARNING insufficient arguments\n";
00999       printCommand(argc, argv);
01000       opserr << "Want: element dispBeamColumn eleTag? iNode? jNode? transfTag? MidDistance nIP? secTag1? ... pt1? ... \n";
01001       return TCL_ERROR;
01002     }
01003 
01004     int nIP;
01005     
01006     if (Tcl_GetInt(interp, argv[7], &nIP) != TCL_OK) {
01007       opserr << "WARNING invalid nIP\n";
01008       opserr << "dispBeamColumn element: " << eleTag << endln;
01009       return TCL_ERROR;
01010     }
01011     
01012     ID secs(nIP);
01013     Vector pts(nIP);
01014     Vector wts(nIP);
01015 
01016     int i, j;
01017     for (i = 0, j = 8; i < nIP; i++, j++) {
01018       int sec;
01019       double pt;
01020       if (Tcl_GetInt(interp, argv[j], &sec) != TCL_OK) {
01021         opserr << "WARNING invalid sec\n";
01022         opserr << "dispBeamColumn element: " << eleTag << endln;
01023         return TCL_ERROR;
01024       }
01025       if (Tcl_GetDouble(interp, argv[j+nIP], &pt) != TCL_OK) {
01026         opserr << "WARNING invalid pt\n";
01027         opserr << "dispBeamColumn element: " << eleTag << endln;
01028         return TCL_ERROR;
01029       }
01030       secs(i) = sec;
01031       pts(i)  = pt;
01032     }
01033     
01034     SectionForceDeformation **sections = new SectionForceDeformation *[nIP];
01035     for (i = 0; i < nIP; i++) {
01036       SectionForceDeformation *theSection = theTclBuilder->getSection(secs(i));
01037       if (theSection == 0) {
01038         opserr << "WARNING section not found\n";
01039         opserr << "Section: " << secs(i);
01040         opserr << "\ndispBeamColumn element: " << eleTag << endln;
01041         return TCL_ERROR;
01042       }
01043       sections[i] = theSection;
01044     }
01045     
01046     /*
01047     MidDistanceBeamIntegration beamIntegr(nIP, pts);
01048 
01049     if (ndm == 2)
01050       theElement = new DispBeamColumn2d(eleTag, iNode, jNode, nIP, sections,
01051                                          beamIntegr, *theTransf2d);
01052     else
01053       theElement = new DispBeamColumn3d(eleTag, iNode, jNode, nIP, sections,
01054                                         *theTransf3d);
01055                                         */
01056 
01057     delete [] sections;
01058   }
01059 
01060   else {
01061     opserr << "Unknown integration type: " << argv[6] << endln;
01062     opserr << "dispBeamColumn element: " << eleTag << endln;
01063     return TCL_ERROR;
01064   }
01065   
01066   if (theElement == 0) {
01067     opserr << "WARNING ran out of memory creating element\n";
01068     opserr << "dispBeamColumn element: " << eleTag << endln;
01069     return TCL_ERROR;
01070   }
01071   
01072   if (theTclDomain->addElement(theElement) == false) {
01073     opserr << "WARNING could not add element to the domain\n";
01074     opserr << "dispBeamColumn element: " << eleTag << endln;
01075     delete theElement;
01076     return TCL_ERROR;
01077   }
01078   
01079   // if get here we have sucessfully created the element and added it to the domain
01080   return TCL_OK;
01081 }

Generated on Mon Oct 23 15:05:05 2006 for OpenSees by doxygen 1.5.0