ElasticBeam3d.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.17 $
00022 // $Date: 2006/08/04 19:08:07 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/element/elasticBeamColumn/ElasticBeam3d.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/model/ElasticBeam3d.C
00027 //
00028 // Written: fmk 11/95
00029 // Revised:
00030 //
00031 // Purpose: This file contains the class definition for ElasticBeam3d.
00032 // ElasticBeam3d is a 3d beam element. As such it can only
00033 // connect to a node with 6-dof. 
00034 
00035 #include <ElasticBeam3d.h>
00036 #include <Domain.h>
00037 #include <Channel.h>
00038 #include <FEM_ObjectBroker.h>
00039 
00040 #include <CrdTransf3d.h>
00041 #include <Information.h>
00042 #include <ElementResponse.h>
00043 #include <ElementalLoad.h>
00044 #include <Renderer.h>
00045 #include <SectionForceDeformation.h>
00046 #include <ID.h>
00047 #include <math.h>
00048 #include <stdlib.h>
00049 
00050 Matrix ElasticBeam3d::K(12,12);
00051 Vector ElasticBeam3d::P(12);
00052 Matrix ElasticBeam3d::kb(6,6);
00053 
00054 ElasticBeam3d::ElasticBeam3d()
00055   :Element(0,ELE_TAG_ElasticBeam3d), 
00056   A(0), E(0), G(0), Jx(0), Iy(0), Iz(0), rho(0.0),
00057   Q(12), q(6), connectedExternalNodes(2), theCoordTransf(0)
00058 {
00059   // does nothing
00060   q0[0] = 0.0;
00061   q0[1] = 0.0;
00062   q0[2] = 0.0;
00063   q0[3] = 0.0;
00064   q0[4] = 0.0;
00065 
00066   p0[0] = 0.0;
00067   p0[1] = 0.0;
00068   p0[2] = 0.0;
00069   p0[3] = 0.0;
00070   p0[4] = 0.0;
00071   
00072   // set node pointers to NULL
00073   for (int i=0; i<2; i++)
00074     theNodes[i] = 0;      
00075 }
00076 
00077 ElasticBeam3d::ElasticBeam3d(int tag, double a, double e, double g, 
00078                              double jx, double iy, double iz, int Nd1, int Nd2, 
00079                              CrdTransf3d &coordTransf, double r, int sectTag)
00080   :Element(tag,ELE_TAG_ElasticBeam3d), 
00081    A(a), E(e), G(g), Jx(jx), Iy(iy), Iz(iz), rho(r), sectionTag(sectTag),
00082   Q(12), q(6), connectedExternalNodes(2), theCoordTransf(0)
00083 {
00084   connectedExternalNodes(0) = Nd1;
00085   connectedExternalNodes(1) = Nd2;
00086   
00087   theCoordTransf = coordTransf.getCopy();
00088   
00089   if (!theCoordTransf) {
00090     opserr << "ElasticBeam3d::ElasticBeam3d -- failed to get copy of coordinate transformation\n";
00091     exit(-1);
00092   }
00093 
00094   q0[0] = 0.0;
00095   q0[1] = 0.0;
00096   q0[2] = 0.0;
00097   q0[3] = 0.0;
00098   q0[4] = 0.0;
00099 
00100   p0[0] = 0.0;
00101   p0[1] = 0.0;
00102   p0[2] = 0.0;
00103   p0[3] = 0.0;
00104   p0[4] = 0.0;
00105 
00106   // set node pointers to NULL
00107   for (int i=0; i<2; i++)
00108     theNodes[i] = 0;      
00109 }
00110 
00111 ElasticBeam3d::ElasticBeam3d(int tag, int Nd1, int Nd2, SectionForceDeformation *section,                            
00112                              CrdTransf3d &coordTransf, double r)
00113   :Element(tag,ELE_TAG_ElasticBeam3d), 
00114   Q(12), q(6), connectedExternalNodes(2), theCoordTransf(0)
00115 {
00116   if (section != 0) {
00117     sectionTag = section->getTag();
00118     E = 1.0;
00119     G = 1.0;
00120     Jx = 0.0;
00121     rho = r;
00122 
00123     const Matrix &sectTangent = section->getSectionTangent();
00124     const ID &sectCode = section->getType();
00125     for (int i=0; i<sectCode.Size(); i++) {
00126       int code = sectCode(i);
00127       switch(code) {
00128       case SECTION_RESPONSE_P:
00129         A = sectTangent(i,i);
00130         break;
00131       case SECTION_RESPONSE_MZ:
00132         Iz = sectTangent(i,i);
00133         break;
00134       case SECTION_RESPONSE_MY:
00135         Iy = sectTangent(i,i);
00136         break;
00137       case SECTION_RESPONSE_T:
00138         Jx = sectTangent(i,i);
00139         break;
00140       default:
00141         break;
00142       }
00143     }
00144   }    
00145   
00146   if (Jx == 0.0) {
00147     opserr << "ElasticBeam3d::ElasticBeam3d -- no torsion in section -- setting GJ = 1.0e10\n";
00148     Jx = 1.0e10;
00149   }
00150 
00151   connectedExternalNodes(0) = Nd1;
00152   connectedExternalNodes(1) = Nd2;
00153   
00154   theCoordTransf = coordTransf.getCopy();
00155   
00156   if (!theCoordTransf) {
00157     opserr << "ElasticBeam3d::ElasticBeam3d -- failed to get copy of coordinate transformation\n";
00158     exit(-1);
00159   }
00160 
00161   q0[0] = 0.0;
00162   q0[1] = 0.0;
00163   q0[2] = 0.0;
00164   q0[3] = 0.0;
00165   q0[4] = 0.0;
00166 
00167   p0[0] = 0.0;
00168   p0[1] = 0.0;
00169   p0[2] = 0.0;
00170   p0[3] = 0.0;
00171   p0[4] = 0.0;
00172 
00173   // set node pointers to NULL
00174   for (int i=0; i<2; i++)
00175     theNodes[i] = 0;      
00176 }
00177 
00178 ElasticBeam3d::~ElasticBeam3d()
00179 {
00180   if (theCoordTransf)
00181     delete theCoordTransf;
00182 }
00183 
00184 int
00185 ElasticBeam3d::getNumExternalNodes(void) const
00186 {
00187     return 2;
00188 }
00189 
00190 const ID &
00191 ElasticBeam3d::getExternalNodes(void) 
00192 {
00193     return connectedExternalNodes;
00194 }
00195 
00196 Node **
00197 ElasticBeam3d::getNodePtrs(void) 
00198 {
00199   return theNodes;
00200 }
00201 
00202 int
00203 ElasticBeam3d::getNumDOF(void)
00204 {
00205     return 12;
00206 }
00207 
00208 void
00209 ElasticBeam3d::setDomain(Domain *theDomain)
00210 {
00211   if (theDomain == 0) {
00212     opserr << "ElasticBeam3d::setDomain -- Domain is null\n";
00213     exit(-1);
00214   }
00215     
00216     theNodes[0] = theDomain->getNode(connectedExternalNodes(0));
00217     theNodes[1] = theDomain->getNode(connectedExternalNodes(1));    
00218     
00219 
00220     if (theNodes[0] == 0) {
00221       opserr << "ElasticBeam3d::setDomain -- Node 1: " << connectedExternalNodes(0) << " does not exist\n";
00222       exit(-1);
00223     }
00224                               
00225     if (theNodes[1] == 0) {
00226       opserr << "ElasticBeam3d::setDomain -- Node 2: " << connectedExternalNodes(1) << " does not exist\n";
00227       exit(-1);
00228     }
00229 
00230     int dofNd1 = theNodes[0]->getNumberDOF();
00231     int dofNd2 = theNodes[1]->getNumberDOF();    
00232     
00233     if (dofNd1 != 6) {
00234       opserr << "ElasticBeam3d::setDomain -- Node 1: " << connectedExternalNodes(0) 
00235              << " has incorrect number of DOF\n";
00236       exit(-1);
00237     }
00238     
00239     if (dofNd2 != 6) {
00240       opserr << "ElasticBeam3d::setDomain -- Node 2: " << connectedExternalNodes(1) 
00241              << " has incorrect number of DOF\n";
00242       exit(-1);
00243     }
00244         
00245     this->DomainComponent::setDomain(theDomain);
00246     
00247     if (theCoordTransf->initialize(theNodes[0], theNodes[1]) != 0) {
00248         opserr << "ElasticBeam3d::setDomain -- Error initializing coordinate transformation\n";
00249         exit(-1);
00250     }
00251     
00252     double L = theCoordTransf->getInitialLength();
00253 
00254     if (L == 0.0) {
00255       opserr << "ElasticBeam3d::setDomain -- Element has zero length\n";
00256       exit(-1);
00257     }
00258 }
00259 
00260 int
00261 ElasticBeam3d::commitState()
00262 {
00263   int retVal = 0;
00264   // call element commitState to do any base class stuff
00265   if ((retVal = this->Element::commitState()) != 0) {
00266     opserr << "ElasticBeam3d::commitState () - failed in base class";
00267   }    
00268   retVal += theCoordTransf->commitState();
00269   return retVal;
00270 }
00271 
00272 int
00273 ElasticBeam3d::revertToLastCommit()
00274 {
00275     return theCoordTransf->revertToLastCommit();
00276 }
00277 
00278 int
00279 ElasticBeam3d::revertToStart()
00280 {
00281     return theCoordTransf->revertToStart();
00282 }
00283 
00284 int
00285 ElasticBeam3d::update(void)
00286 {
00287   return theCoordTransf->update();
00288 }
00289 
00290 const Matrix &
00291 ElasticBeam3d::getTangentStiff(void)
00292 {
00293   const Vector &v = theCoordTransf->getBasicTrialDisp();
00294   
00295   double L = theCoordTransf->getInitialLength();
00296   double oneOverL = 1.0/L;
00297   double EoverL   = E*oneOverL;
00298   double EAoverL  = A*EoverL;                   // EA/L
00299   double EIzoverL2 = 2.0*Iz*EoverL;             // 2EIz/L
00300   double EIzoverL4 = 2.0*EIzoverL2;             // 4EIz/L
00301   double EIyoverL2 = 2.0*Iy*EoverL;             // 2EIy/L
00302   double EIyoverL4 = 2.0*EIyoverL2;             // 4EIy/L
00303   double GJoverL = G*Jx*oneOverL;         // GJ/L
00304   
00305   q(0) = EAoverL*v(0);
00306   q(1) = EIzoverL4*v(1) + EIzoverL2*v(2);
00307   q(2) = EIzoverL2*v(1) + EIzoverL4*v(2);
00308   q(3) = EIyoverL4*v(3) + EIyoverL2*v(4);
00309   q(4) = EIyoverL2*v(3) + EIyoverL4*v(4);    
00310   q(5) = GJoverL*v(5);
00311 
00312   q(0) += q0[0];
00313   q(1) += q0[1];
00314   q(2) += q0[2];
00315   q(3) += q0[3];
00316   q(4) += q0[4];
00317   
00318   kb(0,0) = EAoverL;
00319   kb(1,1) = kb(2,2) = EIzoverL4;
00320   kb(2,1) = kb(1,2) = EIzoverL2;
00321   kb(3,3) = kb(4,4) = EIyoverL4;
00322   kb(4,3) = kb(3,4) = EIyoverL2;
00323   kb(5,5) = GJoverL;
00324   
00325   return theCoordTransf->getGlobalStiffMatrix(kb,q);
00326 }
00327 
00328 
00329 const Matrix &
00330 ElasticBeam3d::getInitialStiff(void)
00331 {
00332   //  const Vector &v = theCoordTransf->getBasicTrialDisp();
00333   
00334   double L = theCoordTransf->getInitialLength();
00335   double oneOverL = 1.0/L;
00336   double EoverL   = E*oneOverL;
00337   double EAoverL  = A*EoverL;                   // EA/L
00338   double EIzoverL2 = 2.0*Iz*EoverL;             // 2EIz/L
00339   double EIzoverL4 = 2.0*EIzoverL2;             // 4EIz/L
00340   double EIyoverL2 = 2.0*Iy*EoverL;             // 2EIy/L
00341   double EIyoverL4 = 2.0*EIyoverL2;             // 4EIy/L
00342   double GJoverL = G*Jx*oneOverL;         // GJ/L
00343   
00344   kb(0,0) = EAoverL;
00345   kb(1,1) = kb(2,2) = EIzoverL4;
00346   kb(2,1) = kb(1,2) = EIzoverL2;
00347   kb(3,3) = kb(4,4) = EIyoverL4;
00348   kb(4,3) = kb(3,4) = EIyoverL2;
00349   kb(5,5) = GJoverL;
00350   
00351   return theCoordTransf->getInitialGlobalStiffMatrix(kb);
00352 }
00353 
00354 const Matrix &
00355 ElasticBeam3d::getMass(void)
00356 { 
00357   K.Zero();
00358 
00359   if (rho > 0.0) {
00360     double L = theCoordTransf->getInitialLength();
00361     double m = 0.5*rho*L;
00362     
00363     K(0,0) = m;
00364     K(1,1) = m;
00365     K(2,2) = m;
00366     
00367     K(6,6) = m;
00368     K(7,7) = m;
00369     K(8,8) = m;
00370   }
00371   
00372   return K;
00373 }
00374 
00375 void 
00376 ElasticBeam3d::zeroLoad(void)
00377 {
00378   Q.Zero();
00379 
00380   q0[0] = 0.0;
00381   q0[1] = 0.0;
00382   q0[2] = 0.0;
00383   q0[3] = 0.0;
00384   q0[4] = 0.0;
00385 
00386   p0[0] = 0.0;
00387   p0[1] = 0.0;
00388   p0[2] = 0.0;
00389   p0[3] = 0.0;
00390   p0[4] = 0.0;
00391 
00392   return;
00393 }
00394 
00395 int 
00396 ElasticBeam3d::addLoad(ElementalLoad *theLoad, double loadFactor)
00397 {
00398   int type;
00399   const Vector &data = theLoad->getData(type, loadFactor);
00400   double L = theCoordTransf->getInitialLength();
00401 
00402   if (type == LOAD_TAG_Beam3dUniformLoad) {
00403     double wy = data(0)*loadFactor;  // Transverse
00404     double wz = data(1)*loadFactor;  // Transverse
00405     double wx = data(2)*loadFactor;  // Axial (+ve from node I to J)
00406 
00407     double Vy = 0.5*wy*L;
00408     double Mz = Vy*L/6.0; // wy*L*L/12
00409     double Vz = 0.5*wz*L;
00410     double My = Vz*L/6.0; // wz*L*L/12
00411     double P = wx*L;
00412 
00413     // Reactions in basic system
00414     p0[0] -= P;
00415     p0[1] -= Vy;
00416     p0[2] -= Vy;
00417     p0[3] -= Vz;
00418     p0[4] -= Vz;
00419 
00420     // Fixed end forces in basic system
00421     q0[0] -= 0.5*P;
00422     q0[1] -= Mz;
00423     q0[2] += Mz;
00424     q0[3] += My;
00425     q0[4] -= My;
00426   }
00427   else if (type == LOAD_TAG_Beam3dPointLoad) {
00428     double Py = data(0)*loadFactor;
00429     double Pz = data(1)*loadFactor;
00430     double N  = data(2)*loadFactor;
00431     double aOverL = data(3);
00432 
00433     if (aOverL < 0.0 || aOverL > 1.0)
00434       return 0;
00435 
00436     double a = aOverL*L;
00437     double b = L-a;
00438 
00439     // Reactions in basic system
00440     p0[0] -= N;
00441     double V1, V2;
00442     V1 = Py*(1.0-aOverL);
00443     V2 = Py*aOverL;
00444     p0[1] -= V1;
00445     p0[2] -= V2;
00446     V1 = Pz*(1.0-aOverL);
00447     V2 = Pz*aOverL;
00448     p0[3] -= V1;
00449     p0[4] -= V2;
00450 
00451     double L2 = 1.0/(L*L);
00452     double a2 = a*a;
00453     double b2 = b*b;
00454 
00455     // Fixed end forces in basic system
00456     q0[0] -= N*aOverL;
00457     double M1, M2;
00458     M1 = -a * b2 * Py * L2;
00459     M2 = a2 * b * Py * L2;
00460     q0[1] += M1;
00461     q0[2] += M2;
00462     M1 = -a * b2 * Pz * L2;
00463     M2 = a2 * b * Pz * L2;
00464     q0[3] -= M1;
00465     q0[4] -= M2;
00466   }
00467   else {
00468     opserr << "ElasticBeam3d::addLoad()  -- load type unknown for element with tag: " << this->getTag() << endln;
00469     return -1;
00470   }
00471 
00472   return 0;
00473 }
00474 
00475 
00476 int
00477 ElasticBeam3d::addInertiaLoadToUnbalance(const Vector &accel)
00478 {
00479   if (rho == 0.0)
00480     return 0;
00481 
00482   // Get R * accel from the nodes
00483   const Vector &Raccel1 = theNodes[0]->getRV(accel);
00484   const Vector &Raccel2 = theNodes[1]->getRV(accel);
00485         
00486   if (6 != Raccel1.Size() || 6 != Raccel2.Size()) {
00487     opserr << "ElasticBeam3d::addInertiaLoadToUnbalance matrix and vector sizes are incompatable\n";
00488     return -1;
00489   }
00490 
00491   // Want to add ( - fact * M R * accel ) to unbalance
00492   // Take advantage of lumped mass matrix
00493   double L = theCoordTransf->getInitialLength();
00494   double m = 0.5*rho*L;
00495   
00496   Q(0) -= m * Raccel1(0);
00497   Q(1) -= m * Raccel1(1);
00498   Q(2) -= m * Raccel1(2);
00499     
00500   Q(6) -= m * Raccel2(0);    
00501   Q(7) -= m * Raccel2(1);
00502   Q(8) -= m * Raccel2(2);    
00503   
00504   return 0;
00505 }
00506 
00507 
00508 
00509 const Vector &
00510 ElasticBeam3d::getResistingForceIncInertia()
00511 {       
00512   P = this->getResistingForce();
00513 
00514   // add the damping forces if rayleigh damping
00515   if (alphaM != 0.0 || betaK != 0.0 || betaK0 != 0.0 || betaKc != 0.0)
00516     P += this->getRayleighDampingForces();
00517     
00518   if (rho == 0.0)
00519     return P;
00520 
00521   else{
00522     const Vector &accel1 = theNodes[0]->getTrialAccel();
00523     const Vector &accel2 = theNodes[1]->getTrialAccel();    
00524     
00525     double L = theCoordTransf->getInitialLength();
00526     double m = 0.5*rho*L;
00527     
00528     P(0) += m * accel1(0);
00529     P(1) += m * accel1(1);
00530     P(2) += m * accel1(2);
00531     
00532     P(6) += m * accel2(0);    
00533     P(7) += m * accel2(1);
00534     P(8) += m * accel2(2);    
00535     
00536     return P;
00537   }
00538 }
00539 
00540 
00541 const Vector &
00542 ElasticBeam3d::getResistingForce()
00543 {
00544   const Vector &v = theCoordTransf->getBasicTrialDisp();
00545   
00546   double L = theCoordTransf->getInitialLength();
00547   double oneOverL = 1.0/L;
00548   double EoverL   = E*oneOverL;
00549   double EAoverL  = A*EoverL;                   // EA/L
00550   double EIzoverL2 = 2.0*Iz*EoverL;             // 2EIz/L
00551   double EIzoverL4 = 2.0*EIzoverL2;             // 4EIz/L
00552   double EIyoverL2 = 2.0*Iy*EoverL;             // 2EIy/L
00553   double EIyoverL4 = 2.0*EIyoverL2;             // 4EIy/L
00554   double GJoverL = G*Jx*oneOverL;         // GJ/L
00555   
00556   q(0) = EAoverL*v(0);
00557   q(1) = EIzoverL4*v(1) + EIzoverL2*v(2);
00558   q(2) = EIzoverL2*v(1) + EIzoverL4*v(2);
00559   q(3) = EIyoverL4*v(3) + EIyoverL2*v(4);
00560   q(4) = EIyoverL2*v(3) + EIyoverL4*v(4);    
00561   q(5) = GJoverL*v(5);
00562   
00563   q(0) += q0[0];
00564   q(1) += q0[1];
00565   q(2) += q0[2];
00566   q(3) += q0[3];
00567   q(4) += q0[4];
00568   
00569   Vector p0Vec(p0, 5);
00570   
00571   //  opserr << q;
00572 
00573   P = theCoordTransf->getGlobalResistingForce(q, p0Vec);
00574 
00575   // opserr << P;
00576   
00577   // P = P - Q;
00578   P.addVector(1.0, Q, -1.0);
00579   
00580   return P;
00581 }
00582 
00583 int
00584 ElasticBeam3d::sendSelf(int cTag, Channel &theChannel)
00585 {
00586     int res = 0;
00587 
00588     static Vector data(12);
00589     
00590     data(0) = A;
00591     data(1) = E; 
00592     data(2) = G; 
00593     data(3) = Jx; 
00594     data(4) = Iy; 
00595     data(5) = Iz;     
00596     data(6) = rho;
00597     data(7) = this->getTag();
00598     data(8) = connectedExternalNodes(0);
00599     data(9) = connectedExternalNodes(1);
00600     data(10) = theCoordTransf->getClassTag();           
00601         
00602         int dbTag = theCoordTransf->getDbTag();
00603 
00604         if (dbTag == 0) {
00605                 dbTag = theChannel.getDbTag();
00606                 if (dbTag != 0)
00607                         theCoordTransf->setDbTag(dbTag);
00608         }
00609 
00610         data(11) = dbTag;
00611 
00612         // Send the data vector
00613     res += theChannel.sendVector(this->getDbTag(), cTag, data);
00614     if (res < 0) {
00615       opserr << "ElasticBeam3d::sendSelf -- could not send data Vector\n";
00616       return res;
00617     }
00618 
00619     // Ask the CoordTransf to send itself
00620     res += theCoordTransf->sendSelf(cTag, theChannel);
00621     if (res < 0) {
00622       opserr << "ElasticBeam3d::sendSelf -- could not send CoordTransf\n";
00623       return res;
00624     }
00625 
00626     return res;
00627 }
00628 
00629 int
00630 ElasticBeam3d::recvSelf(int cTag, Channel &theChannel, FEM_ObjectBroker &theBroker)
00631 {
00632         int res = 0;
00633         
00634         static Vector data(12);
00635 
00636     res += theChannel.recvVector(this->getDbTag(), cTag, data);
00637     if (res < 0) {
00638       opserr << "ElasticBeam3d::recvSelf -- could not receive data Vector\n";
00639       return res;
00640     }
00641 
00642     A = data(0);
00643     E = data(1); 
00644     G = data(2); 
00645     Jx = data(3); 
00646     Iy = data(4); 
00647     Iz = data(5);     
00648     rho = data(6);
00649     this->setTag((int)data(7));
00650     connectedExternalNodes(0) = (int)data(8);
00651     connectedExternalNodes(1) = (int)data(9);
00652 
00653     // Check if the CoordTransf is null; if so, get a new one
00654     int crdTag = (int)data(10);
00655     if (theCoordTransf == 0) {
00656       theCoordTransf = theBroker.getNewCrdTransf3d(crdTag);
00657       if (theCoordTransf == 0) {
00658         opserr << "ElasticBeam3d::recvSelf -- could not get a CrdTransf3d\n";
00659         exit(-1);
00660       }
00661     }
00662 
00663     // Check that the CoordTransf is of the right type; if not, delete
00664     // the current one and get a new one of the right type
00665     if (theCoordTransf->getClassTag() != crdTag) {
00666       delete theCoordTransf;
00667       theCoordTransf = theBroker.getNewCrdTransf3d(crdTag);
00668       if (theCoordTransf == 0) {
00669         opserr << "ElasticBeam3d::recvSelf -- could not get a CrdTransf3d\n";
00670         exit(-1);
00671       }
00672     }
00673 
00674     // Now, receive the CoordTransf
00675     theCoordTransf->setDbTag((int)data(11));
00676     res += theCoordTransf->recvSelf(cTag, theChannel, theBroker);
00677     if (res < 0) {
00678       opserr << "ElasticBeam3d::recvSelf -- could not receive CoordTransf\n";
00679       return res;
00680     }
00681 
00682     // Revert the crdtrasf to its last committed state
00683     theCoordTransf->revertToLastCommit();
00684 
00685     return res;
00686 }
00687 
00688 void
00689 ElasticBeam3d::Print(OPS_Stream &s, int flag)
00690 {
00691    if (flag == -1) { 
00692     int eleTag = this->getTag();
00693     s << "EL_BEAM\t" << eleTag << "\t";
00694     s << sectionTag << "\t" << sectionTag; 
00695     s  << "\t" << connectedExternalNodes(0) << "\t" << connectedExternalNodes(1);
00696     s << "\t0\t0.0000000\n";
00697    }  else if (flag < -1) {
00698      int counter = (flag + 1) * -1;
00699      int eleTag = this->getTag();
00700      const Vector &force = this->getResistingForce();
00701 
00702     double P, MZ1, MZ2, VY, MY1, MY2, VZ, T;
00703     double L = theCoordTransf->getInitialLength();
00704     double oneOverL = 1.0/L;
00705     
00706     P   = q(0);
00707     MZ1 = q(1);
00708     MZ2 = q(2);
00709     VY  = (MZ1+MZ2)*oneOverL;
00710     MY1 = q(3);
00711     MY2 = q(4);
00712     VZ  = (MY1+MY2)*oneOverL;
00713     T   = q(5);
00714 
00715     s << "FORCE\t" << eleTag << "\t" << counter << "\t0";
00716     s << "\t" << -P+p0[0] << "\t"  <<  VY+p0[1] << "\t"  << -VZ+p0[3]  << endln;
00717     s << "FORCE\t" << eleTag << "\t" << counter << "\t1";
00718     s << "\t"  << P  << ' '  << -VY+p0[2] << ' ' << VZ+p0[4] << endln;
00719     s << "MOMENT\t" << eleTag << "\t" << counter << "\t0";
00720     s << "\t" << -T << "\t"  << MY1 << "\t" << MZ1 << endln;
00721     s << "MOMENT\t" << eleTag << "\t" << counter << "\t1";
00722     s << "\t" << T << ' ' << MY2 << ' '  <<  MZ2 << endln;
00723     
00724    }
00725 
00726    else if (flag == 2){
00727      this->getResistingForce(); // in case linear algo
00728 
00729      static Vector xAxis(3);
00730      static Vector yAxis(3);
00731      static Vector zAxis(3);
00732      
00733      theCoordTransf->getLocalAxes(xAxis, yAxis, zAxis);
00734                         
00735      s << "#ElasticBeamColumn3D\n";
00736      s << "#LocalAxis " << xAxis(0) << " " << xAxis(1) << " " << xAxis(2);
00737      s << " " << yAxis(0) << " " << yAxis(1) << " " << yAxis(2) << " ";
00738      s << zAxis(0) << " " << zAxis(1) << " " << zAxis(2) << endln;
00739 
00740      const Vector &node1Crd = theNodes[0]->getCrds();
00741      const Vector &node2Crd = theNodes[1]->getCrds();   
00742      const Vector &node1Disp = theNodes[0]->getDisp();
00743      const Vector &node2Disp = theNodes[1]->getDisp();    
00744      
00745      s << "#NODE " << node1Crd(0) << " " << node1Crd(1) << " " << node1Crd(2)
00746        << " " << node1Disp(0) << " " << node1Disp(1) << " " << node1Disp(2)
00747        << " " << node1Disp(3) << " " << node1Disp(4) << " " << node1Disp(5) << endln;
00748      
00749      s << "#NODE " << node2Crd(0) << " " << node2Crd(1) << " " << node2Crd(2)
00750        << " " << node2Disp(0) << " " << node2Disp(1) << " " << node2Disp(2)
00751        << " " << node2Disp(3) << " " << node2Disp(4) << " " << node2Disp(5) << endln;
00752 
00753     double N, Mz1, Mz2, Vy, My1, My2, Vz, T;
00754     double L = theCoordTransf->getInitialLength();
00755     double oneOverL = 1.0/L;
00756     
00757     N   = q(0);
00758     Mz1 = q(1);
00759     Mz2 = q(2);
00760     Vy  = (Mz1+Mz2)*oneOverL;
00761     My1 = q(3);
00762     My2 = q(4);
00763     Vz  = -(My1+My2)*oneOverL;
00764     T   = q(5);
00765     
00766     s << "#END_FORCES " << -N+p0[0] << ' ' <<  Vy+p0[1] << ' ' << Vz+p0[3] << ' ' 
00767       << -T << ' ' << My1 << ' ' <<  Mz1 << endln;
00768     s << "#END_FORCES " <<  N << ' ' << -Vy+p0[2] << ' ' << -Vz+p0[4] << ' ' 
00769       << T << ' ' << My2 << ' ' << Mz2 << endln;
00770    }
00771    else {
00772 
00773      this->getResistingForce(); // in case linear algo
00774 
00775     s << "\nElasticBeam3d: " << this->getTag() << endln;
00776     s << "\tConnected Nodes: " << connectedExternalNodes ;
00777     s << "\tCoordTransf: " << theCoordTransf->getTag() << endln;
00778     
00779     double N, Mz1, Mz2, Vy, My1, My2, Vz, T;
00780     double L = theCoordTransf->getInitialLength();
00781     double oneOverL = 1.0/L;
00782     
00783     N   = q(0);
00784     Mz1 = q(1);
00785     Mz2 = q(2);
00786     Vy  = (Mz1+Mz2)*oneOverL;
00787     My1 = q(3);
00788     My2 = q(4);
00789     Vz  = -(My1+My2)*oneOverL;
00790     T   = q(5);
00791     
00792     s << "\tEnd 1 Forces (P Mz Vy My Vz T): "
00793       << -N+p0[0] << ' ' << Mz1 << ' ' <<  Vy+p0[1] << ' ' << My1 << ' ' <<  Vz+p0[3] << ' ' << -T << endln;
00794     s << "\tEnd 2 Forces (P Mz Vy My Vz T): "
00795       <<  N << ' ' << Mz2 << ' ' << -Vy+p0[2] << ' ' << My2 << ' ' << -Vz+p0[4] << ' ' <<  T << endln;
00796   }
00797 }
00798 
00799 int
00800 ElasticBeam3d::displaySelf(Renderer &theViewer, int displayMode, float fact)
00801 {
00802     // first determine the end points of the quad based on
00803     // the display factor (a measure of the distorted image)
00804     const Vector &end1Crd = theNodes[0]->getCrds();
00805     const Vector &end2Crd = theNodes[1]->getCrds();     
00806 
00807     static Vector v1(3);
00808     static Vector v2(3);
00809 
00810     if (displayMode >= 0) {
00811       const Vector &end1Disp = theNodes[0]->getDisp();
00812       const Vector &end2Disp = theNodes[1]->getDisp();
00813       
00814       for (int i = 0; i < 3; i++) {
00815         v1(i) = end1Crd(i) + end1Disp(i)*fact;
00816         v2(i) = end2Crd(i) + end2Disp(i)*fact;    
00817       }
00818     } else {
00819       int mode = displayMode * -1;
00820       const Matrix &eigen1 = theNodes[0]->getEigenvectors();
00821       const Matrix &eigen2 = theNodes[1]->getEigenvectors();
00822       if (eigen1.noCols() >= mode) {
00823         for (int i = 0; i < 3; i++) {
00824           v1(i) = end1Crd(i) + eigen1(i,mode-1)*fact;
00825           v2(i) = end2Crd(i) + eigen2(i,mode-1)*fact;    
00826         }    
00827       } else {
00828         for (int i = 0; i < 3; i++) {
00829           v1(i) = end1Crd(i);
00830           v2(i) = end2Crd(i);
00831         }    
00832       }
00833     }
00834     
00835     return theViewer.drawLine (v1, v2, 1.0, 1.0);
00836 }
00837 
00838 Response*
00839 ElasticBeam3d::setResponse(const char **argv, int argc, Information &info, OPS_Stream &output)
00840 {
00841 
00842   Response *theResponse = 0;
00843 
00844   output.tag("ElementOutput");
00845   output.attr("eleType","ElasticBeam3d");
00846   output.attr("eleTag",this->getTag());
00847   output.attr("node1",connectedExternalNodes[0]);
00848   output.attr("node2",connectedExternalNodes[1]);
00849   
00850   // global forces
00851   if (strcmp(argv[0],"force") == 0 || strcmp(argv[0],"forces") == 0 ||
00852       strcmp(argv[0],"globalForce") == 0 || strcmp(argv[0],"globalForces") == 0) {
00853 
00854 
00855     output.tag("ResponseType","Px_1");
00856     output.tag("ResponseType","Py_1");
00857     output.tag("ResponseType","Pz_1");
00858     output.tag("ResponseType","Mx_1");
00859     output.tag("ResponseType","My_1");
00860     output.tag("ResponseType","Mz_1");
00861     output.tag("ResponseType","Px_2");
00862     output.tag("ResponseType","Py_2");
00863     output.tag("ResponseType","Pz_2");
00864     output.tag("ResponseType","Mx_2");
00865     output.tag("ResponseType","My_2");
00866     output.tag("ResponseType","Mz_2");
00867 
00868     theResponse =  new ElementResponse(this, 2, P);
00869 
00870         // local forces
00871   } else if (strcmp(argv[0],"localForce") == 0 || strcmp(argv[0],"localForces") == 0) {
00872 
00873     output.tag("ResponseType","N_ 1");
00874     output.tag("ResponseType","Vy_1");
00875     output.tag("ResponseType","Vz_1");
00876     output.tag("ResponseType","T_1");
00877     output.tag("ResponseType","My_1");
00878     output.tag("ResponseType","Tz_1");
00879     output.tag("ResponseType","N_2");
00880     output.tag("ResponseType","Py_2");
00881     output.tag("ResponseType","Pz_2");
00882     output.tag("ResponseType","T_2");
00883     output.tag("ResponseType","My_2");
00884     output.tag("ResponseType","Mz_2");
00885 
00886     theResponse =  new ElementResponse(this, 3, P);
00887   }
00888 
00889   output.endTag(); // ElementOutput
00890 
00891   return theResponse;
00892 }
00893 
00894 int
00895 ElasticBeam3d::getResponse (int responseID, Information &eleInfo)
00896 {
00897   double N, V, M1, M2, T;
00898   double L = theCoordTransf->getInitialLength();
00899   double oneOverL = 1.0/L;
00900 
00901   switch (responseID) {
00902   case 1: // stiffness
00903     return eleInfo.setMatrix(this->getTangentStiff());
00904     
00905   case 2: // global forces
00906     return eleInfo.setVector(this->getResistingForce());
00907     
00908   case 3: // local forces
00909     // Axial
00910     N = q(0);
00911     P(6) =  N;
00912     P(0) = -N+p0[0];
00913     
00914     // Torsion
00915     T = q(5);
00916     P(9) =  T;
00917     P(3) = -T;
00918     
00919     // Moments about z and shears along y
00920     M1 = q(1);
00921     M2 = q(2);
00922     P(5)  = M1;
00923     P(11) = M2;
00924     V = (M1+M2)*oneOverL;
00925     P(1) =  V+p0[1];
00926     P(7) = -V+p0[2];
00927     
00928     // Moments about y and shears along z
00929     M1 = q(3);
00930     M2 = q(4);
00931     P(4)  = M1;
00932     P(10) = M2;
00933     V = -(M1+M2)*oneOverL;
00934     P(2) = -V+p0[3];
00935     P(8) =  V+p0[4];
00936     
00937     return eleInfo.setVector(P);
00938     
00939   default:
00940     return -1;
00941   }
00942 }

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