TclForceBeamColumnCommand.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.11 $
00022 // $Date: 2006/09/26 18:51:37 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/element/forceBeamColumn/TclForceBeamColumnCommand.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 <ForceBeamColumn2d.h>
00038 #include <ForceBeamColumn3d.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_addForceBeamColumn(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 forceBeamColumn 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_addForceBeamColumn - 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_addForceBeamColumn - 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 forceBeamColumn 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 forceBeamColumn 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 << "forceBeamColumn 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 << "forceBeamColumn 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 << "forceBeamColumn 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 << "forceBeamColumn 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 << "\nforceBeamColumn 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 << "forceBeamColumn 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 << "forceBeamColumn 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 << "forceBeamColumn 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 << "forceBeamColumn 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 << "\nforceBeamColumn 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 << "\nforceBeamColumn 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     LobattoBeamIntegration beamIntegr;
00253 
00254     if (ndm == 2) {
00255       if (tol == 0.0)
00256         theElement = new ForceBeamColumn2d(eleTag, iNode, jNode, nIP, sections,
00257                                            beamIntegr, *theTransf2d);
00258       else
00259         theElement = new ForceBeamColumn2d(eleTag, iNode, jNode, nIP, sections,
00260                                            beamIntegr, *theTransf2d, 0.0, numIter, tol);
00261     }
00262     else {
00263       if (tol == 0.0)      
00264         theElement = new ForceBeamColumn3d(eleTag, iNode, jNode, nIP, sections,
00265                                            beamIntegr, *theTransf3d);
00266       else
00267         theElement = new ForceBeamColumn3d(eleTag, iNode, jNode, nIP, sections,
00268                                            beamIntegr, *theTransf3d, 0.0, numIter, tol);
00269     }
00270 
00271     delete [] sections;    
00272     if (theElement == 0) {
00273       opserr << "WARNING ran out of memory creating element\n";
00274       opserr << "forceBeamColumn 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 << "forceBeamColumn 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 << "forceBeamColumn 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 << "\nforceBeamColumn 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 << "\nforceBeamColumn 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 forceBeamColumn 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 << "forceBeamColumn 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 << "forceBeamColumn 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 << "\nforceBeamColumn 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 ForceBeamColumn2d(eleTag, iNode, jNode, nIP, sections,
00376                                          *beamIntegr, *theTransf2d);
00377     else
00378       theElement = new ForceBeamColumn3d(eleTag, iNode, jNode, nIP, sections,
00379                                          *beamIntegr, *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 forceBeamColumn 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 << "forceBeamColumn 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 << "forceBeamColumn 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 << "forceBeamColumn 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 << "forceBeamColumn 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 << "\nforceBeamColumn 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 ForceBeamColumn2d(eleTag, iNode, jNode, nIP, sections,
00446                                          beamIntegr, *theTransf2d);
00447     else
00448       theElement = new ForceBeamColumn3d(eleTag, iNode, jNode, nIP, sections,
00449                                          beamIntegr, *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 forceBeamColumn 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 << "forceBeamColumn 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 << "forceBeamColumn 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 << "forceBeamColumn 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 << "forceBeamColumn 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 << "\nforceBeamColumn 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 << "\nforceBeamColumn 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 ForceBeamColumn2d(eleTag, iNode, jNode, Np, sections,
00562                                          *beamIntegr, *theTransf2d);
00563     else
00564       theElement = new ForceBeamColumn3d(eleTag, iNode, jNode, Np, sections,
00565                                          *beamIntegr, *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 forceBeamColumn eleTag? iNode? jNode? transfTag? UserHinge secTagE? npL? secTagL1? ... ptL1? ... wtL1? ... npR? secTagR1? ... ptR1? ... wtR1? ...\n";
00576       return TCL_ERROR;
00577     }
00578 
00579     int secTagE;
00580     
00581     if (Tcl_GetInt(interp, argv[7], &secTagE) != TCL_OK) {
00582       opserr << "WARNING invalid secTagE\n";
00583       opserr << "forceBeamColumn element: " << eleTag << endln;
00584       return TCL_ERROR;
00585     }
00586 
00587     int argStart = 8;
00588 
00589     int npL, npR;
00590       
00591     if (Tcl_GetInt(interp, argv[argStart], &npL) != TCL_OK) {
00592       opserr << "WARNING invalid npL\n";
00593       opserr << "forceBeamColumn element: " << eleTag << endln;
00594       return TCL_ERROR;
00595     }
00596     if (Tcl_GetInt(interp, argv[argStart+3*npL+1], &npR) != TCL_OK) {
00597       opserr << "WARNING invalid npR\n";
00598       opserr << "forceBeamColumn element: " << eleTag << endln;
00599       return TCL_ERROR;
00600     }
00601 
00602     int nIP = npL+npR;
00603 
00604     ID secs(nIP);
00605     Vector ptsL(npL);
00606     Vector wtsL(npL);
00607     Vector ptsR(npR);
00608     Vector wtsR(npR);
00609 
00610     int i, j;
00611     for (i = 0, j = argStart+1; i < npL; i++, j++) {
00612       int sec;
00613       double pt, wt;
00614       if (Tcl_GetInt(interp, argv[j], &sec) != TCL_OK) {
00615         opserr << "WARNING invalid sec\n";
00616         opserr << "forceBeamColumn element: " << eleTag << endln;
00617         return TCL_ERROR;
00618       }
00619       if (Tcl_GetDouble(interp, argv[j+npL], &pt) != TCL_OK) {
00620         opserr << "WARNING invalid pt\n";
00621         opserr << "forceBeamColumn element: " << eleTag << endln;
00622         return TCL_ERROR;
00623       }
00624       if (Tcl_GetDouble(interp, argv[j+2*npL], &wt) != TCL_OK) {
00625         opserr << "WARNING invalid wt\n";
00626         opserr << "forceBeamColumn element: " << eleTag << endln;
00627         return TCL_ERROR;
00628       }
00629       secs(i) = sec;
00630       ptsL(i) = pt;
00631       wtsL(i) = wt;
00632     }
00633     for (i = 0, j = 1+(argStart+1)+3*npL; i < npR; i++, j++) {
00634       int sec;
00635       double pt, wt;
00636       if (Tcl_GetInt(interp, argv[j], &sec) != TCL_OK) {
00637         opserr << "WARNING invalid sec\n";
00638         opserr << "forceBeamColumn element: " << eleTag << endln;
00639         return TCL_ERROR;
00640       }
00641       if (Tcl_GetDouble(interp, argv[j+npR], &pt) != TCL_OK) {
00642         opserr << "WARNING invalid pt\n";
00643         opserr << "forceBeamColumn element: " << eleTag << endln;
00644         return TCL_ERROR;
00645       }
00646       if (Tcl_GetDouble(interp, argv[j+2*npR], &wt) != TCL_OK) {
00647         opserr << "WARNING invalid wt\n";
00648         opserr << "forceBeamColumn element: " << eleTag << endln;
00649         return TCL_ERROR;
00650       }
00651       secs(i+npL) = sec;
00652       ptsR(i)     = pt;
00653       wtsR(i)     = wt;
00654     }
00655     
00656     SectionForceDeformation **sections = new SectionForceDeformation *[nIP+2];
00657 
00658     for (i = 0; i < nIP; i++) {
00659       SectionForceDeformation *theSection = theTclBuilder->getSection(secs(i));
00660       if (theSection == 0) {
00661         opserr << "WARNING section not found\n";
00662         opserr << "Section: " << secs(i);
00663         opserr << "\nforceBeamColumn element: " << eleTag << endln;
00664         return TCL_ERROR;
00665       }
00666       sections[i] = theSection;
00667     }
00668 
00669     SectionForceDeformation *sectionE = theTclBuilder->getSection(secTagE);
00670     if (sectionE == 0) {
00671       opserr << "WARNING section not found\n";
00672       opserr << "Section: " << secTagE;
00673       opserr << "\nforceBeamColumn element: " << eleTag << endln;
00674       return TCL_ERROR;
00675     }
00676 
00677     sections[nIP]   = sectionE;
00678     sections[nIP+1] = sectionE;
00679     
00680     UserDefinedHingeIntegration beamIntegr(npL, ptsL, wtsL,
00681                                            npR, ptsR, wtsR);
00682                 
00683     if (ndm == 2)
00684       theElement = new ForceBeamColumn2d(eleTag, iNode, jNode, nIP+2, sections,
00685                                          beamIntegr, *theTransf2d);
00686     else
00687       theElement = new ForceBeamColumn3d(eleTag, iNode, jNode, nIP+2, sections,
00688                                          beamIntegr, *theTransf3d);
00689     
00690     delete [] sections;
00691   }
00692 
00693   else if (strcmp(argv[6],"DistHinge") == 0) {
00694     
00695     if (argc < 16) {
00696       opserr << "WARNING insufficient arguments\n";
00697       printCommand(argc, argv);
00698       opserr << "Want: element forceBeamColumn eleTag? iNode? jNode? transfTag? type distType nIP? secTagI? lpI? secTagJ? lpJ? secTagE?\n";
00699       return TCL_ERROR;
00700     }
00701 
00702     int secTagI, secTagJ, secTagE;
00703     double lpI, lpJ;
00704     int nIP;
00705 
00706     BeamIntegration *otherBeamInt = 0;
00707     if (strcmp(argv[7],"Lobatto") == 0)
00708       otherBeamInt = new LobattoBeamIntegration();
00709     else if (strcmp(argv[7],"Legendre") == 0)
00710       otherBeamInt = new LegendreBeamIntegration();
00711     else if (strcmp(argv[7],"Radau") == 0)
00712       otherBeamInt = new RadauBeamIntegration();
00713     else if (strcmp(argv[7],"NewtonCotes") == 0)
00714       otherBeamInt = new NewtonCotesBeamIntegration();
00715     //else if (strcmp(argv[7],"Trapezoidal") == 0)
00716     //  otherBeamInt = new TrapezoidalBeamIntegration();
00717     else {
00718       opserr << "ERROR: invalid integration type: " << argv[7] << endln;
00719       return TCL_ERROR;
00720     }
00721 
00722     if (Tcl_GetInt(interp, argv[8], &nIP) != TCL_OK) {
00723       opserr << "WARNING invalid nIP\n";
00724       opserr << "forceBeamColumn element: " << eleTag << endln;
00725       return TCL_ERROR;
00726     }
00727     if (Tcl_GetInt(interp, argv[9], &secTagI) != TCL_OK) {
00728       opserr << "WARNING invalid secTagI\n";
00729       opserr << "forceBeamColumn element: " << eleTag << endln;
00730       return TCL_ERROR;
00731     }
00732     if (Tcl_GetDouble(interp, argv[10], &lpI) != TCL_OK) {
00733       opserr << "WARNING invalid lpI\n";
00734       opserr << "forceBeamColumn element: " << eleTag << endln;
00735       return TCL_ERROR;
00736     }
00737     if (Tcl_GetInt(interp, argv[11], &secTagJ) != TCL_OK) {
00738       opserr << "WARNING invalid secTagJ\n";
00739       opserr << "forceBeamColumn element: " << eleTag << endln;
00740       return TCL_ERROR;
00741     }
00742     if (Tcl_GetDouble(interp, argv[12], &lpJ) != TCL_OK) {
00743       opserr << "WARNING invalid lpJ\n";
00744       opserr << "forceBeamColumn element: " << eleTag << endln;
00745       return TCL_ERROR;
00746     }
00747     if (Tcl_GetInt(interp, argv[13], &secTagE) != TCL_OK) {
00748       opserr << "WARNING invalid secTagE\n";
00749       opserr << "forceBeamColumn element: " << eleTag << endln;
00750       return TCL_ERROR;
00751     }
00752 
00753     SectionForceDeformation *sectionI = theTclBuilder->getSection(secTagI);
00754     if (sectionI == 0) {
00755       opserr << "WARNING section not found\n";
00756       opserr << "Section: " << secTagI;
00757       opserr << "\nforceBeamColumn element: " << eleTag << endln;
00758       return TCL_ERROR;
00759     }
00760     SectionForceDeformation *sectionJ = theTclBuilder->getSection(secTagJ);
00761     if (sectionJ == 0) {
00762       opserr << "WARNING section not found\n";
00763       opserr << "Section: " << secTagJ;
00764       opserr << "\nforceBeamColumn element: " << eleTag << endln;
00765       return TCL_ERROR;
00766     }
00767     
00768     SectionForceDeformation *sectionE = theTclBuilder->getSection(secTagE);
00769     if (sectionJ == 0) {
00770       opserr << "WARNING section not found\n";
00771       opserr << "Section: " << secTagE;
00772       opserr << "\nforceBeamColumn element: " << eleTag << endln;
00773       return TCL_ERROR;
00774     }
00775     
00776     int numSections = 2*nIP;
00777     SectionForceDeformation **sections = new SectionForceDeformation *[numSections];
00778     for (int i = 0; i < nIP; i++) {
00779       sections[i] = sectionI;
00780       sections[numSections-1-i] = sectionJ;
00781     }
00782 
00783     sections[numSections]   = sectionE;
00784     sections[numSections+1] = sectionE;
00785     
00786     DistHingeIntegration beamIntegr(lpI, lpJ, *otherBeamInt);
00787 
00788     if (ndm == 2)
00789       theElement = new ForceBeamColumn2d(eleTag, iNode, jNode, numSections+2,
00790                                          sections, beamIntegr, *theTransf2d);
00791     else
00792       theElement = new ForceBeamColumn3d(eleTag, iNode, jNode, numSections+2,
00793                                          sections, beamIntegr, *theTransf3d);
00794 
00795     if (otherBeamInt != 0)
00796       delete otherBeamInt;
00797     delete [] sections;
00798   }
00799 
00800   else if (strcmp(argv[6],"FixedLocation") == 0) {
00801 
00802     if (argc < 9) {
00803       opserr << "WARNING insufficient arguments\n";
00804       printCommand(argc, argv);
00805       opserr << "Want: element forceBeamColumn eleTag? iNode? jNode? transfTag? FixedLocation nIP? secTag1? ... pt1? ... \n";
00806       return TCL_ERROR;
00807     }
00808 
00809     int nIP;
00810     
00811     if (Tcl_GetInt(interp, argv[7], &nIP) != TCL_OK) {
00812       opserr << "WARNING invalid nIP\n";
00813       opserr << "forceBeamColumn element: " << eleTag << endln;
00814       return TCL_ERROR;
00815     }
00816     
00817     ID secs(nIP);
00818     Vector pts(nIP);
00819     Vector wts(nIP);
00820 
00821     int i, j;
00822     for (i = 0, j = 8; i < nIP; i++, j++) {
00823       int sec;
00824       double pt;
00825       if (Tcl_GetInt(interp, argv[j], &sec) != TCL_OK) {
00826         opserr << "WARNING invalid sec\n";
00827         opserr << "forceBeamColumn element: " << eleTag << endln;
00828         return TCL_ERROR;
00829       }
00830       if (Tcl_GetDouble(interp, argv[j+nIP], &pt) != TCL_OK) {
00831         opserr << "WARNING invalid pt\n";
00832         opserr << "forceBeamColumn element: " << eleTag << endln;
00833         return TCL_ERROR;
00834       }
00835       secs(i) = sec;
00836       pts(i)  = pt;
00837     }
00838     
00839     SectionForceDeformation **sections = new SectionForceDeformation *[nIP];
00840     for (i = 0; i < nIP; i++) {
00841       SectionForceDeformation *theSection = theTclBuilder->getSection(secs(i));
00842       if (theSection == 0) {
00843         opserr << "WARNING section not found\n";
00844         opserr << "Section: " << secs(i);
00845         opserr << "\nforceBeamColumn element: " << eleTag << endln;
00846         return TCL_ERROR;
00847       }
00848       sections[i] = theSection;
00849     }
00850     
00851     /*
00852     FixedLocationBeamIntegration beamIntegr(nIP, pts);
00853 
00854     if (ndm == 2)
00855       theElement = new ForceBeamColumn2d(eleTag, iNode, jNode, nIP, sections,
00856                                          beamIntegr, *theTransf2d);
00857     else
00858       theElement = new ForceBeamColumn3d(eleTag, iNode, jNode, nIP, sections,
00859                                          beamIntegr, *theTransf3d);
00860     */
00861 
00862     delete [] sections;
00863   }
00864 
00865   else if (strcmp(argv[6],"LowOrder") == 0) {
00866 
00867     if (argc < 9) {
00868       opserr << "WARNING insufficient arguments\n";
00869       printCommand(argc, argv);
00870       opserr << "Want: element forceBeamColumn eleTag? iNode? jNode? transfTag? LowOrder nIP? secTag1? ... pt1? ... wt1? ...\n";
00871       return TCL_ERROR;
00872     }
00873 
00874     int nIP;
00875     
00876     if (Tcl_GetInt(interp, argv[7], &nIP) != TCL_OK) {
00877       opserr << "WARNING invalid nIP\n";
00878       opserr << "forceBeamColumn element: " << eleTag << endln;
00879       return TCL_ERROR;
00880     }
00881     
00882     ID secs(nIP);
00883     Vector pts(nIP);
00884     Vector wts(nIP);
00885 
00886     int i, j;
00887     int nc = 0;
00888     for (i = 0, j = 8; i < nIP; i++, j++) {
00889       int sec;
00890       double pt, wt;
00891       if (Tcl_GetInt(interp, argv[j], &sec) != TCL_OK) {
00892         opserr << "WARNING invalid sec\n";
00893         opserr << "forceBeamColumn element: " << eleTag << endln;
00894         return TCL_ERROR;
00895       }
00896       secs(i) = sec;
00897 
00898       if (Tcl_GetDouble(interp, argv[j+nIP], &pt) != TCL_OK) {
00899         opserr << "WARNING invalid pt\n";
00900         opserr << "forceBeamColumn element: " << eleTag << endln;
00901         return TCL_ERROR;
00902       }
00903       pts(i)  = pt;
00904 
00905       if (j+2*nIP < argc) {
00906         if (Tcl_GetDouble(interp, argv[j+2*nIP], &wt) != TCL_OK) {
00907           opserr << "WARNING invalid wt\n";
00908           opserr << "forceBeamColumn element: " << eleTag << endln;
00909           return TCL_ERROR;
00910         }
00911         else {
00912           wts(i)  = wt;
00913           nc++;
00914         }
00915       }
00916     }
00917     
00918     SectionForceDeformation **sections = new SectionForceDeformation *[nIP];
00919     for (i = 0; i < nIP; i++) {
00920       SectionForceDeformation *theSection = theTclBuilder->getSection(secs(i));
00921       if (theSection == 0) {
00922         opserr << "WARNING section not found\n";
00923         opserr << "Section: " << secs(i);
00924         opserr << "\nforceBeamColumn element: " << eleTag << endln;
00925         return TCL_ERROR;
00926       }
00927       sections[i] = theSection;
00928     }
00929     
00930     /*
00931     LowOrderBeamIntegration beamIntegr(nIP, pts, nc, wts);
00932 
00933     if (ndm == 2)
00934       theElement = new ForceBeamColumn2d(eleTag, iNode, jNode, nIP, sections,
00935                                          beamIntegr, *theTransf2d);
00936     else
00937       theElement = new ForceBeamColumn3d(eleTag, iNode, jNode, nIP, sections,
00938                                          beamIntegr, *theTransf3d);
00939     */
00940 
00941     delete [] sections;
00942   }
00943 
00944   else if (strcmp(argv[6],"MidDistance") == 0) {
00945 
00946     if (argc < 9) {
00947       opserr << "WARNING insufficient arguments\n";
00948       printCommand(argc, argv);
00949       opserr << "Want: element forceBeamColumn eleTag? iNode? jNode? transfTag? MidDistance nIP? secTag1? ... pt1? ... \n";
00950       return TCL_ERROR;
00951     }
00952 
00953     int nIP;
00954     
00955     if (Tcl_GetInt(interp, argv[7], &nIP) != TCL_OK) {
00956       opserr << "WARNING invalid nIP\n";
00957       opserr << "forceBeamColumn element: " << eleTag << endln;
00958       return TCL_ERROR;
00959     }
00960     
00961     ID secs(nIP);
00962     Vector pts(nIP);
00963     Vector wts(nIP);
00964 
00965     int i, j;
00966     for (i = 0, j = 8; i < nIP; i++, j++) {
00967       int sec;
00968       double pt;
00969       if (Tcl_GetInt(interp, argv[j], &sec) != TCL_OK) {
00970         opserr << "WARNING invalid sec\n";
00971         opserr << "forceBeamColumn element: " << eleTag << endln;
00972         return TCL_ERROR;
00973       }
00974       if (Tcl_GetDouble(interp, argv[j+nIP], &pt) != TCL_OK) {
00975         opserr << "WARNING invalid pt\n";
00976         opserr << "forceBeamColumn element: " << eleTag << endln;
00977         return TCL_ERROR;
00978       }
00979       secs(i) = sec;
00980       pts(i)  = pt;
00981     }
00982     
00983     SectionForceDeformation **sections = new SectionForceDeformation *[nIP];
00984     for (i = 0; i < nIP; i++) {
00985       SectionForceDeformation *theSection = theTclBuilder->getSection(secs(i));
00986       if (theSection == 0) {
00987         opserr << "WARNING section not found\n";
00988         opserr << "Section: " << secs(i);
00989         opserr << "\nforceBeamColumn element: " << eleTag << endln;
00990         return TCL_ERROR;
00991       }
00992       sections[i] = theSection;
00993     }
00994     
00995     /*
00996     MidDistanceBeamIntegration beamIntegr(nIP, pts);
00997 
00998     if (ndm == 2)
00999       theElement = new ForceBeamColumn2d(eleTag, iNode, jNode, nIP, sections,
01000                                          beamIntegr, *theTransf2d);
01001     else
01002       theElement = new ForceBeamColumn3d(eleTag, iNode, jNode, nIP, sections,
01003                                          beamIntegr, *theTransf3d);
01004     */
01005 
01006     delete [] sections;
01007   }
01008 
01009   else {
01010     opserr << "Unknown integration type: " << argv[6] << endln;
01011     opserr << "forceBeamColumn element: " << eleTag << endln;
01012     return TCL_ERROR;
01013   }
01014   
01015   if (theElement == 0) {
01016     opserr << "WARNING ran out of memory creating element\n";
01017     opserr << "forceBeamColumn element: " << eleTag << endln;
01018     return TCL_ERROR;
01019   }
01020   
01021   if (theTclDomain->addElement(theElement) == false) {
01022     opserr << "WARNING could not add element to the domain\n";
01023     opserr << "forceBeamColumn element: " << eleTag << endln;
01024     delete theElement;
01025     return TCL_ERROR;
01026   }
01027   
01028   // if get here we have sucessfully created the element and added it to the domain
01029   return TCL_OK;
01030 }

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