beam2d04.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/beam2d/beam2d04.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/element/beam2d04.C
00027 //
00028 // Written: fmk 11/95
00029 // Revised:
00030 //
00031 // Purpose: This file contains the class definition for beam2d04.
00032 // beam2d04 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 "beam2d04.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 Matrix beam2d04::k(6,6);
00056 Matrix beam2d04::trans(6,6);
00057 
00058 // beam2d04(int tag, double A, double E, double I, int Nd1, int Nd2);
00059 //      constructor which takes the unique element tag, the elements A,E and
00060 //      I and the node ID's of it's nodal end points. 
00061 
00062 beam2d04::beam2d04()
00063    :Element(0,ELE_TAG_beam2d04), A(0), E(0), I(0), L(0),
00064     connectedExternalNodes(2), 
00065     rForce(6), load(6), isStiffFormed(0)
00066 {
00067   theNodes[0] = 0;
00068   theNodes[1] = 0;
00069 }
00070 
00071 beam2d04::beam2d04(int tag, double a, double e, double i, int Nd1, int Nd2)
00072    :Element(tag,ELE_TAG_beam2d04), A(a), E(e), I(i), L(0),
00073     connectedExternalNodes(2), 
00074     rForce(6), load(6), isStiffFormed(0)
00075 {
00076     connectedExternalNodes(0) = Nd1;
00077     connectedExternalNodes(1) = Nd2;    
00078     
00079     theNodes[0] = 0;
00080     theNodes[1] = 0;
00081 }
00082 
00083 
00084 // ~beam2d04():
00085 //      destructor
00086 
00087 beam2d04::~beam2d04()
00088 {
00089 }
00090 
00091 
00092 
00093 int
00094 beam2d04::getNumExternalNodes(void) const
00095 {
00096     return connectedExternalNodes.Size();
00097 }
00098 
00099 const ID &
00100 beam2d04::getExternalNodes(void) 
00101 {
00102     return connectedExternalNodes;
00103 }
00104 
00105 Node **
00106 beam2d04::getNodePtrs(void) 
00107 {
00108   return theNodes;
00109 }
00110 
00111 int
00112 beam2d04::getNumDOF(void) {
00113     int i =6;
00114     return i;
00115 }
00116 
00117 
00118 void
00119 beam2d04::formVar(void)
00120 {
00121     // compute the stiffness
00122     if (isStiffFormed == 0) { 
00123         // first check element has correct number of DOF at attached nodes
00124         int Nd1, Nd2;
00125         Nd1 = connectedExternalNodes(0);
00126         Nd2 = connectedExternalNodes(1);
00127         Domain *theDomain = this->getDomain();
00128         Node *end1Ptr = theDomain->getNode(Nd1);
00129         Node *end2Ptr = theDomain->getNode(Nd2);        
00130         theNodes[0] = end1Ptr;
00131         theNodes[1] = end2Ptr;
00132 
00133         if (end1Ptr == 0) {
00134             opserr << "beam2d04::formVar: Nd1: ";
00135             opserr << Nd1 << "does not exist in model\n";
00136             exit(0);
00137         }
00138         if (end2Ptr == 0) {
00139             opserr << "beam2d04::formVar: Nd2: ";
00140             opserr << Nd2 << "does not exist in model\n";
00141             exit(0);
00142         }
00143 
00144         double dx,dy;
00145         const Vector &end1Crd = end1Ptr->getCrds();
00146         const Vector &end2Crd = end2Ptr->getCrds();     
00147     
00148         dx = end2Crd(0)-end1Crd(0);
00149         dy = end2Crd(1)-end1Crd(1);     
00150     
00151         L = sqrt(dx*dx + dy*dy);
00152         double L2 = L*L;
00153         double L3 = L*L*L;
00154         if (L == 0.0) {
00155             opserr << "Element: " << this->getTag();
00156             opserr << " beam2d04::formVar: 0 length\n";
00157             exit(-1);
00158         }
00159         
00160         cs = dx/L;
00161         sn = dy/L;
00162 
00163         oneEA = E*A/L;
00164         twoEI = 2*E*I/L;
00165         fourEI = 4*E*I/L;
00166         twelveEI = 12*E*I/L3;
00167         sixEI = 6*E*I/L2;
00168     }
00169     isStiffFormed = 1;
00170 }    
00171 
00172 
00173 int
00174 beam2d04::revertToLastCommit()
00175 {
00176     return 0;
00177     // linear element - nothing to commit
00178 }
00179 
00180 const Matrix &
00181 beam2d04::getTangentStiff(void)
00182 {
00183     return this->getStiff();
00184 }
00185 
00186 const Matrix &
00187 beam2d04::getInitialStiff(void)
00188 {
00189     return this->getStiff();
00190 }
00191 
00192 
00193 
00194 
00195 // const Matrix &getStiff():
00196 //      Method to return the stiffness matrix.
00197 
00198 const Matrix &
00199 beam2d04::getStiff(void)
00200 {
00201     if (isStiffFormed == 0)
00202         this->formVar();
00203 
00204     if (cs == 1.0) {
00205         k(0,0) = oneEA;
00206         k(1,0) = 0;
00207         k(2,0) = 0;
00208         k(3,0) = -oneEA;
00209         k(4,0) = 0;
00210         k(5,0) = 0;
00211 
00212         k(0,1) = 0;
00213         k(1,1) = twelveEI;
00214         k(2,1)= sixEI;
00215         k(3,1) = 0;
00216         k(4,1) = -twelveEI;
00217         k(5,1) = sixEI;
00218 
00219         k(0,2) = 0;
00220         k(1,2) = sixEI;
00221         k(2,2) = fourEI;
00222         k(3,2) = 0;
00223         k(4,2) = -sixEI;
00224         k(5,2) = twoEI;
00225         
00226         k(0,3) = -oneEA;
00227         k(1,3) = 0;
00228         k(2,3) = 0;
00229         k(3,3) = oneEA;
00230         k(4,3) = 0;
00231         k(5,3) = 0;
00232 
00233         k(0,4) = 0;
00234         k(1,4) = -twelveEI;
00235         k(2,4) = -sixEI;
00236         k(3,4) = 0;
00237         k(4,4) = twelveEI;
00238         k(5,4)  = -sixEI;
00239         
00240         k(0,5) = 0;
00241         k(1,5) = sixEI;
00242         k(2,5) = twoEI;
00243         k(3,5) = 0;
00244         k(4,5) = -sixEI;
00245         k(5,5) = fourEI;
00246     }
00247     else if (sn == 1.0) {
00248         k(0,0) = twelveEI;
00249         k(1,0) = 0;
00250         k(2,0) = -sixEI;
00251         k(3,0) = -twelveEI;;
00252         k(4,0) = 0;
00253         k(5,0) = -sixEI;;
00254 
00255         k(0,1) = 0;
00256         k(1,1) = oneEA;
00257         k(2,1) = 0;
00258         k(3,1) = 0;
00259         k(4,1) = -oneEA;
00260         k(5,1) = 0;
00261         
00262         k(0,2) = -sixEI;
00263         k(1,2) = 0;
00264         k(2,2) = fourEI;
00265         k(3,2) = sixEI;
00266         k(4,2) = 0;
00267         k(5,2) = twoEI;
00268         
00269         k(0,3) = -twelveEI;
00270         k(1,3) = 0;
00271         k(2,3) = sixEI;
00272         k(3,3) = twelveEI;
00273         k(4,3) = 0;
00274         k(5,3) = sixEI;
00275 
00276         k(0,4) = 0;
00277         k(1,4) = -oneEA;
00278         k(2,4) = 0;
00279         k(3,4) = 0;
00280         k(4,4) = oneEA;
00281         k(5,4) = 0;
00282         
00283         k(0,5) = -sixEI;
00284         k(1,5) = 0;
00285         k(2,5) = twoEI;
00286         k(3,5) = sixEI;
00287         k(4,5) = 0;
00288         k(5,5) = fourEI;
00289     }
00290     else {
00291         opserr << "beam2d04::getStiff - more WORK \n";
00292         exit(0);
00293     }
00294 
00295     return k;
00296 }
00297     
00298 
00299 
00300 void 
00301 beam2d04::zeroLoad(void)
00302 {
00303     load.Zero();
00304 }
00305 
00306 int 
00307 beam2d04::addLoad(ElementalLoad *theLoad, double loadFactor)
00308 {
00309   opserr << "beam2d04::addLoad() - beam " << this->getTag() << ",load type unknown\n"; 
00310   return -1;
00311 }
00312 
00313 int
00314 beam2d04::addInertiaLoadToUnbalance(const Vector &accel)
00315 {
00316   return 0;
00317 }
00318 
00319 const Vector &
00320 beam2d04::getResistingForceIncInertia()
00321 {       
00322     this->getResistingForce();
00323 
00324     if (betaK != 0.0 || betaK0 != 0.0 || betaKc != 0.0)
00325       rForce += this->getRayleighDampingForces();
00326     
00327     return rForce;
00328 }
00329 
00330 
00331 
00332 
00333 const Vector &
00334 beam2d04::getResistingForce()
00335 {       
00336     this->getStiff();
00337     
00338     // compute the residual Res = k*uTrial
00339     int Nd1, Nd2;
00340     Nd1 = connectedExternalNodes(0);
00341     Nd2 = connectedExternalNodes(1);
00342     Domain *theDomain = this->getDomain();
00343     Node *end1Ptr = theDomain->getNode(Nd1);
00344     Node *end2Ptr = theDomain->getNode(Nd2);    
00345     
00346     const Vector &end1Disp = end1Ptr->getTrialDisp();
00347     const Vector &end2Disp = end2Ptr->getTrialDisp();    
00348     rForce(0) = end1Disp(0);
00349     rForce(1) = end1Disp(1);
00350     rForce(2) = end1Disp(2);    
00351     rForce(3) = end2Disp(0);
00352     rForce(4) = end2Disp(1);
00353     rForce(5) = end2Disp(2);    
00354 
00355     rForce = k * rForce;
00356     
00357     // add any applied load
00358     rForce -= load;
00359     
00360     return rForce;
00361 }
00362 
00363 int
00364 beam2d04::sendSelf(int commitTag, Channel &theChannel)
00365 {
00366   int dataTag = this->getDbTag();
00367 
00368   Vector data(4);
00369   data(0) = A; data(1) = E; data(2) = I; data(3) = this->getTag();
00370     
00371   int result = 0;
00372   result = theChannel.sendVector(dataTag, commitTag, data);
00373   if (result < 0) {
00374     opserr << "beam2d04::sendSelf - failed to send data\n";
00375     return -1;
00376   }
00377   
00378   result = theChannel.sendID(dataTag, commitTag, connectedExternalNodes);
00379   if (result < 0) {
00380     opserr << "beam2d04::sendSelf - failed to send data\n";
00381     return -1;
00382   }
00383     
00384   return 0;
00385 }
00386 
00387 int
00388 beam2d04::recvSelf(int commitTag, Channel &theChannel, FEM_ObjectBroker &theBroker)
00389 {
00390     Vector data(4);
00391     int result = 0;
00392     int dataTag = this->getDbTag();
00393 
00394     result = theChannel.recvVector(dataTag, commitTag, data);
00395     if (result < 0) {
00396         opserr << "beam2d04::recvSelf - failed to recv data\n";
00397         return -1;
00398     }
00399 
00400     A = data(0); E = data(1); I=data(2); 
00401     this->setTag((int)data(3));
00402 
00403     result = theChannel.recvID(dataTag, commitTag, connectedExternalNodes);
00404     if (result < 0) {
00405         opserr << "beam2d04::recvSelf - failed to recv data\n";
00406         return -1;
00407     }
00408     
00409     return 0;
00410 }
00411 
00412 void
00413 beam2d04::Print(OPS_Stream &s, int flag)
00414 {
00415     s << "\nElement: " << this->getTag() << " Type: beam2d04 ";
00416     s << "\tConnected Nodes: " << connectedExternalNodes ;
00417 //    s << "\tStiffness Matrix:\n" << k;
00418     s << "\tResisting Force: " << rForce;
00419 //    s << "\tElemt End Force: " << load;        
00420 //    s << "\tElemt End Force: " << eForce;    
00421 }
00422 
00423 
00424 
00425 
00426 

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