TclBeamWithHingesBuilder.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.14 $
00022 // $Date: 2006/01/24 18:51:53 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/element/beamWithHinges/TclBeamWithHingesBuilder.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/tcl/TclElmtBuilder.C
00027 // 
00028 // Written: Remo M. de Souza
00029 // Created: 08/99
00030 // based on TclPlaneFrame.C by fmk and rms
00031 //
00032 // Description: This file contains the implementation of the commands used 
00033 // to add sections and nonlinear frame elements to the model.
00034 
00035 #include <stdlib.h>
00036 #include <string.h>
00037 #include <math.h>
00038 
00039 #include <Domain.h>
00040 #include <Node.h>
00041 #include <Matrix.h>
00042 
00043 
00044 #include <ForceBeamColumn2d.h>
00045 #include <ForceBeamColumn3d.h>
00046 
00047 #include <HingeMidpointBeamIntegration.h>
00048 #include <HingeEndpointBeamIntegration.h>
00049 #include <HingeRadauTwoBeamIntegration.h>
00050 #include <HingeRadauBeamIntegration.h>
00051 
00052 #include <ElasticSection2d.h>
00053 #include <ElasticSection3d.h>
00054 
00055 #include <SectionForceDeformation.h>
00056 
00057 #include <CrdTransf2d.h>
00058 #include <CrdTransf3d.h>
00059 
00060 #include <TclModelBuilder.h>
00061 
00062 static void printCommand(int argc, TCL_Char **argv)
00063 {
00064     opserr << "Input command: ";
00065     for (int i=0; i<argc; i++)
00066         opserr << argv[i] << " ";
00067     opserr << endln;
00068 } 
00069 
00070 int
00071 TclModelBuilder_addBeamWithHinges (ClientData clientData, Tcl_Interp *interp,
00072                                    int argc, TCL_Char **argv,
00073                                    Domain *theDomain, TclModelBuilder *theBuilder)              
00074 {
00075     int NDM = theBuilder->getNDM();
00076     int NDF = theBuilder->getNDF();
00077     
00078     // Plane frame element
00079     if (NDM == 2 && NDF == 3) {
00080         if (argc < 13) {
00081             opserr << "WARNING insufficient arguments\n";
00082             printCommand(argc,argv);
00083             opserr << "Want: element beamWithHinges tag? ndI? ndJ? secTagI? lenI? secTagJ? lenJ? ";
00084             opserr << "E? A? I? transfTag? <-shear shearLength?> <-mass massDens?> <-iter maxIters tolerance>" << endln;
00085             return TCL_ERROR;
00086         }
00087 
00088         int tag, ndI, ndJ, secTagI, secTagJ, transfTag;
00089         double lenI, lenJ, E, A, I;
00090         double massDens = 0.0;
00091         int numIters = 10;
00092         double tol = 1.0e-10;
00093     
00094         if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK) {
00095             opserr << "WARNING invalid beamWithHinges tag" << endln;
00096             return TCL_ERROR;           
00097         }
00098 
00099         if (Tcl_GetInt(interp, argv[3], &ndI) != TCL_OK) {
00100             opserr << "WARNING invalid ndI\n";
00101             opserr << "BeamWithHinges: " << tag << endln;
00102             return TCL_ERROR;   
00103         }
00104 
00105         if (Tcl_GetInt(interp, argv[4], &ndJ) != TCL_OK) {
00106             opserr << "WARNING invalid ndJ\n";
00107             opserr << "BeamWithHinges: " << tag << endln;
00108             return TCL_ERROR;   
00109         }
00110 
00111         if (Tcl_GetInt(interp, argv[5], &secTagI) != TCL_OK) {
00112             opserr << "WARNING invalid secTagI\n";
00113             opserr << "BeamWithHinges: " << tag << endln;
00114             return TCL_ERROR;   
00115         }
00116 
00117         if (Tcl_GetDouble (interp, argv[6], &lenI) != TCL_OK) {
00118             opserr << "WARNING invalid lenI\n";
00119             opserr << "BeamWithHinges: " << tag << endln;
00120             return TCL_ERROR;
00121         }
00122 
00123         if (Tcl_GetInt(interp, argv[7], &secTagJ) != TCL_OK) {
00124             opserr << "WARNING invalid ndJ\n";
00125             opserr << "BeamWithHinges: " << tag << endln;
00126             return TCL_ERROR;   
00127         }
00128 
00129         if (Tcl_GetDouble (interp, argv[8], &lenJ) != TCL_OK) {
00130             opserr << "WARNING invalid lenJ\n";
00131             opserr << "BeamWithHinges: " << tag << endln;
00132             return TCL_ERROR;
00133         }
00134 
00135         if (Tcl_GetDouble (interp, argv[9], &E) != TCL_OK) {
00136             opserr << "WARNING invalid E\n";
00137             opserr << "BeamWithHinges: " << tag << endln;
00138             return TCL_ERROR;
00139         }
00140 
00141         if (Tcl_GetDouble (interp, argv[10], &A) != TCL_OK) {
00142             opserr << "WARNING invalid A\n";
00143             opserr << "BeamWithHinges: " << tag << endln;
00144             return TCL_ERROR;
00145         }
00146 
00147         if (Tcl_GetDouble (interp, argv[11], &I) != TCL_OK) {
00148             opserr << "WARNING invalid I\n";
00149             opserr << "BeamWithHinges: " << tag << endln;
00150             return TCL_ERROR;
00151         }
00152         
00153         if (Tcl_GetInt (interp, argv[12], &transfTag) != TCL_OK) {
00154             opserr << "WARNING invalid transfTag\n";
00155             opserr << "BeamWithHinges: " << tag << endln;
00156             return TCL_ERROR;
00157         }       
00158 
00159         bool useFour = false;
00160         bool isShear = false;
00161         int shearTag = 0;
00162 
00163         if (argc > 13) {
00164             for (int i = 13; i < argc; i++) {
00165                 if (strcmp(argv[i],"-mass") == 0 && ++i < argc) {
00166                     if (Tcl_GetDouble(interp, argv[i], &massDens) != TCL_OK) {
00167                         opserr << "WARNING invalid massDens\n";
00168                         opserr << "BeamWithHinges: " << tag << endln;
00169                         return TCL_ERROR;
00170                     }
00171                 }
00172                 
00173                 if (strcmp(argv[i],"-constHinge") == 0 && ++i < argc) {
00174                     if (Tcl_GetInt(interp, argv[i], &shearTag) != TCL_OK) {
00175                         opserr << "WARNING invalid constHinge tag\n";
00176                         opserr << "BeamWithHinges: " << tag << endln;
00177                         return TCL_ERROR;
00178                     }
00179                     isShear = true;
00180                 }
00181 
00182                 if (strcmp(argv[i],"-iter") == 0 && i+2 < argc) {
00183                         if (Tcl_GetInt(interp, argv[++i], &numIters) != TCL_OK) {
00184                                 opserr << "WARNING invalid maxIters\n";
00185                                 opserr << "BeamWithHinges: " << tag << endln;
00186                                 return TCL_ERROR;
00187                     }
00188                         if (Tcl_GetDouble(interp, argv[++i], &tol) != TCL_OK) {
00189                           opserr << "WARNING invalid tolerance\n";
00190                           opserr << "BeamWithHinges: " << tag << endln;
00191                           return TCL_ERROR;
00192                         }
00193                 }
00194                 if (strcmp(argv[i],"-useFour") == 0)
00195                   useFour = true;
00196             }
00197         }       
00198         
00199         // Retrieve section I from the model builder    
00200         SectionForceDeformation *sectionI = theBuilder->getSection (secTagI);
00201 
00202         if (sectionI == 0) {
00203             opserr << "WARNING section I does not exist\n";
00204             opserr << "section: " << secTagI; 
00205             opserr << "\nBeamWithHinges: " << tag << endln;
00206             return TCL_ERROR;
00207         }
00208 
00209         // Retrieve section J from the model builder    
00210         SectionForceDeformation *sectionJ = theBuilder->getSection (secTagJ);
00211 
00212         if (sectionJ == 0) {
00213             opserr << "WARNING section J does not exist\n";
00214             opserr << "section: " << secTagJ; 
00215             opserr << "\nBeamWithHinges: " << tag << endln;
00216             return TCL_ERROR;
00217         }
00218 
00219         CrdTransf2d *theTransf = theBuilder->getCrdTransf2d (transfTag);
00220 
00221         if (theTransf == 0) {
00222             opserr << "WARNING geometric transformation does not exist\n";
00223             opserr << "geometric transformation: " << transfTag; 
00224             opserr << "\nBeamWithHinges: " << tag << endln;
00225             return TCL_ERROR;
00226         }       
00227         
00228         Element *theElement = 0;
00229         int numSections = 0;
00230         SectionForceDeformation *sections[10];
00231         BeamIntegration *theBeamIntegr = 0;
00232 
00233         ElasticSection2d elastic(0, E, A, I);
00234 
00235         if (strcmp(argv[1],"beamWithHinges1") == 0) {
00236           theBeamIntegr =
00237             new HingeMidpointBeamIntegration(lenI, lenJ);
00238 
00239           numSections = 4;
00240 
00241           sections[0] = sectionI;
00242           sections[1] = &elastic;
00243           sections[2] = &elastic;
00244           sections[3] = sectionJ;
00245         }
00246         else if (strcmp(argv[1],"beamWithHinges2") == 0) {
00247           theBeamIntegr =
00248             new HingeRadauTwoBeamIntegration(lenI, lenJ);
00249           
00250           numSections = 6;
00251           sections[0] = sectionI;
00252           sections[1] = sectionI;
00253           sections[2] = &elastic;
00254           sections[3] = &elastic;
00255           sections[4] = sectionJ;
00256           sections[5] = sectionJ;
00257         }
00258         else if (strcmp(argv[1],"beamWithHinges3") == 0 ||
00259                  strcmp(argv[1],"beamWithHinges") == 0) {
00260           theBeamIntegr =
00261             new HingeRadauBeamIntegration(lenI, lenJ);
00262           
00263           numSections = 6;
00264           sections[0] = sectionI;
00265           sections[1] = &elastic;
00266           sections[2] = &elastic;
00267           sections[3] = &elastic;
00268           sections[4] = &elastic;
00269           sections[5] = sectionJ;
00270         }
00271         else if (strcmp(argv[1],"beamWithHinges4") == 0) {
00272           theBeamIntegr =
00273             new HingeEndpointBeamIntegration(lenI, lenJ);
00274           
00275           numSections = 4;
00276           sections[0] = sectionI;
00277           sections[1] = &elastic;
00278           sections[2] = &elastic;
00279           sections[3] = sectionJ;
00280         }
00281 
00282         if (theBeamIntegr == 0) {
00283           opserr << "Unknown element type: " << argv[1] << endln;
00284           return TCL_ERROR;
00285         }
00286 
00287         if (isShear) {
00288           SectionForceDeformation *sectionL = theBuilder->getSection(shearTag);
00289 
00290           if (sectionL == 0) {
00291             opserr << "WARNING section L does not exist\n";
00292             opserr << "section: " << shearTag; 
00293             opserr << "\nBeamWithHinges: " << tag << endln;
00294             return TCL_ERROR;
00295           }
00296           sections[numSections++] = sectionL;
00297         }
00298 
00299         theElement = new ForceBeamColumn2d(tag, ndI, ndJ, numSections,
00300                                            sections, *theBeamIntegr,
00301                                            *theTransf,massDens,numIters,tol);
00302 
00303         delete theBeamIntegr;
00304 
00305         // Ensure we have created the element, out of memory if got here and no element
00306         if (theElement == 0) {
00307             opserr << "WARNING ran out of memory creating element\n";
00308             opserr << "BeamWithHinges: " << tag << endln;
00309             return TCL_ERROR;
00310         }
00311 
00312         if (theDomain->addElement(theElement) == false) {
00313             opserr << "WARNING TclElmtBuilder - addBeamWithHinges - could not add element to domain ";
00314             opserr << tag << endln;
00315             return TCL_ERROR;
00316         }
00317     }
00318     
00319     else if (NDM == 3 && NDF == 6) {
00320         if (argc < 16) {
00321             opserr << "WARNING insufficient arguments\n";
00322             printCommand(argc,argv);
00323             opserr << "Want: element beamWithHinges tag? ndI? ndJ? secTagI? lenI? secTagJ? lenJ? ";
00324             opserr << "E? A? Iz? Iy? G? J? transfTag? <-shear shearLength?> <-mass massDens?> <-iter maxIters tolerance>" << endln;
00325             return TCL_ERROR;
00326         }
00327 
00328         int tag, ndI, ndJ, secTagI, secTagJ, transfTag;
00329         double lenI, lenJ, E, A, Iz, Iy, G, J;
00330         double massDens = 0.0;
00331         int numIters = 10;
00332         double tol = 1.0e-10;
00333         double shearLength = 1.0;
00334     
00335         if (Tcl_GetInt(interp, argv[2], &tag) != TCL_OK) {
00336             opserr << "WARNING invalid beamWithHinges tag" << endln;
00337             return TCL_ERROR;           
00338         }
00339 
00340         if (Tcl_GetInt(interp, argv[3], &ndI) != TCL_OK) {
00341             opserr << "WARNING invalid ndI\n";
00342             opserr << "BeamWithHinges: " << tag << endln;
00343             return TCL_ERROR;   
00344         }
00345 
00346         if (Tcl_GetInt(interp, argv[4], &ndJ) != TCL_OK) {
00347             opserr << "WARNING invalid ndJ\n";
00348             opserr << "BeamWithHinges: " << tag << endln;
00349             return TCL_ERROR;   
00350         }
00351 
00352         if (Tcl_GetInt(interp, argv[5], &secTagI) != TCL_OK) {
00353             opserr << "WARNING invalid secTagI\n";
00354             opserr << "BeamWithHinges: " << tag << endln;
00355             return TCL_ERROR;   
00356         }
00357 
00358         if (Tcl_GetDouble (interp, argv[6], &lenI) != TCL_OK) {
00359             opserr << "WARNING invalid lenI\n";
00360             opserr << "BeamWithHinges: " << tag << endln;
00361             return TCL_ERROR;
00362         }
00363 
00364         if (Tcl_GetInt(interp, argv[7], &secTagJ) != TCL_OK) {
00365             opserr << "WARNING invalid ndJ\n";
00366             opserr << "BeamWithHinges: " << tag << endln;
00367             return TCL_ERROR;   
00368         }
00369 
00370         if (Tcl_GetDouble (interp, argv[8], &lenJ) != TCL_OK) {
00371             opserr << "WARNING invalid lenJ\n";
00372             opserr << "BeamWithHinges: " << tag << endln;
00373             return TCL_ERROR;
00374         }
00375 
00376         if (Tcl_GetDouble (interp, argv[9], &E) != TCL_OK) {
00377             opserr << "WARNING invalid E\n";
00378             opserr << "BeamWithHinges: " << tag << endln;
00379             return TCL_ERROR;
00380         }
00381 
00382         if (Tcl_GetDouble (interp, argv[10], &A) != TCL_OK) {
00383             opserr << "WARNING invalid A\n";
00384             opserr << "BeamWithHinges: " << tag << endln;
00385             return TCL_ERROR;
00386         }
00387         
00388         if (Tcl_GetDouble (interp, argv[11], &Iz) != TCL_OK) {
00389             opserr << "WARNING invalid Iz\n";
00390             opserr << "BeamWithHinges: " << tag << endln;
00391             return TCL_ERROR;
00392         }       
00393 
00394         if (Tcl_GetDouble (interp, argv[12], &Iy) != TCL_OK) {
00395             opserr << "WARNING invalid Iy\n";
00396             opserr << "BeamWithHinges: " << tag << endln;
00397             return TCL_ERROR;
00398         }
00399 
00400         if (Tcl_GetDouble (interp, argv[13], &G) != TCL_OK) {
00401             opserr << "WARNING invalid G\n";
00402             opserr << "BeamWithHinges: " << tag << endln;
00403             return TCL_ERROR;
00404         }
00405         
00406         if (Tcl_GetDouble (interp, argv[14], &J) != TCL_OK) {
00407             opserr << "WARNING invalid J\n";
00408             opserr << "BeamWithHinges: " << tag << endln;
00409             return TCL_ERROR;
00410         }       
00411         
00412         if (Tcl_GetInt (interp, argv[15], &transfTag) != TCL_OK) {
00413             opserr << "WARNING invalid transfTag\n";
00414             opserr << "BeamWithHinges: " << tag << endln;
00415             return TCL_ERROR;
00416         }       
00417 
00418         bool useFour = false;
00419 
00420         if (argc > 16) {
00421             for (int i = 16; i < argc; i++) {
00422                 if (strcmp(argv[i],"-mass") == 0 && ++i < argc) {
00423                     if (Tcl_GetDouble(interp, argv[i], &massDens) != TCL_OK) {
00424                         opserr << "WARNING invalid massDens\n";
00425                         opserr << "BeamWithHinges: " << tag << endln;
00426                         return TCL_ERROR;
00427                     }
00428                 }
00429                 
00430                 if (strcmp(argv[i],"-shear") == 0 && ++i < argc) {
00431                     if (Tcl_GetDouble(interp, argv[i], &shearLength) != TCL_OK) {
00432                         opserr << "WARNING invalid shearLength\n";
00433                         opserr << "BeamWithHinges: " << tag << endln;
00434                         return TCL_ERROR;
00435                     }
00436                 }
00437 
00438                 if (strcmp(argv[i],"-iter") == 0 && i+2 < argc) {
00439                         if (Tcl_GetInt(interp, argv[++i], &numIters) != TCL_OK) {
00440                                 opserr << "WARNING invalid maxIters\n";
00441                                 opserr << "BeamWithHinges: " << tag << endln;
00442                                 return TCL_ERROR;
00443                     }
00444                         if (Tcl_GetDouble(interp, argv[++i], &tol) != TCL_OK) {
00445                                 opserr << "WARNING invalid tolerance\n";
00446                                 opserr << "BeamWithHinges: " << tag << endln;
00447                                 return TCL_ERROR;
00448                     }
00449             }
00450                 if (strcmp(argv[i],"-useFour") == 0)
00451                   useFour = true;
00452             }
00453         }       
00454         
00455         // Retrieve section I from the model builder    
00456         SectionForceDeformation *sectionI = theBuilder->getSection (secTagI);
00457 
00458         if (sectionI == 0) {
00459             opserr << "WARNING section I does not exist\n";
00460             opserr << "section: " << secTagI; 
00461             opserr << "\nBeamWithHinges: " << tag << endln;
00462             return TCL_ERROR;
00463         }
00464 
00465         // Retrieve section J from the model builder    
00466         SectionForceDeformation *sectionJ = theBuilder->getSection (secTagJ);
00467 
00468         if (sectionJ == 0) {
00469             opserr << "WARNING section J does not exist\n";
00470             opserr << "section: " << secTagJ; 
00471             opserr << "\nBeamWithHinges: " << tag << endln;
00472             return TCL_ERROR;
00473         }
00474 
00475         CrdTransf3d *theTransf = theBuilder->getCrdTransf3d (transfTag);
00476 
00477         if (theTransf == 0) {
00478             opserr << "WARNING geometric transformation does not exist\n";
00479             opserr << "geometric transformation: " << transfTag; 
00480             opserr << "\nBeamWithHinges: " << tag << endln;
00481             return TCL_ERROR;
00482         }               
00483 
00484         Element *theElement = 0;
00485         int numSections = 0;
00486         SectionForceDeformation *sections[10];
00487         BeamIntegration *theBeamIntegr = 0;
00488 
00489         ElasticSection3d elastic(0, E, A, Iz, Iy, G, J);
00490 
00491         if (strcmp(argv[1],"beamWithHinges1") == 0) {
00492           theBeamIntegr = new HingeMidpointBeamIntegration(lenI, lenJ);
00493 
00494           numSections = 4;
00495           sections[0] = sectionI;
00496           sections[1] = &elastic;
00497           sections[2] = &elastic;
00498           sections[3] = sectionJ;
00499         }
00500         else if (strcmp(argv[1],"beamWithHinges2") == 0) {
00501           theBeamIntegr = new HingeRadauTwoBeamIntegration(lenI, lenJ);
00502           
00503           numSections = 6;
00504           sections[0] = sectionI;
00505           sections[1] = sectionI;
00506           sections[2] = &elastic;
00507           sections[3] = &elastic;
00508           sections[4] = sectionJ;
00509           sections[5] = sectionJ;
00510         }
00511         else if (strcmp(argv[1],"beamWithHinges3") == 0 ||
00512                  strcmp(argv[1],"beamWithHinges") == 0) {
00513           theBeamIntegr = new HingeRadauBeamIntegration(lenI, lenJ);
00514           
00515           numSections = 6;
00516           sections[0] = sectionI;
00517           sections[1] = &elastic;
00518           sections[2] = &elastic;
00519           sections[3] = &elastic;
00520           sections[4] = &elastic;
00521           sections[5] = sectionJ;
00522         }
00523         else if (strcmp(argv[1],"beamWithHinges4") == 0) {
00524           theBeamIntegr = new HingeEndpointBeamIntegration(lenI, lenJ);
00525           
00526           numSections = 4;
00527           sections[0] = sectionI;
00528           sections[1] = &elastic;
00529           sections[2] = &elastic;
00530           sections[3] = sectionJ;
00531         }
00532 
00533         if (theBeamIntegr == 0) {
00534           opserr << "Unknown element type: " << argv[1] << endln;
00535           return TCL_ERROR;
00536         }
00537 
00538         /*
00539         if (isShear) {
00540           SectionForceDeformation *sectionL = theBuilder->getSection(shearTag);
00541 
00542           if (sectionL == 0) {
00543             opserr << "WARNING section L does not exist\n";
00544             opserr << "section: " << shearTag; 
00545             opserr << "\nBeamWithHinges: " << tag << endln;
00546             return TCL_ERROR;
00547           }
00548           sections[numSections++] = sectionL;
00549         }
00550         */
00551 
00552         theElement = new ForceBeamColumn3d(tag, ndI, ndJ, numSections,
00553                                            sections, *theBeamIntegr,
00554                                            *theTransf,massDens,numIters,tol);
00555 
00556         delete theBeamIntegr;
00557 
00558         // Ensure we have created the element, out of memory if got here and no element
00559         if (theElement == 0) {
00560             opserr << "WARNING ran out of memory creating element\n";
00561             opserr << "BeamWithHinges: " << tag << endln;
00562             return TCL_ERROR;
00563         }
00564 
00565         if (theDomain->addElement(theElement) == false) {
00566             opserr << "WARNING TclElmtBuilder - addBeamWithHinges - could not add element to domain ";
00567             opserr << tag << endln;
00568             return TCL_ERROR;
00569         }
00570     }
00571     
00572     else {
00573         opserr << "ERROR -- model dimension: " << NDM << " and nodal degrees of freedom: "
00574             << NDF << " are incompatible for BeamWithHinges element" << endln;
00575         return TCL_ERROR;
00576     }
00577     
00578     return TCL_OK;
00579 }

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