beam2d03.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.6 $
00022 // $Date: 2006/03/07 17:14:51 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/element/beam2d/beam2d03.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/element/beam2d03.C
00027 //
00028 // Written: fmk 11/95
00029 // Revised:
00030 //
00031 // Purpose: This file contains the class definition for beam2d03.
00032 // beam2d03 is a 2d plane frame bending member. As such it can only
00033 // connect to a node with 3-dof. It only uses the x and y coordinates
00034 // at the nodes, a z coordinate is not used. 
00035 //
00036 //                                      5
00037 //        2                             |<
00038 //        |                   .=========+-)-4
00039 //       3|      .=============         | 6
00040 // 1 ---(-+======
00041 //       >|
00042 //
00043 // The interface:
00044 //
00045 
00046 
00047 #include "beam2d03.h"
00048 #include <Domain.h>
00049 #include <Channel.h>
00050 #include <FEM_ObjectBroker.h>
00051 
00052 #include <math.h>
00053 #include <stdlib.h>
00054 
00055 // beam2d03(int tag, double A, double E, double I, int Nd1, int Nd2);
00056 //      constructor which takes the unique element tag, the elements A,E and
00057 //      I and the node ID's of it's nodal end points. 
00058 
00059 beam2d03::beam2d03()
00060    :Element(0,ELE_TAG_beam2d03), A(0), E(0), I(0), L(0),
00061     connectedExternalNodes(2),
00062     k(6,6), rForce(6), load(6), 
00063     trans(6,6)
00064 {
00065   theNodes[0] = 0;
00066   theNodes[1] = 0;
00067 }
00068 
00069 beam2d03::beam2d03(int tag, double a, double e, double i, int Nd1, int Nd2)
00070    :Element(tag,ELE_TAG_beam2d03), A(a),  E(e), I(i), 
00071     L(0), connectedExternalNodes(2),
00072     k(6,6), rForce(6), 
00073     load(6), trans(6,6)
00074 {
00075     connectedExternalNodes(0) = Nd1;
00076     connectedExternalNodes(1) = Nd2;    
00077 
00078     theNodes[0] = 0;
00079     theNodes[1] = 0;
00080 }
00081 
00082 
00083 // ~beam2d03():
00084 //      destructor
00085 
00086 beam2d03::~beam2d03()
00087 {
00088 }
00089 
00090 
00091 
00092 int
00093 beam2d03::getNumExternalNodes(void) const
00094 {
00095     return connectedExternalNodes.Size();
00096 }
00097 
00098 const ID &
00099 beam2d03::getExternalNodes(void) 
00100 {
00101     return connectedExternalNodes;
00102 }
00103 
00104 Node **
00105 beam2d03::getNodePtrs(void) 
00106 {
00107   return theNodes;
00108 }
00109 
00110 int
00111 beam2d03::getNumDOF(void) {
00112     int i =6;
00113     return i;
00114 }
00115 
00116 
00117 int
00118 beam2d03::revertToLastCommit()
00119 {
00120     return 0;
00121     // linear element - nothing to commit
00122 }
00123 
00124 
00125 
00126 void
00127 beam2d03::setDomain(Domain *theDomain)
00128 {
00129     // first set the node pointers
00130     int Nd1 = connectedExternalNodes(0);
00131     int Nd2 = connectedExternalNodes(1);
00132     theNodes[0] = theDomain->getNode(Nd1);
00133     theNodes[1] = theDomain->getNode(Nd2);      
00134     if (theNodes[0] == 0) {
00135         opserr << "WARNING beam2d02::setDomain(): Nd1: ";
00136         opserr << Nd1 << "does not exist in model for beam \n" << *this;
00137         return;
00138     }
00139     if (theNodes[1] == 0) {
00140         opserr << "WARNING beam2d02::setDomain(): Nd2: ";
00141         opserr << Nd2 << "does not exist in model for beam\n" << *this;
00142         return;
00143     }   
00144     
00145     // now verify the number of dof at node ends
00146     int dofNd1 = theNodes[0]->getNumberDOF();
00147     int dofNd2 = theNodes[1]->getNumberDOF();   
00148     if (dofNd1 != 3 && dofNd2 != 3) {
00149         opserr << "WARNING beam2d02::setDomain(): node " << Nd1;
00150         opserr << " and/or node " << Nd2 << " have/has incorrect number ";
00151         opserr << "of dof's at end for beam\n " << *this;
00152         return;
00153     }   
00154 
00155     // call the base class method
00156     this->DomainComponent::setDomain(theDomain);
00157 
00158     double dx,dy;
00159     const Vector &end1Crd = theNodes[0]->getCrds();
00160     const Vector &end2Crd = theNodes[1]->getCrds();     
00161     
00162     dx = end2Crd(0)-end1Crd(0);
00163     dy = end2Crd(1)-end1Crd(1); 
00164     
00165     L = sqrt(dx*dx + dy*dy);
00166     double L2 = L*L;
00167     double L3 = L*L*L;
00168     if (L == 0.0) {
00169       opserr << "Element: " << this->getTag();
00170       opserr << " beam2d03::getStiff: 0 length\n";
00171     }
00172     
00173     cs = dx/L;
00174     sn = dy/L;
00175     
00176     trans(0,0) = trans(3,3) = cs;
00177     trans(0,1) = trans(3,4) = sn;
00178     trans(1,0) = trans(4,3) = -sn;
00179     trans(1,1) = trans(4,4) = cs;
00180     trans(2,2) = trans(5,5) = 1.0;
00181     
00182     double oneEA = E*A/L;
00183     double twoEI = 2*E*I/L;
00184     double fourEI = 4*E*I/L;
00185     double twelveEI = 12*E*I/L3;
00186     double sixEI = 6*E*I/L2;
00187     
00188     if (sn == 1.0) {
00189       k(0,0) = twelveEI;
00190       k(2,0) = -sixEI;
00191       k(3,0) = -twelveEI;;
00192       k(5,0) = -sixEI;;
00193       
00194       k(1,1) = oneEA;
00195       k(4,1) = -oneEA;
00196       
00197       k(0,2) = -sixEI;
00198       k(2,2) = fourEI;
00199       k(3,2) = sixEI;
00200       k(5,2) = twoEI;
00201       
00202       k(0,3) = -twelveEI;
00203       k(2,3) = sixEI;
00204       k(3,3) = twelveEI;
00205       k(5,3) = sixEI;
00206       
00207       k(1,4) = -oneEA;
00208       k(4,4) = oneEA;
00209       
00210       k(0,5) = -sixEI;
00211       k(2,5) = twoEI;
00212       k(3,5) = sixEI;
00213       k(5,5) = fourEI;
00214     }
00215     else {
00216       k(0,0) = oneEA;
00217       k(3,0) = -oneEA;
00218       
00219       k(1,1) = twelveEI;
00220       k(2,1)= sixEI;
00221       k(4,1) = -twelveEI;
00222       k(5,1) = sixEI;
00223       
00224       k(1,2) = sixEI;
00225       k(2,2) = fourEI;
00226       k(4,2) = -sixEI;
00227       k(5,2) = twoEI;
00228       
00229       k(0,3) = -oneEA;
00230       k(3,3) = oneEA;
00231       
00232       k(1,4) = -twelveEI;
00233       k(2,4) = -sixEI;
00234       k(4,4) = twelveEI;
00235       k(5,4)  = -sixEI;
00236       
00237       k(1,5) = sixEI;
00238       k(2,5) = twoEI;
00239       k(4,5) = -sixEI;
00240       k(5,5) = fourEI;
00241       
00242       if (cs != 1.0)
00243         k = trans^ k * trans;       
00244     }
00245 }
00246 
00247 
00248 
00249 const Matrix &
00250 beam2d03::getTangentStiff(void)
00251 {
00252     return k;
00253 }
00254 
00255 
00256 const Matrix &
00257 beam2d03::getInitialStiff(void)
00258 {
00259     return k;
00260 }
00261     
00262 void 
00263 beam2d03::zeroLoad(void)
00264 {
00265     load.Zero();
00266 }
00267 
00268 int 
00269 beam2d03::addLoad(ElementalLoad *theLoad, double loadFactor)
00270 {
00271 
00272   opserr << "beam2d03::addLoad() - beam " << this->getTag() << "load type unknown\n";
00273   return -1;
00274     
00275   return 0;
00276 }
00277 
00278 int
00279 beam2d03::addInertiaLoadToUnbalance(const Vector &accel)
00280 {
00281   return 0;
00282 }
00283 
00284 const Vector &
00285 beam2d03::getResistingForce()
00286 {       
00287     // compute the residual Res = k*uTrial
00288     const Vector &end1Disp = theNodes[0]->getTrialDisp();
00289     const Vector &end2Disp = theNodes[1]->getTrialDisp();    
00290     rForce(0) = end1Disp(0);
00291     rForce(1) = end1Disp(1);
00292     rForce(2) = end1Disp(2);    
00293     rForce(3) = end2Disp(0);
00294     rForce(4) = end2Disp(1);
00295     rForce(5) = end2Disp(2);    
00296     
00297     rForce = k * rForce;
00298     
00299     // add any applied load
00300     rForce -= load;
00301     
00302     return rForce;
00303 }
00304 
00305 const Vector &
00306 beam2d03::getResistingForceIncInertia()
00307 {       
00308     this->getResistingForce();  
00309 
00310     if (betaK != 0.0 || betaK0 != 0.0 || betaKc != 0.0)
00311         rForce += this->getRayleighDampingForces();
00312 
00313     return rForce;
00314 }
00315 
00316 
00317 int
00318 beam2d03::sendSelf(int commitTag, Channel &theChannel)
00319 {
00320   int dataTag = this->getDbTag();
00321 
00322   Vector data(4);
00323   data(0) = A; data(1) = E; data(2) = I; data(3) = this->getTag();
00324     
00325   int result = 0;
00326   result = theChannel.sendVector(dataTag, commitTag, data);
00327   if (result < 0) {
00328     opserr << "beam2d03::sendSelf - failed to send data\n";
00329     return -1;
00330   }
00331   
00332   result = theChannel.sendID(dataTag, commitTag, connectedExternalNodes);
00333   if (result < 0) {
00334     opserr << "beam2d03::sendSelf - failed to send data\n";
00335     return -1;
00336   }
00337     
00338   return 0;
00339 }
00340 
00341 int
00342 beam2d03::recvSelf(int commitTag, Channel &theChannel, FEM_ObjectBroker &theBroker)
00343 {
00344     Vector data(4);
00345     int result = 0;
00346     int dataTag = this->getDbTag();
00347 
00348     result = theChannel.recvVector(dataTag, commitTag, data);
00349     if (result < 0) {
00350         opserr << "beam2d03::recvSelf - failed to recv data\n";
00351         return -1;
00352     }
00353 
00354     A = data(0); E = data(1); I=data(2); 
00355     this->setTag((int)data(3));
00356 
00357     result = theChannel.recvID(dataTag, commitTag, connectedExternalNodes);
00358     if (result < 0) {
00359         opserr << "beam2d03::recvSelf - failed to recv data\n";
00360         return -1;
00361     }
00362     
00363     return 0;
00364 }
00365 
00366 
00367 
00368 void
00369 beam2d03::Print(OPS_Stream &s, int flag)
00370 {
00371   //    s << "\nElement: " << this->getTag() << " Type: beam2d03 ";
00372   //    s << "\tConnected Nodes: " << connectedExternalNodes ;
00373 //    s << "\tStiffness Matrix:\n" << k;
00374   //    s << "\tResisting Force: " << rForce;
00375 //    s << "\tElemt End Force: " << eForce;    
00376 }
00377 
00378 
00379 
00380 

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