TclNLBeamColumnCommand.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.4 $
00022 // $Date: 2003/04/18 16:31:44 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/element/nonlinearBeamColumn/element/TclNLBeamColumnCommand.cpp,v $
00024                                                                                                                                  
00025 // Written: Remo M. de Souza (rmsouza@ce.berkeley.edu)
00026 // Created: 08/99
00027 //
00028 // Description: This file contains the implementation of the commands used 
00029 // to add coordinate transformation objects  and nonlinear frame elements to the model.
00030 
00031 #include <stdlib.h>
00032 #include <string.h>
00033 
00034 #include <Domain.h>
00035 #include <Node.h>
00036 #include <Matrix.h>
00037 
00038 #include <SectionForceDeformation.h>
00039 
00040 #include <NLBeamColumn2d.h>
00041 #include <NLBeamColumn3d.h>
00042 
00043 #include <LobattoBeamIntegration.h>
00044 #include <ForceBeamColumn2d.h>
00045 #include <ForceBeamColumn3d.h>
00046 
00047 // #include <LargeDispBeamColumn3d.h>
00048 
00049 #include <GaussLobattoQuadRule1d01.h>
00050 #include <TclModelBuilder.h>
00051 
00052 //
00053 // some static variables used in the functions
00054 //
00055 
00056 static Domain *theTclModelBuilderDomain = 0;
00057 static TclModelBuilder *theTclModelBuilder =0;
00058 
00059 // 
00060 // to create a NL frame element and add to the domain
00061 //
00062 int
00063 TclModelBuilder_addNLBeamColumn(ClientData clientData, Tcl_Interp *interp,
00064                                 int inArgc, TCL_Char **inArgv,
00065                                 Domain *theDomain,
00066                                 TclModelBuilder *theBuilder)
00067                                 
00068 {
00069   theTclModelBuilderDomain = theDomain;
00070   theTclModelBuilder = theBuilder;
00071     
00072   int NDM, NDF;
00073      
00074   NDM = theTclModelBuilder->getNDM();   // dimension of the structure (1d, 2d, or 3d)
00075   NDF = theTclModelBuilder->getNDF();   // number of degrees of freedom per node
00076 
00077   // split possible lists present in argv
00078   char *List;
00079 
00080   List = Tcl_Merge (inArgc, inArgv);
00081   if (List == 0)
00082   {
00083     opserr << "WARNING - TclModelBuilder_addFrameElement - problem merging list\n";
00084     return TCL_ERROR;
00085   }
00086 
00087 //  opserr << "List :" << List << endln;
00088 
00089   // remove braces from list
00090   for (int i = 0; List[i] != '\0'; i++)
00091   {
00092     if ((List[i] == '{')  ||  (List[i] == '}'))
00093       List[i] = ' ';
00094   }
00095   
00096   int argc;
00097   TCL_Char **argv;
00098        
00099   if (Tcl_SplitList(interp, List, &argc, &argv) != TCL_OK)
00100   {
00101     opserr <<  "WARNING - TclModelBuilder_addFrameElement - problem spliting list\n";
00102     return TCL_ERROR;
00103   }
00104       
00105   Tcl_Free (List);
00106   
00107 //  opserr << "argc : " << argc; 
00108 //  for (int i=0; i<argc; i++)
00109 //  {
00110 //    opserr <<"string " << i << " : " << argv[i] << endln;
00111 //  }
00112 
00113 
00114   // create plane frame elements
00115   if ((NDM == 2 && NDF == 3) || (NDM == 3 && NDF == 6)) {
00116     
00117     int eleTag, iNode, jNode, numIntgrPts, transfTag;
00118     int secTag[10]; // Max size of integration rule ... can change if needed
00119     
00120     if (argc < 8) {
00121       opserr << "WARNING bad command - want: element nonlinearBeamColumn eleTag? iNode? jNode? numIntgrPts? secTag? transfTag? <-mass massDens?> <-iter nMaxLocIters? locToler?>\n";
00122       return TCL_ERROR;
00123     }
00124     int argi = 2;  
00125     if (Tcl_GetInt(interp, argv[argi++], &eleTag) != TCL_OK) {
00126       opserr << "WARNING invalid eleTag: element nonlinearBeamColumn eleTag? iNode? jNode? numIntgrPts? secTag? transfTag? <-mass massDens?> <-iter nMaxLocIters? locToler?>\n"; 
00127       return TCL_ERROR;
00128     }
00129 
00130     if (Tcl_GetInt(interp, argv[argi++], &iNode) != TCL_OK) {
00131       opserr << "WARNING invalid iNode:  element nonlinearBeamColumn eleTag? iNode? jNode? numIntgrPts? secTag? transfTag? <-mass massDens?> <-iter nMaxLocIters? locToler?>\n";
00132       return TCL_ERROR;
00133     }
00134 
00135     if (Tcl_GetInt(interp, argv[argi++], &jNode) != TCL_OK) {
00136       opserr << "WARNING invalid jNode: element nonlinearBeamColumn eleTag? iNode? jNode? numIntgrPts? secTag? transfTag? <-mass massDens?> <-iter nMaxLocIters? locToler?>\n";
00137       return TCL_ERROR;
00138     }
00139 
00140     if (Tcl_GetInt(interp, argv[argi++], &numIntgrPts) != TCL_OK) {
00141       opserr << "WARNING invalid numIntgrPts: element nonlinearBeamColumn eleTag? iNode? jNode? numIntgrPts? secTag? transfTag? <-mass massDens?> <-iter nMaxLocIters? locToler?>\n";
00142       return TCL_ERROR;
00143     }
00144 
00145     if (strcmp(argv[argi], "-sections") == 0) {
00146       argi++;
00147       if (argi+numIntgrPts > argc) {
00148         opserr << "WARNING insufficient number of section tags - element nonlinearBeamColumn eleTag? iNode? jNode? numIntgrPts? secTag? transfTag? <-mass massDens?> <-iter nMaxLocIters? locToler?>\n";
00149         return TCL_ERROR;
00150       }
00151       int section;
00152       for (int i = 0; i < numIntgrPts; i++) {
00153         if (Tcl_GetInt(interp, argv[argi+i], &section) != TCL_OK) {
00154           opserr << "WARNING invalid secTag - element nonlinearBeamColumn eleTag? iNode? jNode? numIntgrPts? secTag? transfTag? <-mass massDens?> <-iter nMaxLocIters? locToler?>\n";
00155           return TCL_ERROR;
00156         }
00157         secTag[i] = section;
00158       }
00159       argi += numIntgrPts;
00160     }
00161 
00162     else {
00163       int section;
00164       if (Tcl_GetInt(interp, argv[argi++], &section) != TCL_OK) {
00165         opserr << "WARNING invalid secTag - element nonlinearBeamColumn eleTag? iNode? jNode? numIntgrPts? secTag? transfTag? <-mass massDens?> <-iter nMaxLocIters? locToler?>\n";
00166         return TCL_ERROR;
00167       }
00168       for (int i = 0; i < numIntgrPts; i++)
00169         secTag[i] = section;
00170     }
00171 
00172     if (argi >= argc || Tcl_GetInt(interp, argv[argi++], &transfTag) != TCL_OK) {
00173       opserr << "WARNING invalid transfTag? - element nonlinearBeamColumn eleTag? iNode? jNode? numIntgrPts? secTag? transfTag? <-mass massDens?> <-iter nMaxLocIters? locToler?>\n";
00174       return TCL_ERROR;
00175     }
00176 
00177     // some  additional options at end of command .. setting defaults of 10 and 1.0e-10
00178     double massDens = 0.0;
00179     int    nMaxLocIters = 10;
00180     double locToler = 1e-08;
00181     
00182     while (argi != argc) {
00183       if (strcmp(argv[argi],"-mass") == 0) {
00184         // allow user to specify mass (per unit length)
00185         argi++;
00186         if (argi == argc || Tcl_GetDouble(interp, argv[argi++], &massDens) != TCL_OK) {
00187           opserr << "WARNING invalid massDens - element nonlinearBeamColumn eleTag? iNode? jNode? numIntgrPts? secTag? transfTag? <-mass massDens?> <-iter nMaxLocIters? locToler?>\n";
00188           return TCL_ERROR;
00189         } 
00190       }
00191 
00192       else if (strcmp(argv[argi],"-iter") == 0) {
00193         // allow user to specify maximum number of local iterations
00194         argi++;
00195         if (argi == argc || Tcl_GetInt(interp, argv[argi++], &nMaxLocIters) != TCL_OK) {
00196           opserr << "WARNING invalid nMaxLocIters - element nonlinearBeamColumn eleTag? iNode? jNode? numIntgrPts? secTag? transfTag? <-mass massDens?> <-iter nMaxLocIters? locToler?>\n";
00197           return TCL_ERROR;
00198         } 
00199 
00200         // specify local tolerance 
00201         if (argi == argc || Tcl_GetDouble(interp, argv[argi++], &locToler) != TCL_OK) {
00202           opserr << "WARNING invalid locToler - element nonlinearBeamColumn eleTag? iNode? jNode? numIntgrPts? secTag? transfTag? <-mass massDens?> <-iter nMaxLocIters? locToler?>\n";
00203           return TCL_ERROR;
00204         } 
00205       }
00206       else {
00207         opserr << "WARNING bad command  - element nonlinearBeamColumn eleTag? iNode? jNode? numIntgrPts? secTag? transfTag? <-mass massDens?> <-iter nMaxLocIters? locToler?>\n";
00208         opserr << "invalid: " << argv[argi] << endln;
00209         return TCL_ERROR;
00210       }
00211     }
00212     
00213     // create the element
00214 
00215     // get pointer to the sections for the whole beam
00216 
00217     SectionForceDeformation **sections = new SectionForceDeformation* [numIntgrPts];
00218     
00219     if (!sections) {
00220       opserr << "WARNING TclElmtBuilder - addFrameElement - Insufficient memory to create sections\n";
00221       return TCL_ERROR;
00222     }
00223 
00224     for (int j=0; j<numIntgrPts; j++) {
00225       SectionForceDeformation *theSection = theTclModelBuilder->getSection(secTag[j]);
00226 
00227       if (theSection == 0) {
00228         opserr << "WARNING TclElmtBuilder - frameElement - no Section found with tag ";
00229         opserr << secTag[j] << endln;
00230         delete [] sections;
00231         return TCL_ERROR;
00232       }
00233 
00234       sections[j] = theSection;
00235     }
00236 
00237     // opserr << "massDens " << massDens << endln;
00238      
00239     // construct the element
00240 
00241     Element *element = 0;
00242     if (NDM == 2) {
00243       CrdTransf2d *theCrdTransf = theTclModelBuilder->getCrdTransf2d(transfTag);
00244       
00245       if (theCrdTransf == 0) {
00246         opserr << "WARNING TclElmtBuilder - frameElement - no geometric transformation found with tag ";
00247         opserr << transfTag << endln;
00248         return TCL_ERROR;
00249       }
00250       
00251       //element = new NLBeamColumn2d(eleTag, iNode, jNode, numIntgrPts, sections,
00252       //                           *theCrdTransf, massDens, nMaxLocIters, locToler, 10);
00253       LobattoBeamIntegration beamIntegr;
00254       element = new ForceBeamColumn2d(eleTag, iNode, jNode, numIntgrPts,
00255                                       sections, beamIntegr, *theCrdTransf,
00256                                       massDens, nMaxLocIters, locToler);
00257       
00258       delete [] sections;
00259     }
00260     else {
00261       CrdTransf3d *theCrdTransf = theTclModelBuilder->getCrdTransf3d(transfTag);
00262       
00263       if (theCrdTransf == 0) {
00264         opserr << "WARNING TclElmtBuilder - frameElement - no geometric transformation found with tag ";
00265         opserr << transfTag << endln;
00266         return TCL_ERROR;
00267       }
00268       
00269       //element = new NLBeamColumn3d(eleTag, iNode, jNode, numIntgrPts, sections,
00270       //                           *theCrdTransf, massDens, nMaxLocIters, locToler);
00271         
00272       LobattoBeamIntegration beamIntegr;
00273       element = new ForceBeamColumn3d(eleTag, iNode, jNode, numIntgrPts,
00274                                       sections, beamIntegr, *theCrdTransf,
00275                                       massDens, nMaxLocIters, locToler);
00276 
00277       delete [] sections;
00278     }
00279 
00280     if (element == 0) {
00281       opserr << "WARNING  TclElmtBuilder - addFrameElement - ran out of memory to create element\n";
00282       return TCL_ERROR;
00283     }
00284    
00285     if (theTclModelBuilderDomain->addElement(element) == false) {
00286       opserr << "WARNING TclElmtBuilder - addFrameElement - could not add element to domain ";
00287       opserr << eleTag << endln;
00288       return TCL_ERROR;
00289     } 
00290     
00291   }
00292   else {
00293     opserr << "WARNING NDM = " << NDM << " and NDF = " << NDF << "is imcompatible with available frame elements\n";
00294     return TCL_ERROR;
00295   }      
00296 
00297   Tcl_Free ((char *)argv);
00298 
00299   // if get here we have sucessfully created the element and added it to the domain
00300   
00301   return TCL_OK;
00302 }

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