UpdatedLagrangianBeam2D.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 ** See file 'COPYRIGHT'  in main directory for information on usage   **
00010 ** and redistribution of OpenSees, and for a DISCLAIMER OF ALL        **
00011 ** WARRANTIES.                                                        **
00012 **                                                                    **
00013 ** UpdatedLagrangianBeam2D.cpp: implementation of the                 **
00014 **                             UpdatedLagrangianBeam2D class          **
00015 ** Developed by:                                                      **
00016 **    Rohit Kaul       (rkaul@stanford.edu)                           **
00017 **    Greg Deierlein   (ggd@stanford.edu)                             **
00018 **                                                                    **
00019 **           John A. Blume Earthquake Engineering Center              **
00020 **                    Stanford University                             **
00021 ** ****************************************************************** **/
00022 
00023 #include <Domain.h>
00024 #include <Channel.h>
00025 #include <FEM_ObjectBroker.h>
00026 #include <Renderer.h>
00027 #include <Information.h>
00028 #include <ElementResponse.h>
00029 #include <math.h>
00030 #include <stdlib.h>
00031 #include <string.h>
00032 
00033 #include "UpdatedLagrangianBeam2D.h"
00034 
00035 #define   _debug  0
00036 #define   _Kdebug 0
00037 
00038 Matrix UpdatedLagrangianBeam2D::K(6,6);  
00039 Matrix UpdatedLagrangianBeam2D::Kg(6,6);
00040 Matrix UpdatedLagrangianBeam2D::Kt(6,6);
00041 Matrix UpdatedLagrangianBeam2D::M(6,6);
00042 Matrix UpdatedLagrangianBeam2D::D(6,6);
00043 Matrix UpdatedLagrangianBeam2D::T(6,6);
00044 Vector UpdatedLagrangianBeam2D::force(6);
00045 Vector UpdatedLagrangianBeam2D::disp(6);
00046 Vector UpdatedLagrangianBeam2D::ZeroVector(6);
00047 Matrix UpdatedLagrangianBeam2D::ZeroMatrix(6,6);
00048 Vector UpdatedLagrangianBeam2D::end1IncrDisp(3);
00049 Vector UpdatedLagrangianBeam2D::end2IncrDisp(3);
00050 
00051 Node *UpdatedLagrangianBeam2D::theNodes[2];
00052 
00054 // Construction/Destruction
00056 
00057 UpdatedLagrangianBeam2D::UpdatedLagrangianBeam2D(int classTag)
00058   :Element(0, classTag), isLinear(true), L(0.0), sn(0.0), cs(0),
00059    connectedExternalNodes(2), load(6),
00060    end1Ptr(0), end2Ptr(0),  eleForce(6), eleForce_hist(6), 
00061    nodeRecord(0), dofRecord(0), m_Iter(-1), Ki(0)
00062 {
00063         numDof  = 6;
00064         massDof = -1;// assumes no lumped mass
00065     // will be overwritten by the sub-class massDof
00066 }
00067 
00068 UpdatedLagrangianBeam2D::UpdatedLagrangianBeam2D(int tag, int classTag, int nd1, int nd2, bool islinear)
00069   :Element(tag, classTag), isLinear(islinear), L(0.0), sn(0.0), cs(0),
00070    connectedExternalNodes(2), load(6),
00071    end1Ptr(0), end2Ptr(0),  eleForce(6), eleForce_hist(6), 
00072    nodeRecord(0), dofRecord(0), m_Iter(-1), Ki(0)
00073 {
00074         connectedExternalNodes(0) = nd1;
00075         connectedExternalNodes(1) = nd2;
00076         numDof  = 6;
00077         massDof = -1;// assumes no lumped mass
00078     // will be overwritten by the sub-class massDof
00079 }
00080 
00081 UpdatedLagrangianBeam2D::~UpdatedLagrangianBeam2D()
00082 {
00083   if (Ki != 0)
00084     delete Ki;
00085 }
00086 
00088 // Add the 2D element to the domain
00090 
00091 void UpdatedLagrangianBeam2D::setDomain(Domain *theDomain)
00092 {
00093         // check Domain is not null - invoked when object removed from a domain
00094     if (theDomain == 0) {
00095         end1Ptr = 0;
00096         end2Ptr = 0;
00097         L = 0;
00098     }
00099     // first set the node pointers
00100     //cout <<  "Element " << getTag() << ", Nodes = " << connectedExternalNodes; cin.get();
00101 
00102     int Nd1 = connectedExternalNodes(0);
00103     int Nd2 = connectedExternalNodes(1);
00104     end1Ptr = theDomain->getNode(Nd1);
00105     end2Ptr = theDomain->getNode(Nd2);  
00106     if (end1Ptr == 0) {
00107         opserr << "WARNING (W_C_10) - UpdatedLagrangianBeam2D::setDomain(..) [" << getTag() << "]\n";
00108         opserr << Nd1 << "Nd1 does not exist in model for element \n" <<" Tag = " << getTag();
00109         return;
00110     }
00111     if (end2Ptr == 0) {
00112         opserr << "WARNING (W_C_20) - UpdatedLagrangianBeam2D::setDomain(..) [" << getTag() << "]\n";
00113         opserr << Nd2 << "Nd2 does not exist in model for element\n" << " Tag = " << getTag();
00114         return;
00115     }
00116 
00117     // now verify the number of dof at node ends
00118     int dofNd1 = end1Ptr->getNumberDOF();
00119     int dofNd2 = end2Ptr->getNumberDOF();
00120     if (dofNd1 != 3 && dofNd2 != 3) {
00121         opserr << "WARNING (W_C_30) - UpdatedLagrangianBeam2D::setDomain() [" << getTag() <<"]\n";
00122         opserr << "node and/or node " << Nd1 << Nd2 << " have/has incorrect number ";
00123         opserr << "of dof's at end for element\n " << *this;
00124         return;
00125     }
00126 
00127     // call the base class method
00128     this->DomainComponent::setDomain(theDomain);
00129 
00130     // determine length and direction cosines
00131         {
00132                 double dx,dy;
00133                 const Vector &end1Crd = end1Ptr->getCrds();
00134                 const Vector &end2Crd = end2Ptr->getCrds();
00135     
00136                 dx = end2Crd(0)-end1Crd(0);
00137                 dy = end2Crd(1)-end1Crd(1);     
00138   
00139                 L = sqrt(dx*dx + dy*dy);
00140                 L_hist = L;
00141 
00142                 if(L==0)
00143                 {
00144                         opserr << "WARNING UpdatedLagrangianBeam2D::setDomain(): zero length\n";
00145                         return; 
00146                 }
00147                 cs = dx/L;
00148                 sn = dy/L;
00149                 cs_hist = dx/L;
00150                 sn_hist = dy/L;
00151         }
00152 
00153 
00154 }//setDomain
00155 
00156 
00157 int UpdatedLagrangianBeam2D::update()
00158 {
00159         return 0;
00160 }
00161 
00162 
00163 int UpdatedLagrangianBeam2D::commitState()
00164 {
00165   int success = 0 ;
00166 
00167   // call element commitState to do any base class stuff
00168   if ((success = this->Element::commitState()) != 0) {
00169     opserr << "UpdatedLagrangianBeam2D::commitState () - failed in base class";
00170   }    
00171 
00172 #ifdef _G3DEBUG
00173         opserr << m_Iter << " "; // cin.get();
00174 #endif
00175                 m_Iter = 0;
00176         
00177         if(_debug || _Kdebug)
00178         {
00179             opserr << "\n Beam N0: "<< this->getTag()
00180             << " ----- Inside Commit State -----\n";
00181             //cin.get();
00182         }
00183 
00184     if(!isLinear)
00185     {
00186         this->updateState();
00187         cs_hist = cs;
00188         sn_hist = sn;
00189                 L_hist = L;
00190     }
00191 
00192         // save the prev. step element forces
00193         eleForce_hist = eleForce;
00194         return success;
00195 }
00196 
00197 void UpdatedLagrangianBeam2D::updateState()
00198 {
00199         // Update the direction cosines to the new trial state
00201         //return;
00203 
00204         const Vector &end1Crd = end1Ptr->getCrds();
00205         const Vector &end2Crd = end2Ptr->getCrds();
00206         const Vector &end1Disp  = end1Ptr->getTrialDisp();
00207     const Vector &end2Disp  = end2Ptr->getTrialDisp();
00208 
00209         double x1 = end1Crd(0) + end1Disp(0);
00210         double y1 = end1Crd(1) + end1Disp(1);
00211         double x2 = end2Crd(0) + end2Disp(0);
00212         double y2 = end2Crd(1) + end2Disp(1);
00213 
00214         double dx = x2 - x1;
00215         double dy = y2 - y1;
00216 
00217         L = sqrt(dx*dx + dy*dy);
00218         if(L==0 )
00219         {
00220                 opserr << "WARNING (W_B_40) - UpdatedLagrangianBeam2D::updateState() [" << getTag() << "\n";
00221                 opserr << "L = 0\n";
00222                 return;
00223         }
00224         cs = dx/L;
00225         sn = dy/L;
00226 }
00227 
00228 
00229 int UpdatedLagrangianBeam2D::revertToLastCommit()
00230 {
00231         cs = cs_hist;
00232         sn = sn_hist;
00233         L = L_hist;
00234         eleForce = eleForce_hist;
00235         return 0;
00236 }
00237 
00239 // protected methods for local stiffness and force formulation
00241 
00242 // set default for 2D beam-column elements
00243 
00244 void UpdatedLagrangianBeam2D::addInternalGeomStiff(Matrix &K)
00245 {
00246    if (isLinear)
00247         return;
00248         
00249  double P = eleForce_hist(3);  //Last committed
00250  double l = L_hist;
00251 
00252     K(0,0) += P/l;
00253         K(0,3) += -P/l;
00254         K(3,0) += -P/l;
00255         K(3,3) += P/l;
00256 
00257         K(1,1) += 1.2*P/l;
00258         K(1,4) += -1.2*P/l;
00259         K(4,1) += -1.2*P/l;
00260         K(4,4) += 1.2*P/l;
00261 
00262         K(1,2) += P/10;
00263         K(1,5) += P/10;
00264         K(2,1) += P/10;
00265         K(5,1) += P/10;
00266 
00267         K(2,2) += 2*P*l/15;
00268         K(2,5) += -P*l/30;
00269         K(5,2) += -P*l/30;
00270         K(5,5) += 2*P*l/15;
00271 
00272 
00273         K(2,4) += -P/10;
00274         K(4,2) += -P/10;
00275         K(4,5) += -P/10;
00276         K(5,4) += -P/10;
00277 
00279 /*    K(1, 1) +=  0.2*P/l;
00280     K(4, 4) +=  0.2*P/l;
00281         K(1, 4) += -0.2*P/l;
00282     K(4, 1) += -0.2*P/l;
00283         K(1, 2) += P/10;
00284     K(1, 5) += P/10;
00285     K(2, 1) += P/10;
00286     K(5, 1) += P/10;
00287         K(2, 4) += -P/10;
00288     K(4, 2) += -P/10;
00289     K(4, 5) += -P/10;
00290     K(5, 4) += -P/10;
00291         K(2, 2) += 2*P*l/15;
00292     K(5, 5) += 2*P*l/15;
00293         K(2, 5) += -P*l/30;
00294     K(5, 2) += -P*l/30;
00295 */
00296 
00297 }
00298 
00299 void UpdatedLagrangianBeam2D::addExternalGeomStiff(Matrix &K)
00300 {
00301 //     if (isLinear)
00302         return;
00303 // everything is included above for rf2
00304  
00305 double P = eleForce_hist(3);  //Last committed
00306 double V = eleForce_hist(1);
00307 double l = L_hist;
00308 
00309     K(0, 1) += V/l;
00310     K(1, 0) += V/l;
00311         K(0, 4) += -V/l;
00312     K(4, 0) += -V/l;
00313         K(1, 1) += P/l;
00314     K(4, 4) += P/l;
00315         K(1, 3) += -V/l;
00316     K(3, 1) += -V/l;
00317         K(1, 4) += -P/l;
00318     K(4, 1) += -P/l;
00319         K(3, 4) += P/l;
00320     K(4, 3) += P/l;
00321 
00322 }
00323 
00324 
00326 // Public methods called, taken care of for 2D element subclasses
00328 
00329 int UpdatedLagrangianBeam2D::getNumExternalNodes(void) const
00330 {
00331     return 2;
00332 }
00333 
00334 const ID &UpdatedLagrangianBeam2D::getExternalNodes(void) 
00335 {
00336     return connectedExternalNodes;
00337 }
00338 
00339 Node **
00340 UpdatedLagrangianBeam2D::getNodePtrs(void) 
00341 {
00342   theNodes[0] = end1Ptr;
00343   theNodes[1] = end2Ptr;
00344   
00345   return theNodes;
00346 }
00347 
00348 int UpdatedLagrangianBeam2D::getNumDOF(void) 
00349 {
00350     return numDof;
00351 }
00352 
00353 const Matrix &UpdatedLagrangianBeam2D::getTangentStiff(void)
00354 {
00355     // Get the local elastic stiffness matrix, store in Kt
00356     getLocalStiff(Kt);
00357 
00358     // Add internal geometric stiffness matrix
00359     addInternalGeomStiff(Kt);
00360 
00361     // Add external geometric stiffness matrix
00362     addExternalGeomStiff(Kt);
00363 
00364         if(_Kdebug){
00365             opserr << "UpdatedLagrangianBeam2D::getTangentStiff(void) tag = " << getTag() << "\n";
00366             opserr << Kt;
00367         }
00368 
00369     //Kt = T^(Kt*T);
00370     transformToGlobal(Kt);
00371 
00372 #ifdef _G3DEBUG
00373         for(int i=0; i< 6; i++)
00374         {
00375                 double aii = Kt(i, i);
00376                 if(aii < 1e-6)
00377                 {
00378                         opserr << " WARNING (W_B_50) - UpdatedLagrangianBeam2D::getTangentStiff(..) [" << getTag() << "]\n";
00379                         opserr << " aii = " << aii << ", i = " << i << "\n";
00380                 }
00381         }
00382 #endif
00383 
00384     return Kt;
00385 }
00386 
00387 const Matrix &UpdatedLagrangianBeam2D::getInitialStiff(void)
00388 {
00389   if (Ki == 0)
00390     Ki = new Matrix(this->getTangentStiff());
00391   
00392   return *Ki;
00393 }
00394 
00395 
00396 const Matrix &UpdatedLagrangianBeam2D::getMass(void)
00397 {
00398   if(massDof==0)
00399     return ZeroMatrix;
00400 
00401   getLocalMass(M);
00402   transformToGlobal(M);
00403 
00404   return M;
00405 }
00406 
00408 // methods for applying and returning loads
00410 // Add uniformly varying load to the element
00411 Vector &UpdatedLagrangianBeam2D::getUVLoadVector(double q1, double q2)
00412 {
00413  load(0) = 0;
00414  load(1) = (7*q1 + 3*q2)*(L/20);
00415  load(2) = (3*q1 + 2*q2)*(L*L/60);
00416  load(3) = 0;
00417  load(4) = (3*q1 + 7*q2)*(L/20);
00418  load(5) = -(2*q1 + 3*q2)*(L*L/60);
00419  return load;
00420 }
00421 
00422 void UpdatedLagrangianBeam2D::zeroLoad(void)
00423 {
00424     load.Zero();
00425 }
00426 
00427 int UpdatedLagrangianBeam2D::addLoad(const Vector &moreLoad)
00428 {
00429     if (moreLoad.Size() != numDof) {
00430         opserr << "WARNING (W_C_80) - UpdatedLagrangianBeam2D::addLoad(..) [" << getTag() << "]\n";
00431         opserr << "vector not of correct size\n";
00432         return -1;
00433     }
00434     load += moreLoad;
00435     return 0;
00436 }
00437 
00438 void UpdatedLagrangianBeam2D::getTrialLocalForce(Vector &lforce)
00439 {
00440         // Get the local elastic stiffness matrix, store in Kt
00441     getLocalStiff(Kt);
00442 
00443     // Add internal geometric stiffness matrix
00444     addInternalGeomStiff(Kt);
00445 
00446     // Get incremental local displacements  trial-conv.
00447         
00448         if(isLinear)
00449                 getIncrLocalDisp(disp);
00450         else
00451                 getIncrNaturalDisp(disp);
00452         
00453         //~ cout << disp << endln;
00454 /* 
00456 // using the natural deformation approach
00458 
00459         double l  = L_hist;
00460         double ua = disp(0);
00461         double ub = disp(3);
00462         double va = disp(1);
00463         double vb = disp(4);
00464         double ra = disp(2);
00465         double rb = disp(5);
00466 
00467         double un =   (ub - ua) 
00468                     + ( (ub - ua)*(ub - ua) + (vb - va)*(vb - va) )/(2*l);
00469 
00470         double rr  = atan( (vb - va)/(l + ub - ua) );
00471         double ran = ra - rr;
00472         double rbn = rb - rr;
00473 
00474         disp(0) = 0;
00475         disp(1) = 0;
00476         disp(2) = ran;
00477         disp(3) = un;
00478         disp(4) = 0;
00479         disp(5) = rbn;
00481 // end natural defo
00483 */
00484     // Compute local incremental force
00485     force = Kt*disp;
00486 
00487     // Compute total local force
00488     lforce = eleForce_hist + force;
00489 
00490 }
00491 
00492 const Vector &UpdatedLagrangianBeam2D::getResistingForce()
00493 {
00494     // check for quick return
00495     if (L == 0)
00496             return ZeroVector;
00497         
00498         m_Iter++;
00499 
00500         if(!isLinear)
00501                 this->updateState();
00502         
00503         this->getTrialLocalForce(eleForce);
00504 
00506 // start elementary
00508 
00509 /*
00510 double f0 = eleForce(0);
00511 double f1 = eleForce(1);
00512 double f2 = eleForce(2);
00513 double f3 = eleForce(3);
00514 double f4 = eleForce(4);
00515 double f5 = eleForce(5);
00516 
00517     eleForce(0) = (cs*cs_hist+sn*sn_hist)*f0+(-cs*sn_hist+sn*cs_hist)*f1;
00518         eleForce(1) = (-sn*cs_hist+cs*sn_hist)*f0+(cs*cs_hist+sn*sn_hist)*f1;
00519         eleForce(2) = f2;
00520         eleForce(3) = (cs*cs_hist+sn*sn_hist)*f3+(-cs*sn_hist+sn*cs_hist)*f4;
00521         eleForce(4) = (-sn*cs_hist+cs*sn_hist)*f3+(cs*cs_hist+sn*sn_hist)*f4;
00522     eleForce(5) = f5;
00523 */
00525 // end elementary
00527 
00528         double cos = cs;
00529         double sin = sn;
00530     // determine the ele end forces in global coords - want -F into rForce
00531     force(0) =  cos*eleForce(0) - sin*eleForce(1);
00532     force(1) =  sin*eleForce(0) + cos*eleForce(1);
00533     force(2) =  eleForce(2);
00534     force(3) =  cos*eleForce(3) - sin*eleForce(4);
00535     force(4) =  sin*eleForce(3) + cos*eleForce(4);
00536     force(5) =  eleForce(5);
00537 
00538     if(_debug)
00539       { opserr << "Global forces:\n " << force; 
00540       }
00541 
00542     return force;
00543 }
00544 
00545 const Vector &
00546 UpdatedLagrangianBeam2D::getResistingForceIncInertia()
00547 {
00548     // check for quick return
00549     if (L == 0)
00550         return ZeroVector;
00551 
00552     // form the stiffness matrix - we will do a P-kU-MA
00553     force = this->getResistingForce(); // now we have P-Ku
00554 
00555     // massDof <  0 for distributed mass
00556     // massDof =  0 if mass is specified at nodes
00557     // massDof >  0 for lumped mass
00558 
00559 
00560     // determine -Ma
00561     // optimize for lumped mass
00562     if (massDof != 0) {
00563       if(massDof > 0) {
00564         const Vector &end1Accel = end1Ptr->getTrialAccel();
00565         const Vector &end2Accel = end2Ptr->getTrialAccel();
00566         force(0) -= massDof*end1Accel(0);
00567         force(1) -= massDof*end1Accel(1);
00568         force(3) -= massDof*end2Accel(0);
00569         force(4) -= massDof*end2Accel(1);
00570       } else if(massDof < 0) {
00571         M = this->getMass();
00572         
00573         const Vector &end1Accel = end1Ptr->getTrialAccel();
00574         const Vector &end2Accel = end2Ptr->getTrialAccel();
00575         Vector Accel(6), f(6);
00576         int i=0;
00577         for(i=0; i<3; i++)
00578           {
00579             Accel(i)   = end1Accel(i);
00580             Accel(i+3) = end2Accel(i);
00581           }
00582         f = M*Accel;
00583         for(i=0; i<6; i++) force(i) -= f(i);
00584       }
00585 
00586       if (alphaM != 0.0 || betaK != 0.0 || betaK0 != 0.0 || betaKc != 0.0)
00587         force += this->getRayleighDampingForces();
00588     } else {
00589 
00590       if (betaK != 0.0 || betaK0 != 0.0 || betaKc != 0.0)
00591         force += this->getRayleighDampingForces();
00592     }    
00593     
00594     return force;
00595 }
00596 
00597 void UpdatedLagrangianBeam2D::transformToGlobal(Matrix &K)
00598 {
00599 double k00=K(0,0), k01=K(0,1), k02=K(0,2), k03=K(0,3), k04=K(0,4), k05=K(0,5);
00600 double k11=K(1,1), k12=K(1,2), k13=K(1,3), k14=K(1,4), k15=K(1,5);
00601 double k22=K(2,2), k23=K(2,3), k24=K(2,4), k25=K(2,5);
00602 double k33=K(3,3), k34=K(3,4), k35=K(3,5);
00603 double k44=K(4,4), k45=K(4,5);
00604 double k55=K(5,5);
00605 
00606  double cos = cs;
00607  double sin = sn;
00608 
00609     K(0,0) = (cos*k00-sin*k01)*cos-(cos*k01-sin*k11)*sin;
00610     K(0,1) = (cos*k00-sin*k01)*sin+(cos*k01-sin*k11)*cos;
00611     K(0,2) =  cos*k02-sin*k12;
00612     K(0,3) = (cos*k03-sin*k13)*cos-(cos*k04-sin*k14)*sin;
00613     K(0,4) = (cos*k03-sin*k13)*sin+(cos*k04-sin*k14)*cos;
00614     K(0,5) =  cos*k05-sin*k15;
00615 
00616     K(1,1) = (sin*k00+cos*k01)*sin+(sin*k01+cos*k11)*cos;
00617     K(1,2) =  sin*k02+cos*k12;
00618     K(1,3) = (sin*k03+cos*k13)*cos-(sin*k04+cos*k14)*sin;
00619     K(1,4) = (sin*k03+cos*k13)*sin+(sin*k04+cos*k14)*cos;
00620     K(1,5) =  sin*k05+cos*k15;
00621 
00622     K(2,2) =  k22;
00623     K(2,3) =  k23*cos-k24*sin;
00624     K(2,4) =  k23*sin+k24*cos;
00625     K(2,5) =  k25;
00626 
00627     K(3,3) = (cos*k33-sin*k34)*cos-(cos*k34-sin*k44)*sin;
00628     K(3,4) = (cos*k33-sin*k34)*sin+(cos*k34-sin*k44)*cos;
00629     K(3,5) =  cos*k35-sin*k45;
00630 
00631     K(4,4) = (sin*k33+cos*k34)*sin+(sin*k34+cos*k44)*cos;
00632     K(4,5) =  sin*k35+cos*k45;
00633 
00634     K(5,5) =  k55;
00635 
00636     for(int i=1; i<6; i++)
00637     {
00638         for(int j=0; j<i; j++)
00639         {
00640             K(i,j) = K(j,i);
00641         }
00642     }
00643 
00644 }
00645 
00647 // methods for getting local displacements
00649 void UpdatedLagrangianBeam2D::getTrialNaturalDisp(Vector &nDisp)
00650 {
00651     // getIncrLocalDisp(disp);
00652         getTrialLocalDisp(disp);
00654 // using the natural deformation approach
00656 
00657         double l  = L_hist;
00658         double ua = disp(0);
00659         double ub = disp(3);
00660         double va = disp(1);
00661         double vb = disp(4);
00662         double ra = disp(2);
00663         double rb = disp(5);
00664 
00665         double un =   (ub - ua) 
00666                     + ( (ub - ua)*(ub - ua) + (vb - va)*(vb - va) )/(2*l);
00667 
00668         double rr  = atan( (vb - va)/(l + ub - ua) );
00669         double ran = ra - rr;
00670         double rbn = rb - rr;
00671 
00672         nDisp(0) = 0;
00673         nDisp(1) = 0;
00674         nDisp(2) = ran;
00675         nDisp(3) = un;
00676         nDisp(4) = 0;
00677         nDisp(5) = rbn;
00678 }
00679 
00680 void UpdatedLagrangianBeam2D::getIncrNaturalDisp(Vector &nDisp)
00681 {
00682     getIncrLocalDisp(disp);
00683 
00685 // using the natural deformation approach
00687 
00688         double l  = L_hist;
00689         double ua = disp(0);
00690         double ub = disp(3);
00691         double va = disp(1);
00692         double vb = disp(4);
00693         double ra = disp(2);
00694         double rb = disp(5);
00695 
00696         double un =   (ub - ua) 
00697                     + ( (ub - ua)*(ub - ua) + (vb - va)*(vb - va) )/(2*l);
00698 
00699         double rr  = atan( (vb - va)/(l + ub - ua) );
00700         double ran = ra - rr;
00701         double rbn = rb - rr;
00702 
00703         nDisp(0) = 0;
00704         nDisp(1) = 0;
00705         nDisp(2) = ran;
00706         nDisp(3) = un;
00707         nDisp(4) = 0;
00708         nDisp(5) = rbn;
00709 
00710 
00711 }
00712 
00713 
00714 void UpdatedLagrangianBeam2D::getIncrLocalDisp(Vector &lDisp)
00715 {
00716     if (L == 0.0)
00717         return;
00718 
00719     const Vector &end1TrialDisp  = end1Ptr->getTrialDisp();
00720     const Vector &end2TrialDisp  = end2Ptr->getTrialDisp();    
00721         const Vector &end1CommitDisp = end1Ptr->getDisp();
00722         const Vector &end2CommitDisp = end2Ptr->getDisp();
00723         
00724 
00725         for(int i=0; i<3; i++)
00726         {
00727                 end1IncrDisp(i) = end1TrialDisp(i) - end1CommitDisp(i);
00728                 end2IncrDisp(i) = end2TrialDisp(i) - end2CommitDisp(i);
00729         }
00730 
00731     lDisp(0) = cs_hist * end1IncrDisp(0) + sn_hist * end1IncrDisp(1);
00732     lDisp(1) = cs_hist * end1IncrDisp(1) - sn_hist * end1IncrDisp(0);
00733     lDisp(2) = end1IncrDisp(2);
00734     lDisp(3) = cs_hist * end2IncrDisp(0) + sn_hist * end2IncrDisp(1);
00735     lDisp(4) = cs_hist * end2IncrDisp(1) - sn_hist * end2IncrDisp(0);
00736     lDisp(5) = end2IncrDisp(2);
00737 
00738     return;
00739 }
00740 
00741 void UpdatedLagrangianBeam2D::getTrialLocalDisp(Vector &lDisp)
00742 {   
00743     if(L == 0.0)
00744         return;
00745 
00746     const Vector &end1Disp  = end1Ptr->getTrialDisp();
00747     const Vector &end2Disp  = end2Ptr->getTrialDisp();
00748 
00749     lDisp(0) = cs * end1Disp(0) + sn * end1Disp(1);
00750     lDisp(1) = cs * end1Disp(1) - sn * end1Disp(0);
00751     lDisp(2) = end1Disp(2);    
00752     lDisp(3) = cs * end2Disp(0) + sn * end2Disp(1);
00753     lDisp(4) = cs * end2Disp(1) - sn * end2Disp(0);
00754     lDisp(5) = end2Disp(2);  
00755         
00756     return;
00757 }
00758 
00759 
00760 void UpdatedLagrangianBeam2D::getConvLocalDisp(Vector &lDisp)
00761 {   
00762     if (L == 0.0)
00763         return;
00764     
00765         const Vector &end1Disp = end1Ptr->getDisp();
00766         const Vector &end2Disp = end2Ptr->getDisp();
00767 
00768     lDisp(0) = cs_hist * end1Disp(0) + sn_hist * end1Disp(1);
00769     lDisp(1) = cs_hist * end1Disp(1) - sn_hist * end1Disp(0);
00770     lDisp(2) = end1Disp(2);    
00771     lDisp(3) = cs_hist * end2Disp(0) + sn_hist * end2Disp(1);
00772     lDisp(4) = cs_hist * end2Disp(1) - sn_hist * end2Disp(0);
00773     lDisp(5) = end2Disp(2);    
00774         
00775     return;
00776 }
00777 
00778 
00780 // methods for display/recorders... may be overridden if required
00782 
00783 int UpdatedLagrangianBeam2D::displaySelf(Renderer &theViewer, int displayMode, float fact)
00784 {
00785     // first determine the two end points of the element based on
00786     // the display factor (a measure of the distorted image)
00787     // store this information in 2 3d vectors v1 and v2
00788 
00789     const Vector &end1Crd = end1Ptr->getCrds();
00790     const Vector &end2Crd = end2Ptr->getCrds(); 
00791     const Vector &end1Disp = end1Ptr->getDisp();
00792     const Vector &end2Disp = end2Ptr->getDisp();    
00793     Vector rgb(3);
00794         rgb(0) = 0; rgb(1) = 0; rgb(2) = 1;
00795 
00796         Vector v1(3);
00797     Vector v2(3);
00798 
00799     for (int i=0; i<2; i++) {
00800         v1(i) = end1Crd(i)+end1Disp(i)*fact;
00801         v2(i) = end2Crd(i)+end2Disp(i)*fact;            
00802     }   
00803         v1(2) = 0;
00804         //v1(2) = end1Disp(2)*fact;
00805         v2(2) = 0;
00806         //v2(2) = end2Disp(2)*fact;
00807         
00808         //opserr << v1 << v2;
00809         if (displayMode == 1) theViewer.drawLine(v1, v2, rgb, rgb);     
00810         // cout << "line drawn << " << getTag() << endln;
00811         // cin.get();
00812         return 0;
00813     
00814     if (displayMode == 2) // axial force
00815         return theViewer.drawLine(v1, v2, eleForce(0), eleForce(3));
00816     else if (displayMode == 3) // shear forces
00817         return theViewer.drawLine(v1, v2, eleForce(1), eleForce(4));
00818     else if (displayMode == 4) // bending moments
00819         return theViewer.drawLine(v1, v2, eleForce(2), eleForce(5));
00820         
00821         return 0;
00822 }
00823 
00824 Response* UpdatedLagrangianBeam2D::setResponse(const char **argv, int argc, Information &eleInformation)
00825 {
00826     // force (axialForce)
00827     if ((strcmp(argv[0],"force") == 0) ||
00828         (strcmp(argv[0],"forces") == 0) ||
00829         (strcmp(argv[0],"localForce") == 0))
00830         {
00831                 return new ElementResponse(this, 1, Vector(6));
00832     }
00833 
00834         else if((strcmp(argv[0],"forceDisp")==0))
00835         {
00836                 if(strcmp(argv[1],"1") == 0) nodeRecord = 1;
00837                 else nodeRecord = 2;
00838 
00839                 if(strcmp(argv[2],"0") == 0) dofRecord = 0;
00840                 if(strcmp(argv[2],"1") == 0) dofRecord = 1;
00841                 if(strcmp(argv[2],"2") == 0) dofRecord = 2;
00842 
00843                 return  new ElementResponse(this, 4, Vector(7));
00844 
00845         }
00846 
00847         else if ((strcmp(argv[0],"globalForce") == 0))
00848         {
00849                 return  new ElementResponse(this, 5, Vector(6));
00850     }
00851 
00852     else if ((strcmp(argv[0],"disp") == 0) ||
00853         (strcmp(argv[0],"displacements") == 0) ||
00854         (strcmp(argv[0],"displacement") == 0))
00855         {
00856                 return  new ElementResponse(this, 2, Vector(6));
00857     }
00858 
00859     // tangent stiffness matrix
00860     else if (strcmp(argv[0],"stiffness") == 0) {
00861         return new ElementResponse(this, 3, Matrix(6,6));
00862     }
00863 
00864     // a material quantity: needs to be implemented in subclasses
00865 
00866     // otherwise response quantity is unknown for the UpdatedLagrangianBeam2D class
00867     /*else
00868     {
00869         opserr << "WARNING (W_C_90) - UpdatedLagrangianBeam2D::setResponse(..) [" << getTag() << "]\n";
00870                 opserr << "unknown response quantity\n";
00871                 return 0;
00872         }*/
00873         
00874         return 0;
00875 }
00876 
00877 int UpdatedLagrangianBeam2D::getResponse(int responseID, Information &eleInformation)
00878 {
00879   switch (responseID) {
00880     case -1:
00881       return -1;
00882 
00883     case 1:
00884                 if(eleInformation.theVector!=0)
00885                 {
00886                         *(eleInformation.theVector) = eleForce;
00887                 }
00888 
00889       return 0;
00890 
00891     case 2:
00892                 if(eleInformation.theVector!=0)
00893                 {
00894                         this->getTrialLocalDisp(disp);
00895                         *(eleInformation.theVector) = disp;
00896                 }
00897       return 0;
00898 
00899     case 3:
00900       if (eleInformation.theMatrix != 0)
00901           {
00902                 *(eleInformation.theMatrix) = this->getTangentStiff();
00903           }
00904       return 0;
00905 
00906         case 4:
00907                 if(eleInformation.theVector!=0)
00908                 {
00909                         Vector disp(3);
00910                         if(nodeRecord==1)       disp = end1Ptr->getDisp();
00911                         else                            disp = end2Ptr->getDisp();
00912                         
00913                         Vector temp(7);
00914                         temp(0) = disp(dofRecord);
00915                         for(int i=1; i < 7; i++) temp(i) = eleForce(i-1);
00916                         
00917                         eleInformation.theVector->addVector(0, temp, 1);
00918                 }
00919                 return 0;
00920         case 5:
00921                 if(eleInformation.theVector!=0)
00922                 {
00923                         double cos = cs;
00924                         double sin = sn;
00925                         // determine the ele end forces in global coords - want -F into rForce
00926                         force(0) =  cos*eleForce(0) - sin*eleForce(1);
00927                         force(1) =  sin*eleForce(0) + cos*eleForce(1);
00928                         force(2) =  eleForce(2);
00929                         force(3) =  cos*eleForce(3) - sin*eleForce(4);
00930                         force(4) =  sin*eleForce(3) + cos*eleForce(4);
00931                         force(5) =  eleForce(5);
00932                         
00933                         *(eleInformation.theVector) = force;
00934                 }
00935       return 0;
00936 
00937 
00938 
00939     default:      
00940           return -1;
00941   }
00942 }

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