beam3d01.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.5 $
00022 // $Date: 2003/02/14 23:01:05 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/element/beam3d/beam3d01.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/model/beam3d01.C
00027 //
00028 // Written: fmk 11/95
00029 // Revised:
00030 //
00031 // Purpose: This file contains the class definition for beam3d01.
00032 // beam3d01 is a 3d beam element. As such it can only
00033 // connect to a node with 6-dof. 
00034 
00035 #include <beam3d01.h>
00036 #include <Domain.h>
00037 #include <Channel.h>
00038 #include <FEM_ObjectBroker.h>
00039 
00040 #include <math.h>
00041 #include <stdlib.h>
00042 #include <Renderer.h>
00043 
00044 Matrix beam3d01::m(12,12);  // these beam members have no mass or damping matrice
00045 Matrix beam3d01::d(12,12);
00046 
00047 
00048 beam3d01::beam3d01()
00049 :Element(0,ELE_TAG_beam3d01), 
00050  A(0), E(0), G(0), Jx(0), Iy(0), Iz(0),theta(0),
00051  k(12,12), rForce(12), load(12), 
00052  connectedExternalNodes(2), isStiffFormed(0)
00053 {
00054   theNodes[0] = 0;
00055   theNodes[1] = 0;
00056 }
00057 
00058 beam3d01::beam3d01(int tag, double a, double e, double g, 
00059                    double jx, double iy, double iz, int Nd1, int Nd2, 
00060                    double Theta)
00061 
00062 :Element(tag,ELE_TAG_beam3d01), 
00063  A(a), E(e), G(g), Jx(jx), Iy(iy), Iz(iz), theta(Theta), L(0),
00064  k(12,12), rForce(12), load(12), 
00065  connectedExternalNodes(2), isStiffFormed(0)
00066 {
00067     connectedExternalNodes(0) = Nd1;
00068     connectedExternalNodes(1) = Nd2;    
00069 
00070   theNodes[0] = 0;
00071   theNodes[1] = 0;
00072 }
00073 
00074 
00075 // ~beam3d01():
00076 //      destructor
00077 
00078 beam3d01::~beam3d01()
00079 {
00080 
00081 }
00082 
00083 
00084 
00085 int
00086 beam3d01::getNumExternalNodes(void) const
00087 {
00088     return 2;
00089 }
00090 
00091 const ID &
00092 beam3d01::getExternalNodes(void) 
00093 {
00094     return connectedExternalNodes;
00095 }
00096 
00097 Node **
00098 beam3d01::getNodePtrs(void) 
00099 {
00100   return theNodes;
00101 }
00102 
00103 int
00104 beam3d01::getNumDOF(void) {
00105     int i =12;
00106     return i;
00107 }
00108 
00109 
00110 int
00111 beam3d01::revertToLastCommit()
00112 {
00113     return 0;
00114     // linear element - nothing to commit
00115 }
00116 
00117 const Matrix &
00118 beam3d01::getTangentStiff(void)
00119 {
00120     return this->getStiff();
00121 }
00122 
00123 const Matrix &
00124 beam3d01::getInitialStiff(void)
00125 {
00126     return this->getStiff();
00127 }
00128 
00129 // const Matrix &getStiff():
00130 //      Method to return the stiffness matrix.
00131 
00132 const Matrix &
00133 beam3d01::getStiff(void)
00134 {
00135     // compute the stiffness
00136     if (isStiffFormed == 0) { 
00137     
00138         // first check element has correct number of DOF at attached nodes
00139         int Nd1, Nd2;
00140         Nd1 = connectedExternalNodes(0);
00141         Nd2 = connectedExternalNodes(1);
00142 
00143         Domain *theDomain = this->getDomain();
00144         Node *end1Ptr = theDomain->getNode(Nd1);
00145         Node *end2Ptr = theDomain->getNode(Nd2);        
00146 
00147         if (end1Ptr == 0) {
00148             opserr << "beam3d01::getStiff: Nd1: ";
00149             opserr << Nd1 << "does not exist in model\n";
00150             exit(0);
00151         }
00152         if (end2Ptr == 0) {
00153             opserr << "beam3d01::getStiff: Nd2: ";
00154             opserr << Nd2 << "does not exist in model\n";
00155             exit(0);
00156         }
00157         
00158         theNodes[0] = end1Ptr;
00159         theNodes[1] = end2Ptr;
00160 
00161         double dx,dy,dz;
00162         const Vector &end1Crd = end1Ptr->getCrds();
00163         const Vector &end2Crd = end2Ptr->getCrds();     
00164     
00165         dx = end2Crd(0)-end1Crd(0);
00166         dy = end2Crd(1)-end1Crd(1);     
00167         dz = end2Crd(2)-end1Crd(2);             
00168     
00169         L = sqrt(dx*dx + dy*dy + dz*dz);
00170         double L2 = L*L;
00171         double L3 = L*L*L;
00172         if (L == 0.0) {
00173             opserr << "Element: " << this->getTag();
00174             opserr << " beam3d01::getStiff: 0 length\n";
00175             return k;  
00176         }
00177         
00178         double EA = E*A/L;
00179         double twoE = 2*E/L;
00180         double fourE = 4*E/L;
00181         double twelveE = 12*E/L3;
00182         double sixE = 6*E/L2;
00183         
00184         if (dy == 0.0 && dz == 0.0 && dx > 0.0 && theta == 90) {
00185             // local y in y and local z in z
00186             k(0,0) = EA;  
00187             k(6,0) = -EA;
00188 
00189             k(1,1) = twelveE*Iz;
00190             k(5,1) = sixE*Iz;
00191             k(7,1) = -twelveE*Iz;
00192             k(11,1) = sixE*Iz;
00193             
00194             k(2,2) = twelveE*Iy;
00195             k(4,2) = -sixE*Iy;
00196             k(8,2) = -twelveE*Iy;
00197             k(10,2) = -sixE*Iy;     
00198             
00199             k(3,3) = G*Jx/L;
00200             k(9,3) = -G*Jx/L;
00201             
00202             k(2,4) = -sixE*Iy;
00203             k(4,4) = fourE*Iy;
00204             k(8,4) = sixE*Iy;
00205             k(10,4) = twoE*Iy;
00206             
00207             k(1,5) = sixE*Iz;
00208             k(5,5) = fourE*Iz;
00209             k(7,5) = -sixE*Iz;
00210             k(11,5) = twoE*Iz;      
00211             
00212             k(0,6) = -EA;  
00213             k(6,6) = EA;
00214 
00215             k(1,7) = -twelveE*Iz;
00216             k(5,7) = -sixE*Iz;
00217             k(7,7) = twelveE*Iz;
00218             k(11,7) = -sixE*Iz;
00219             
00220             k(2,8) = -twelveE*Iy;
00221             k(4,8) = sixE*Iy;
00222             k(8,8) = twelveE*Iy;
00223             k(10,8) = sixE*Iy;      
00224             
00225             k(3,9) = -G*Jx/L;
00226             k(9,9) = G*Jx/L;
00227             
00228             k(2,10) = -sixE*Iy;
00229             k(4,10) = twoE*Iy;
00230             k(8,10) = sixE*Iy;
00231             k(10,10) = fourE*Iy;
00232             
00233             k(1,11) = sixE*Iz;
00234             k(5,11) = twoE*Iz;
00235             k(7,11) = -sixE*Iz;
00236             k(11,11) = fourE*Iz;                    
00237         }
00238         
00239         else if (dx == 0.0 && dz == 0.0 && dy > 0.0 && theta == 90) {
00240 
00241             k(0,0) = twelveE*Iz;
00242             k(5,0) = -sixE*Iz;
00243             k(6,0) = -twelveE*Iz;
00244             k(11,0) = -sixE*Iz;
00245             
00246             k(1,1) = EA;  
00247             k(7,1) = -EA;
00248 
00249             k(2,2) = twelveE*Iy;
00250             k(3,2) = sixE*Iy;
00251             k(8,2) = -twelveE*Iy;
00252             k(9,2) = sixE*Iy;       
00253 
00254             k(2,3) = sixE*Iy;
00255             k(3,3) = fourE*Iy;
00256             k(8,3) = -sixE*Iy;
00257             k(9,3) = twoE*Iy;
00258             
00259             k(4,4) = G*Jx/L;
00260             k(10,4) = -G*Jx/L;
00261             
00262             k(0,5) = -sixE*Iz;
00263             k(5,5) = fourE*Iz;
00264             k(6,5) = sixE*Iz;
00265             k(11,5) = twoE*Iz;      
00266             
00267             k(0,6) = -twelveE*Iz;
00268             k(5,6) = sixE*Iz;
00269             k(6,6) = twelveE*Iz;
00270             k(11,6) = sixE*Iz;
00271             
00272             k(1,7) = -EA;  
00273             k(7,7) = EA;
00274 
00275             k(2,8) = -twelveE*Iy;
00276             k(3,8) = -sixE*Iy;
00277             k(8,8) = twelveE*Iy;
00278             k(9,8) = -sixE*Iy;      
00279 
00280             k(2,9) = sixE*Iy;
00281             k(3,9) = twoE*Iy;
00282             k(8,9) = -sixE*Iy;
00283             k(9,9) = fourE*Iy;
00284             
00285             k(4,10) = -G*Jx/L;
00286             k(10,10) = G*Jx/L;
00287             
00288             k(0,11) = -sixE*Iz;
00289             k(5,11) = twoE*Iz;
00290             k(6,11) = sixE*Iz;
00291             k(11,11) = fourE*Iz;                    
00292         }           
00293         
00294         else if (dx == 0.0 && dy == 0.0 && dz > 0.0 && theta == 90) {
00295             // local y of columns in x dirn, local z in y dirn
00296             k(0,0) = twelveE*Iz;
00297             k(4,0) = sixE*Iz;
00298             k(6,0) = -twelveE*Iz;
00299             k(10,0) = sixE*Iz;      
00300 
00301             k(1,1) = twelveE*Iy;
00302             k(3,1) = -sixE*Iy;
00303             k(7,1) = -twelveE*Iy;
00304             k(9,1) = -sixE*Iy;
00305 
00306             k(2,2) = EA;  
00307             k(8,2) = -EA;
00308 
00309             k(1,3) = -sixE*Iy;
00310             k(3,3) = fourE*Iy;
00311             k(7,3) = sixE*Iy;
00312             k(9,3) = twoE*Iy;               
00313 
00314             k(0,4) = sixE*Iz;
00315             k(4,4) = fourE*Iz;
00316             k(6,4) = -sixE*Iz;
00317             k(10,4) = twoE*Iz;
00318 
00319             k(5,5) = G*Jx/L;
00320             k(11,5) = -G*Jx/L;      
00321             
00322             k(0,6) = -twelveE*Iz;
00323             k(4,6) = -sixE*Iz;
00324             k(6,6) = twelveE*Iz;
00325             k(10,6) = -sixE*Iz;     
00326 
00327             k(1,7) = -twelveE*Iy;
00328             k(3,7) = sixE*Iy;
00329             k(7,7) = twelveE*Iy;
00330             k(9,7) = sixE*Iy;
00331 
00332             k(2,8) = -EA;  
00333             k(8,8) = EA;
00334 
00335             k(1,9) = -sixE*Iy;
00336             k(3,9) = twoE*Iy;
00337             k(7,9) = sixE*Iy;
00338             k(9,9) = fourE*Iy;              
00339 
00340             k(0,10) = sixE*Iz;
00341             k(4,10) = twoE*Iz;
00342             k(6,10) = -sixE*Iz;
00343             k(10,10) = fourE*Iz;
00344 
00345             k(5,11) = -G*Jx/L;
00346             k(11,11) = G*Jx/L;      
00347         }           
00348         else {
00349             opserr << "beam3d01::getStiff - NOT FINISHED";
00350             opserr << " members not located along global axis directions\n";
00351             exit(0);
00352             
00353         }
00354         
00355         isStiffFormed = 1;
00356     }
00357 
00358     return k;
00359 }
00360     
00361 void 
00362 beam3d01::zeroLoad(void)
00363 {
00364     load.Zero();
00365 }
00366 
00367 int 
00368 beam3d01::addLoad(ElementalLoad *theLoad, double loadFactor)
00369 {
00370   opserr << "beam3d01::addLoad() - beam " << this->getTag() << "load type unknown\n";
00371   return -1;
00372 }
00373 
00374 int
00375 beam3d01::addInertiaLoadToUnbalance(const Vector &accel)
00376 {
00377   return 0;
00378 }
00379 
00380 
00381 const Vector &
00382 beam3d01::getResistingForceIncInertia()
00383 {       
00384     this->getResistingForce();
00385 
00386     // add rayleigh damping force if factors present    
00387     if (betaK != 0.0 || betaK0 != 0.0 || betaKc != 0.0)
00388         rForce += this->getRayleighDampingForces();
00389 
00390     return rForce;
00391 }
00392 
00393 const Vector &
00394 beam3d01::getResistingForce()
00395 {       
00396     if (isStiffFormed == 0)
00397         this->getStiff();
00398     
00399     // compute the residual Res = k*uTrial
00400     int Nd1, Nd2;
00401     Nd1 = connectedExternalNodes(0);
00402     Nd2 = connectedExternalNodes(1);
00403     Domain *theDomain = this->getDomain();
00404     Node *end1Ptr = theDomain->getNode(Nd1);
00405     Node *end2Ptr = theDomain->getNode(Nd2);    
00406     
00407     const Vector &end1Disp = end1Ptr->getTrialDisp();
00408     const Vector &end2Disp = end2Ptr->getTrialDisp();    
00409     rForce(0) = end1Disp(0);
00410     rForce(1) = end1Disp(1);
00411     rForce(2) = end1Disp(2);    
00412     rForce(3) = end1Disp(3);
00413     rForce(4) = end1Disp(4);
00414     rForce(5) = end1Disp(5);    
00415     rForce(6) = end2Disp(0);
00416     rForce(7) = end2Disp(1);
00417     rForce(8) = end2Disp(2);    
00418     rForce(9) = end2Disp(3);
00419     rForce(10) = end2Disp(4);
00420     rForce(11) = end2Disp(5);        
00421 
00422     rForce = k * rForce;
00423     
00424     // add any applied load
00425     rForce -= load;
00426     
00427     return rForce;
00428 }
00429 
00430 
00431 int
00432 beam3d01::displaySelf(Renderer &theViewer, int displayMode, float fact)
00433 {
00434 
00435     Domain *theDomain = this->getDomain();
00436     int Nd1 = connectedExternalNodes(0);
00437     int Nd2 = connectedExternalNodes(1);
00438     Node *end1Ptr = theDomain->getNode(Nd1);
00439     Node *end2Ptr = theDomain->getNode(Nd2);    
00440     
00441     const Vector &end1Crd = end1Ptr->getCrds();
00442     const Vector &end2Crd = end2Ptr->getCrds(); 
00443     const Vector &end1Disp = end1Ptr->getDisp();
00444     const Vector &end2Disp = end2Ptr->getDisp();    
00445 
00446     Vector v1(3);
00447     Vector v2(3);
00448     for (int i=0; i<3; i++) {
00449         v1(i) = end1Crd(i)+end1Disp(i)*fact;
00450         v2(i) = end2Crd(i)+end2Disp(i)*fact;    
00451     }
00452     return theViewer.drawLine(v1,v2,1.0,1.0);
00453 }
00454 
00455 
00456 int
00457 beam3d01::sendSelf(int commitTag, Channel &theChannel)
00458 {
00459     int dataTag = this->getDbTag();
00460     Vector data(10);
00461     data(0) = A; data(1) = E; data(2) = G; 
00462     data(3) = Jx; data(4) = Iy; data(5) = Iz;     
00463     data(6) = this->getTag();
00464     data(7) = connectedExternalNodes(0);
00465     data(8) = connectedExternalNodes(1);
00466     data(9) = theta;    
00467     int result = 0;
00468     result = theChannel.sendVector(dataTag, commitTag, data);
00469     if (result < 0) {
00470         opserr << "beam3d01::sendSelf - failed to send data\n";
00471         return -1;
00472     }
00473     
00474     return 0;
00475 }
00476 
00477 int
00478 beam3d01::recvSelf(int commitTag, Channel &theChannel, FEM_ObjectBroker &theBroker)
00479 {
00480     Vector data(10);
00481     int dataTag = this->getDbTag();
00482     int result = 0;
00483 
00484     result = theChannel.recvVector(dataTag, commitTag, data);
00485     if (result < 0) {
00486         opserr << "beam3d01::recvSelf - failed to recv data\n";
00487         return -1;
00488     }
00489 
00490     A = data(0); E = data(1); G=data(2); 
00491     Jx = data(3); Iy = data(4); Iz=data(5);     
00492     theta = data(9);
00493     int tag = data(6);
00494     this->setTag(tag);
00495     int nd1 = data(7);
00496     int nd2 = data(8);
00497     connectedExternalNodes(0) = nd1;
00498     connectedExternalNodes(1) = nd2;    
00499 
00500     return 0;
00501 }
00502 
00503 
00504 void
00505 beam3d01::Print(OPS_Stream &s, int flag)
00506 {
00507     s << "Element: " << this->getTag(); 
00508     s << " type: beam3d01  iNode: " << connectedExternalNodes(0);
00509     s << " jNode: " << connectedExternalNodes(1) << " Length: " << L << endln;
00510 //    s << "\tStiffness Matrix:\n" << k;
00511     s << "\tResisting Force: " << rForce;
00512 //    s << "\tElemt End Force: " << eForce;    
00513 }
00514 
00515 
00516 
00517 
00518 
00519 

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