Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

BeamWithHinges3d.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.4 $
00022 // $Date: 2001/01/31 10:40:20 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/element/beamWithHinges/BeamWithHinges3d.cpp,v $
00024                                                                         
00025                                                                         
00027 // File:  ~/Src/element/beamWithHinges/BeamWithHinges3d.cpp
00028 //
00029 // Written by MHS
00030 // June 2000
00031 //
00032 // Purpose:  This cpp file contains the definitions
00033 // for BeamWithHinges3d.
00034 
00035 #include <BeamWithHinges3d.h>
00036 #include <Element.h>
00037 #include <Domain.h>
00038 #include <Channel.h>
00039 #include <FEM_ObjectBroker.h>
00040 #include <Matrix.h>
00041 #include <Vector.h>      
00042 #include <Node.h>
00043 #include <MatrixUtil.h>      //For 3x3 matrix inversion
00044 #include <math.h>       //For sqrt function
00045 #include <stdlib.h>      
00046 #include <iostream.h>      //Not needed
00047 #include <string.h>
00048 #include <stdio.h>
00049 
00050 #include <SectionForceDeformation.h>
00051 #include <ElasticSection3d.h> // For numerical integration of interior
00052 #include <CrdTransf3d.h>
00053 
00054 #include <Information.h>
00055 #include <ElementResponse.h>
00056 #include <Renderer.h>
00057 
00058 BeamWithHinges3d::BeamWithHinges3d(void)
00059  :Element(0, ELE_TAG_BeamWithHinges3d),
00060  E(0), Iz(0), Iy(0), A(0), L(0),
00061  G(0), J(0), alpha(0),
00062  sectionI(0), sectionJ(0),
00063  connectedExternalNodes(2),
00064  node1Ptr(0), node2Ptr(0),
00065  hingeIlen(0), hingeJlen(0),
00066  K(12,12), m(12,12), d(12,12), fElastic(6,6), vElastic(6,3),
00067  UePrev(12), P(12), Pinert(12), kb(6,6), q(6),
00068  load(12), prevDistrLoad(3), 
00069  distrLoadCommit(3), UeCommit(12), 
00070  kbCommit(6,6), qCommit(6), massDens(0),
00071  shearLength(1.0), shearIkeyVY(-1), shearJkeyVY(-1),
00072  shearIkeyVZ(-1), shearJkeyVZ(-1),
00073  shearWeightIVY(1.0), shearWeightIVZ(1.0),
00074     shearWeightJVY(1.0), shearWeightJVZ(1.0),
00075  theCoordTransf(0), maxIter(1), tolerance(1.0e-10), initialFlag(false)
00076 {
00077 
00078 }
00079 
00080 BeamWithHinges3d::BeamWithHinges3d(int tag, int nodeI, int nodeJ,
00081       double E_in, double Iz_in, double Iy_in, double A_in,
00082       double G_in, double J_in, double alpha_in,
00083       SectionForceDeformation &sectionRefI, double I_length,
00084       SectionForceDeformation &sectionRefJ, double J_length,
00085       CrdTransf3d &coordTransf, double shearL,
00086       double massDensityPerUnitLength, int max, double tol)
00087  :Element(tag, ELE_TAG_BeamWithHinges3d),
00088  E(E_in), Iz(Iz_in), Iy(Iy_in), A(A_in),
00089  G(G_in), J(J_in), alpha(alpha_in),
00090  sectionI(0), sectionJ(0),
00091  connectedExternalNodes(2),
00092  node1Ptr(0), node2Ptr(0),
00093  hingeIlen(I_length), hingeJlen(J_length),
00094  K(12,12), m(12,12), d(12,12), fElastic(6,6), vElastic(6,3),
00095  UePrev(12), P(12), Pinert(12), kb(6,6), q(6),
00096  load(12), prevDistrLoad(3), 
00097  distrLoadCommit(3), UeCommit(12), 
00098  kbCommit(6,6), qCommit(6),
00099  massDens(massDensityPerUnitLength),
00100  shearLength(shearL), shearIkeyVY(-1), shearJkeyVY(-1),
00101  shearIkeyVZ(-1), shearJkeyVZ(-1),
00102  shearWeightIVY(1.0), shearWeightIVZ(1.0),
00103     shearWeightJVY(1.0), shearWeightJVZ(1.0),
00104  theCoordTransf(0), maxIter(max), tolerance(tol), initialFlag(false)
00105 {
00106  if (E <= 0.0)  {
00107   cerr << "FATAL - BeamWithHinges3d::BeamWithHinges3d() - Paramater E is zero or negative.";
00108   //exit(-1);
00109  }
00110  
00111  if (Iz <= 0.0)  {
00112   cerr << "FATAL - BeamWithHinges3d::BeamWithHinges3d() - Parameter Iz is zero or negative.";
00113   //exit(-1);
00114  }
00115  
00116  if (Iy <= 0.0)  {
00117   cerr << "FATAL - BeamWithHinges3d::BeamWithHinges3d() - Parameter Iy is zero or negative.";
00118   //exit(-1);
00119  }
00120  
00121  if (A <= 0.0)  {
00122   cerr << "FATAL - BeamWithHinges3d::BeamWithHinges3d() - Parameter A is zero or negative.";
00123   //exit(-1); 
00124  }
00125 
00126  if (G <= 0.0)  {
00127   cerr << "FATAL - BeamWithHinges3d::BeamWithHinges3d() - Parameter G is zero or negative.";
00128   //exit(-1); 
00129  }
00130  
00131  if (J <= 0.0)  {
00132   cerr << "FATAL - BeamWithHinges3d::BeamWithHinges3d() - Parameter J is zero or negative.";
00133   //exit(-1); 
00134  } 
00135 
00136  if (alpha < 0.0)  {
00137   cerr << "FATAL - BeamWithHinges3d::BeamWithHinges3d() - Parameter alpha is negative.";
00138   //exit(-1); 
00139  }
00140 
00141  // Get copies of sections
00142  sectionI = sectionRefI.getCopy();
00143  
00144  if (sectionI == 0)
00145   g3ErrorHandler->fatal("%s -- failed to get copy of section I",
00146    "BeamWithHinges3d::BeamWithHinges3d");
00147 
00148  sectionJ = sectionRefJ.getCopy();
00149 
00150  if (sectionJ == 0)
00151   g3ErrorHandler->fatal("%s -- failed to get copy of section J",
00152    "BeamWithHinges3d::BeamWithHinges3d");
00153 
00154  theCoordTransf = coordTransf.getCopy();
00155  
00156  if (theCoordTransf == 0)
00157      g3ErrorHandler->fatal("%s -- failed to get copy of coordinate transformation",
00158    "BeamWithHinges3d::BeamWithHinges3d");
00159  
00160  connectedExternalNodes(0) = nodeI;
00161  connectedExternalNodes(1) = nodeJ;
00162 }
00163 
00164 BeamWithHinges3d::BeamWithHinges3d(int tag, int nodeI, int nodeJ,
00165        double E_in, double Iz_in, double Iy_in, double A_in,
00166        double G_in, double J_in, double alpha_in,
00167        SectionForceDeformation &sectionRefI, double I_length,
00168        SectionForceDeformation &sectionRefJ, double J_length,
00169        CrdTransf3d &coordTransf, const Vector &distrLoad,
00170        double shearL, double massDensityPerUnitLength,
00171        int max, double tol)
00172  :Element(tag, ELE_TAG_BeamWithHinges3d),
00173  E(E_in), Iz(Iz_in), Iy(Iy_in), A(A_in),
00174  G(G_in), J(J_in), alpha(alpha_in),
00175  sectionI(0), sectionJ(0),
00176  connectedExternalNodes(2),
00177  node1Ptr(0), node2Ptr(0),
00178  hingeIlen(I_length), hingeJlen(J_length),
00179  K(12,12), m(12,12), d(12,12), fElastic(6,6), vElastic(6,3),
00180  UePrev(12), P(12), Pinert(12), kb(6,6), q(6),
00181  load(12), prevDistrLoad(3), 
00182  distrLoadCommit(3), UeCommit(12), 
00183  kbCommit(6,6), qCommit(6),
00184  massDens(massDensityPerUnitLength),
00185  shearLength(shearL), shearIkeyVY(-1), shearJkeyVY(-1),
00186  shearIkeyVZ(-1), shearJkeyVZ(-1),
00187  shearWeightIVY(1.0), shearWeightIVZ(1.0),
00188     shearWeightJVY(1.0), shearWeightJVZ(1.0),
00189  theCoordTransf(0), maxIter(max), tolerance(tol), initialFlag(false)
00190 {
00191  if (E <= 0.0)  {
00192   cerr << "FATAL - BeamWithHinges3d::BeamWithHinges3d() - Paramater E is zero or negative.";
00193   //exit(-1);
00194  }
00195  
00196  if (Iz <= 0.0)  {
00197   cerr << "FATAL - BeamWithHinges3d::BeamWithHinges3d() - Parameter Iz is zero or negative.";
00198   //exit(-1);
00199  }
00200  
00201  if (Iy <= 0.0)  {
00202   cerr << "FATAL - BeamWithHinges3d::BeamWithHinges3d() - Parameter Iy is zero or negative.";
00203   //exit(-1);
00204  }
00205  
00206  if (A <= 0.0)  {
00207   cerr << "FATAL - BeamWithHinges3d::BeamWithHinges3d() - Parameter A is zero or negative.";
00208   //exit(-1); 
00209  }
00210 
00211  if (G <= 0.0)  {
00212   cerr << "FATAL - BeamWithHinges3d::BeamWithHinges3d() - Parameter G is zero or negative.";
00213   //exit(-1); 
00214  }
00215  
00216  if (J <= 0.0)  {
00217   cerr << "FATAL - BeamWithHinges3d::BeamWithHinges3d() - Parameter J is zero or negative.";
00218   //exit(-1); 
00219  } 
00220 
00221  if (alpha < 0.0)  {
00222   cerr << "FATAL - BeamWithHinges3d::BeamWithHinges3d() - Parameter alpha is negative.";
00223   //exit(-1); 
00224  }
00225 
00226  // Get copies of sections
00227  sectionI = sectionRefI.getCopy();
00228  
00229  if (sectionI == 0)
00230   g3ErrorHandler->fatal("%s -- failed to get copy of section I",
00231    "BeamWithHinges3d::BeamWithHinges3d");
00232 
00233  sectionJ = sectionRefJ.getCopy();
00234 
00235  if (sectionJ == 0)
00236   g3ErrorHandler->fatal("%s -- failed to get copy of section J",
00237    "BeamWithHinges3d::BeamWithHinges3d");
00238 
00239  theCoordTransf = coordTransf.getCopy();
00240  
00241  if (theCoordTransf == 0)
00242      g3ErrorHandler->fatal("%s -- failed to get copy of coordinate transformation",
00243    "BeamWithHinges3d::BeamWithHinges3d");
00244 
00245  connectedExternalNodes(0) = nodeI;     //node tags
00246  connectedExternalNodes(1) = nodeJ;
00247 }
00248 
00249 BeamWithHinges3d::~BeamWithHinges3d(void)
00250 {
00251  //Only hinges must be destroyed
00252  if (sectionI)
00253   delete sectionI;
00254 
00255  if (sectionJ)
00256   delete sectionJ;
00257  
00258  if (theCoordTransf)
00259      delete theCoordTransf;
00260 }
00261 
00262 int 
00263 BeamWithHinges3d::getNumExternalNodes(void) const
00264 {
00265  return 2;
00266 }
00267 
00268 const ID &
00269 BeamWithHinges3d::getExternalNodes(void)
00270 {
00271  return connectedExternalNodes;
00272 }
00273 
00274 int 
00275 BeamWithHinges3d::getNumDOF(void)
00276 {
00277  return 12;
00278 }
00279 
00280 void
00281 BeamWithHinges3d::setDomain (Domain *theDomain)
00282 {
00283  //This function may be called after a beam is constructed, so
00284  //geometry may change.  Therefore calculate all beam geometry here.
00285 
00286  if(theDomain == 0) {
00287   node1Ptr = 0;
00288   node2Ptr = 0;
00289   return;
00290  }
00291  
00292  // set the node pointers and verify them
00293  this->setNodePtrs(theDomain);
00294 
00295  // call the DomainComponent version of the function
00296  this->DomainComponent::setDomain(theDomain);
00297 
00298  if (theCoordTransf->initialize(node1Ptr, node2Ptr) != 0) {
00299      cerr << "BeamWithHinges3d::setDomain(): Error initializing coordinate transformation";  
00300      exit(-1);
00301  }
00302  
00303  // get element length
00304  L = theCoordTransf->getInitialLength();
00305  
00306  if (L <= 0.0) {
00307      g3ErrorHandler->fatal("%s -- element has zero length",
00308    "BeamWithHinges3d::setDomain");
00309  }
00310 
00311  // Set up section interpolation and hinge lengths
00312  this->setHinges();
00313 
00314  // Calculate the elastic contribution to the element flexibility
00315  this->setElasticFlex();
00316 
00317  // Set the element lumped mass matrix
00318  this->setMass();
00319 }
00320 
00321 int
00322 BeamWithHinges3d::commitState(void)
00323 {
00324  int err = 0;
00325  
00326  err += sectionI->commitState();
00327  err += sectionJ->commitState();
00328 
00329  err += theCoordTransf->commitState();
00330  
00331  distrLoadCommit = prevDistrLoad;
00332  UeCommit = UePrev;
00333  kbCommit = kb;
00334  qCommit = q;
00335 
00336  initialFlag = false;
00337  
00338  return err;
00339 }
00340 
00341 int
00342 BeamWithHinges3d::revertToLastCommit(void)
00343 {
00344  int err = 0;
00345 
00346  // Revert the sections and then get their last commited
00347  // deformations, stress resultants, and flexibilities
00348  err += sectionI->revertToLastCommit();
00349  e1 = sectionI->getSectionDeformation();
00350  sr1 = sectionI->getStressResultant();
00351  fs1 = sectionI->getSectionFlexibility();
00352 
00353  err += sectionJ->revertToLastCommit();
00354  e3 = sectionJ->getSectionDeformation();
00355  sr3 = sectionJ->getStressResultant();
00356  fs3 = sectionJ->getSectionFlexibility();
00357 
00358  // Commit the coordinate transformation
00359  err += theCoordTransf->revertToLastCommit();
00360 
00361  prevDistrLoad = distrLoadCommit;
00362  UePrev = UeCommit;
00363  kb = kbCommit;
00364  q = qCommit;
00365 
00366  initialFlag = false;
00367 
00368  return err;
00369 }
00370 
00371 int
00372 BeamWithHinges3d::revertToStart(void)
00373 {
00374     int err = 0;
00375     
00376     err += sectionI->revertToStart();
00377     err += sectionJ->revertToStart();    
00378     
00379     err += theCoordTransf->revertToStart();
00380     
00381     fs1.Zero();
00382     fs3.Zero();    
00383     
00384     e1.Zero();
00385     e3.Zero(); 
00386 
00387  sr1.Zero();
00388  sr3.Zero();
00389     
00390     prevDistrLoad.Zero();
00391     UePrev.Zero();
00392     kb.Zero();
00393     q.Zero();
00394 
00395  return err;
00396 }
00397 
00398 const Matrix &
00399 BeamWithHinges3d::getTangentStiff(void)
00400 {
00401  this->setStiffMatrix();    //update first and then return K
00402  return K;
00403 }
00404 
00405 const Matrix &
00406 BeamWithHinges3d::getSecantStiff(void)
00407 {
00408  return this->getTangentStiff();
00409 }
00410 
00411 const Matrix &
00412 BeamWithHinges3d::getDamp(void)
00413 {
00414  return d; // zero matrix
00415 }
00416 
00417 const Matrix &
00418 BeamWithHinges3d::getMass(void)
00419 {
00420  // Lumped mass matrix only!!
00421  // Assumed that hinge's massDens/length is the same as the beam's!!
00422  return m;
00423 }
00424 
00425 void 
00426 BeamWithHinges3d::zeroLoad(void)
00427 {
00428  load.Zero();
00429 }
00430 
00431 int
00432 BeamWithHinges3d::addLoad(const Vector &moreLoad)
00433 {
00434  if(moreLoad.Size() != 12) {
00435   g3ErrorHandler->warning("%s -- moreLoad vector not of correct size",
00436    "BeamWithHinges3d::addLoad");
00437   return -1;
00438  }
00439 
00440  // load += moreLoad;
00441  load.addVector(1.0, moreLoad, 1.0);
00442  
00443  return 0;
00444 }
00445 
00446 int
00447 BeamWithHinges3d::addInertiaLoadToUnbalance(const Vector &accel)
00448 {
00449  if (massDens == 0.0)
00450   return 0;
00451 
00452  static Vector ag(12);
00453 
00454  const Vector &Raccel1 = node1Ptr->getRV(accel);
00455  const Vector &Raccel2 = node2Ptr->getRV(accel);
00456 
00457  int i,j;
00458  for (i = 0, j = 6; i < 3; i++, j++) {
00459   load(i) += m(i,i) * Raccel1(i);
00460   load(j) += m(j,j) * Raccel2(i); // Yes, this should be 'i'
00461  }
00462  
00463  return 0;
00464 }
00465 
00466 const Vector &
00467 BeamWithHinges3d::getResistingForce(void)
00468 {
00469  this->setStiffMatrix();
00470 
00471  // Subtract external nodal loads
00472  P.addVector(1.0, load, -1.0);
00473 
00474  return P;
00475 }
00476 
00477 const Vector &
00478 BeamWithHinges3d::getResistingForceIncInertia(void)
00479 {
00480  if (massDens == 0.0)
00481   return this->getResistingForce();
00482 
00483  static Vector ag(12);
00484  
00485  this->getGlobalAccels(ag);
00486  
00487  Pinert = this->getResistingForce();
00488  
00489  int i,j;
00490  for (i = 0, j = 6; i < 3; i++, j++) {
00491   Pinert(i) += m(i,i) * ag(i);
00492   Pinert(j) += m(j,j) * ag(j);
00493  }
00494 
00495  return Pinert;
00496 }
00497 
00498 int
00499 BeamWithHinges3d::sendSelf(int commitTag, Channel &theChannel)
00500 {
00501  int res = 0;
00502 
00503  int elemDbTag = this->getDbTag();
00504 
00505  static ID idData(13);
00506  
00507  int orderI = sectionI->getOrder();
00508  int orderJ = sectionJ->getOrder();
00509 
00510  idData(0) = this->getTag();
00511  idData(1) = sectionI->getClassTag();
00512  idData(2) = sectionJ->getClassTag();
00513  idData(5) = theCoordTransf->getClassTag();
00514  idData(7) = orderI;
00515  idData(8) = orderJ;
00516  idData(9) = maxIter;
00517  idData(10) = (initialFlag) ? 1 : 0;
00518  idData(11) = connectedExternalNodes(0);
00519  idData(12) = connectedExternalNodes(1);
00520 
00521  int sectDbTag;
00522 
00523  sectDbTag = sectionI->getDbTag();
00524     if (sectDbTag == 0) {
00525   sectDbTag = theChannel.getDbTag();
00526   sectionI->setDbTag(sectDbTag);
00527     }
00528     idData(3) = sectDbTag;
00529 
00530  sectDbTag = sectionJ->getDbTag();
00531     if (sectDbTag == 0) {
00532   sectDbTag = theChannel.getDbTag();
00533   sectionJ->setDbTag(sectDbTag);
00534     }
00535     idData(4) = sectDbTag;
00536 
00537  sectDbTag = theCoordTransf->getDbTag();
00538     if (sectDbTag == 0) {
00539   sectDbTag = theChannel.getDbTag();
00540   theCoordTransf->setDbTag(sectDbTag);
00541     }
00542     idData(6) = sectDbTag;
00543 
00544  // Send the data ID
00545  res += theChannel.sendID(elemDbTag, commitTag, idData);
00546  if (res < 0) {
00547   g3ErrorHandler->warning("%s -- failed to send data ID",
00548    "BeamWithHinges3d::sendSelf");
00549   return res;
00550  }
00551 
00552  // Ask the sectionI to send itself
00553  res += sectionI->sendSelf(commitTag, theChannel);
00554  if (res < 0) {
00555   g3ErrorHandler->warning("%s -- failed to send section I",
00556    "BeamWithHinges3d::sendSelf");
00557   return res;
00558  }
00559 
00560  // Ask the sectionJ to send itself
00561  res += sectionJ->sendSelf(commitTag, theChannel);
00562  if (res < 0) {
00563   g3ErrorHandler->warning("%s -- failed to send section J",
00564    "BeamWithHinges3d::sendSelf");
00565   return res;
00566  }
00567 
00568  // data, kbcommit, qcommit, Uecommit, distrLoadcommit
00569  static Vector data(13 + 6*6 + 6 + 12 + 3);
00570  
00571  data(0) = L;
00572  data(1) = E;  
00573  data(2) = A;
00574  data(3) = Iz;  
00575  data(4) = Iy;
00576  data(5) = G;
00577  data(6) = J;
00578  data(7) = alpha;
00579  data(8) = massDens;
00580  data(9) = hingeIlen/L;  // convert back to ratios
00581  data(10) = hingeJlen/L;
00582  data(11) = tolerance;
00583  data(12) = shearLength/L;
00584 
00585  // Jam committed history variables into the data vector
00586  int i,j;
00587  int loc = 13;
00588  for (i = 0; i < 6; i++)
00589   for (j = 0; j < 6; j++)
00590    data(loc++) = kbCommit(i,j);
00591 
00592  for (i = 0; i < 6; i++)
00593   data(loc++) = qCommit(i);
00594 
00595  for (i = 0; i < 12; i++)
00596   data(loc++) = UeCommit(i);
00597 
00598  for (i = 0; i < 3; i++)
00599   data(loc++) = distrLoadCommit(i);
00600 
00601  // Send the data vector
00602  res += theChannel.sendVector(elemDbTag, commitTag, data);
00603  if (res < 0) {
00604   g3ErrorHandler->warning("%s -- failed to send tags ID",
00605    "BeamWithHinges3d::sendSelf");
00606   return res;
00607  }
00608 
00609  // Ask the coordinate transformation to send itself
00610  res += theCoordTransf->sendSelf(commitTag, theChannel);
00611  if (res < 0) {
00612   g3ErrorHandler->warning("%s -- failed to send coordinate transformation",
00613    "BeamWithHinges3d::sendSelf");
00614   return res;
00615  }
00616 
00617  return res;
00618 }
00619 
00620 int 
00621 BeamWithHinges3d::recvSelf(int commitTag, Channel &theChannel,
00622        FEM_ObjectBroker &theBroker)
00623 {
00624  int res = 0;
00625 
00626  int elemDbTag = this->getDbTag();
00627 
00628  static ID idData(13);
00629 
00630  // Receive the ID data
00631  res += theChannel.recvID(elemDbTag, commitTag, idData);
00632  if (res < 0) {
00633   g3ErrorHandler->warning("%s -- failed to received data ID",
00634    "BeamWithHinges3d::recvSelf");
00635   return res;
00636  }
00637 
00638  this->setTag(idData(0));
00639  maxIter = idData(9);
00640  initialFlag = (idData(10) == 1) ? true : false;
00641  connectedExternalNodes(0) = idData(11);
00642  connectedExternalNodes(1) = idData(12);
00643 
00644  int secTag;
00645 
00646  // Receive section I
00647  secTag = idData(1);
00648 
00649  if (sectionI == 0)
00650   sectionI = theBroker.getNewSection(secTag);
00651 
00652  // Check that the section is of the right type; if not, delete
00653  // the current one and get a new one of the right type
00654  if (sectionI->getClassTag() != secTag) {
00655   delete sectionI;
00656   sectionI = theBroker.getNewSection(secTag);
00657  }
00658 
00659  if (sectionI == 0) {
00660   g3ErrorHandler->warning("%s -- could not get a Section",
00661    "BeamWithHinges3d::recvSelf");
00662   return -1;
00663  }
00664 
00665  // Now, receive the section
00666  sectionI->setDbTag(idData(3));
00667  res += sectionI->recvSelf(commitTag, theChannel, theBroker);
00668  if (res < 0) {
00669   g3ErrorHandler->warning("%s -- could not receive Section I",
00670    "BeamWithHinges3d::recvSelf");
00671   return res;
00672  }
00673 
00674  // Receive section J
00675  secTag = idData(2);
00676 
00677  if (sectionJ == 0)
00678   sectionJ = theBroker.getNewSection(secTag);
00679 
00680  // Check that the section is of the right type; if not, delete
00681  // the current one and get a new one of the right type
00682  else if (sectionJ->getClassTag() != secTag) {
00683   delete sectionJ;
00684   sectionJ = theBroker.getNewSection(secTag);
00685  }
00686 
00687  if (sectionJ == 0) {
00688   g3ErrorHandler->warning("%s -- could not get a Section",
00689    "BeamWithHinges3d::recvSelf");
00690   return -1;
00691  }
00692 
00693  // Now, receive the section
00694  sectionJ->setDbTag(idData(4));
00695  res += sectionJ->recvSelf(commitTag, theChannel, theBroker);
00696  if (res < 0) {
00697   g3ErrorHandler->warning("%s -- could not receive Section J",
00698    "BeamWithHinges3d::recvSelf");
00699   return res;
00700  }
00701 
00702  int orderI = idData(7);
00703  int orderJ = idData(8);
00704 
00705  static Vector data(13 + 6*6 + 6 + 12 + 3);
00706 
00707  res += theChannel.recvVector(elemDbTag, commitTag, data);
00708  if(res < 0) {
00709   g3ErrorHandler->warning("%s -- failed to receive Vector data",
00710    "BeamWithHinges3d::recvSelf");
00711   return res;
00712  }
00713 
00714  L = data(0);
00715  E = data(1);
00716  A = data(2);
00717  Iz = data(3);
00718  Iy = data(4);
00719  G = data(5);
00720  J = data(6);
00721  alpha = data(7);
00722  massDens = data(8);
00723  hingeIlen = data(9);
00724  hingeJlen = data(10);
00725  tolerance = data(11);
00726  shearLength = data(12);
00727 
00728  // Set up the section force interpolation
00729  this->setHinges();
00730 
00731  // Compute the elastic flexibility
00732  this->setElasticFlex();
00733 
00734  // Get committed history variables from the data vector
00735  int i,j;
00736  int loc = 13;
00737  for (i = 0; i < 6; i++)
00738   for (j = 0; j < 6; j++)
00739    kbCommit(i,j) = data(loc++);
00740 
00741  for (i = 0; i < 6; i++)
00742   qCommit(i) = data(loc++);
00743 
00744  for (i = 0; i < 12; i++)
00745   UeCommit(i) = data(loc++);
00746 
00747  for (i = 0; i < 3; i++)
00748   distrLoadCommit(i) = data(loc++);
00749 
00750  // Receive the coordinate transformation
00751  int crdTag = idData(5);
00752 
00753  // Allocate new CoordTransf if null
00754  if (theCoordTransf == 0)
00755   theCoordTransf = theBroker.getNewCrdTransf3d(crdTag);
00756 
00757  // Check that the CoordTransf is of the right type; if not, delete
00758  // the current one and get a new one of the right type
00759  else if (theCoordTransf->getClassTag() != crdTag) {
00760   delete theCoordTransf;
00761   theCoordTransf = theBroker.getNewCrdTransf3d(crdTag);
00762  }
00763 
00764  // Check if either allocation failed
00765  if (theCoordTransf == 0) {
00766   g3ErrorHandler->warning("%s -- could not get a CrdTransf3d",
00767    "BeamWithHinges3d::recvSelf");
00768   return -1;
00769  }
00770 
00771  // Now, receive the CoordTransf
00772  theCoordTransf->setDbTag(idData(6));
00773  res += theCoordTransf->recvSelf(commitTag, theChannel, theBroker);
00774  if (res < 0) {
00775   g3ErrorHandler->warning("%s -- could not receive CoordTransf",
00776    "BeamWithHinges3d::recvSelf");
00777   return res;
00778  }
00779  
00780  // Revert the element to the last committed state that was just received
00781  // Can't call this->revertToLastCommit() because this->setDomain() may
00782  // not have been called yet
00783  sectionI->revertToLastCommit();
00784  e1 = sectionI->getSectionDeformation();
00785  sr1 = sectionI->getStressResultant();
00786  fs1 = sectionI->getSectionFlexibility();
00787 
00788  sectionJ->revertToLastCommit();
00789  e3 = sectionJ->getSectionDeformation();
00790  sr3 = sectionJ->getStressResultant();
00791  fs3 = sectionJ->getSectionFlexibility();
00792 
00793  prevDistrLoad = distrLoadCommit;
00794  UePrev = UeCommit;
00795  kb = kbCommit;
00796  q = qCommit;
00797 
00798  initialFlag = false;
00799 
00800  return res;
00801 }
00802 
00803 void 
00804 BeamWithHinges3d::Print(ostream &s, int flag)
00805 {
00806  s << "\nBeamWithHinges3d, tag: " << this->getTag() << endl;
00807  s << "\tConnected Nodes: " << connectedExternalNodes;
00808  s << "\tE: " << E << endl;
00809  s << "\tA: " << A << endl;
00810  s << "\tIz: " << Iz << endl;
00811  s << "\tIy: " << Iy << endl;
00812  s << "\tG: " << G << endl;
00813  s << "\tJ: " << J << endl;
00814 
00815  if (sectionI)
00816   s << "\tHinge I, section tag: " << sectionI->getTag() << 
00817    ", length: " << hingeIlen << endl;
00818 
00819  if (sectionJ)
00820   s << "\tHinge J, section tag: " << sectionJ->getTag() << 
00821    ", length: " << hingeJlen << endl;
00822 }
00823 
00825 //Private Function Definitions
00826 
00827 void 
00828 BeamWithHinges3d::setNodePtrs(Domain *theDomain)
00829 {
00830  node1Ptr = theDomain->getNode(connectedExternalNodes(0));
00831  node2Ptr = theDomain->getNode(connectedExternalNodes(1));
00832 
00833  if(node1Ptr == 0) {
00834   g3ErrorHandler->fatal("%s -- end node %d not found in domain",
00835    "BeamWithHinges3d::setDomain", connectedExternalNodes(0));
00836  }
00837  
00838  if(node2Ptr == 0) {
00839   g3ErrorHandler->fatal("%s -- end node %d not found in domain",
00840    "BeamWithHinges3d::setDomain", connectedExternalNodes(1));
00841  }
00842  
00843  // check for correct # of DOF's
00844  int dofNd1 = node1Ptr->getNumberDOF();
00845  int dofNd2 = node2Ptr->getNumberDOF();
00846  if (dofNd1 != 6 || dofNd2 != 6) {
00847   g3ErrorHandler->fatal("%s -- nodal degrees of freedom not compatible with element",
00848    "BeamWithHinges3d::setDomain");
00849  }
00850 }
00851 
00852 void
00853 BeamWithHinges3d::getGlobalDispls(Vector &dg)    //get nodal displacements
00854 {
00855  const Vector &disp1 = node1Ptr->getTrialDisp();
00856  const Vector &disp2 = node2Ptr->getTrialDisp();
00857 
00858  dg(0) = disp1(0);  //left side
00859  dg(1) = disp1(1);
00860  dg(2) = disp1(2);
00861  dg(3) = disp1(3);  
00862  dg(4) = disp1(4);
00863  dg(5) = disp1(5);
00864  
00865  dg(6) = disp2(0);  //right side
00866  dg(7) = disp2(1);
00867  dg(8) = disp2(2);
00868  dg(9) = disp2(3);  
00869  dg(10) = disp2(4);
00870  dg(11) = disp2(5); 
00871 }
00872 
00873 void
00874 BeamWithHinges3d::getGlobalAccels(Vector &ag) //for dynamic analysis
00875 {
00876  const Vector &accel1 = node1Ptr->getTrialAccel();
00877  const Vector &accel2 = node2Ptr->getTrialAccel();
00878 
00879  ag(0) = accel1(0);
00880  ag(1) = accel1(1);
00881  ag(2) = accel1(2);
00882  ag(3) = accel1(3);
00883  ag(4) = accel1(4);
00884  ag(5) = accel1(5);
00885  
00886  ag(6) = accel2(0);
00887  ag(7) = accel2(1);
00888  ag(8) = accel2(2);
00889  ag(9) = accel2(3);
00890  ag(10) = accel2(4);
00891  ag(11) = accel2(5); 
00892 }
00893 
00894 void
00895 BeamWithHinges3d::setElasticFlex ()
00896 {
00897  //calculates the middle beam flexibility matrix
00898  //this is obtained by integrating (from lp1 to L-lp2) the matrix
00899  //b ^ fs ^ b, where fs is a constant linear section flexibility matrix.
00900  
00901  fElastic.Zero();
00902  vElastic.Zero();
00903  
00904  double a = hingeIlen;
00905  double b = L-hingeJlen;
00906 
00907  // Integrate elastic portion numerically 
00908  // Create elastic section
00909  static Matrix fElas(4,4);
00910  fElas(0,0) = 1/(E*A);
00911  fElas(1,1) = 1/(E*Iz);
00912  fElas(2,2) = 1/(E*Iy);
00913  fElas(3,3) = 1/(G*J);
00914 
00915  // Section code passed to force interpolation
00916  static ID code(4);
00917  code(0) = SECTION_RESPONSE_P;
00918  code(1) = SECTION_RESPONSE_MZ;
00919  code(2) = SECTION_RESPONSE_MY;
00920  code(3) = SECTION_RESPONSE_T;
00921 
00922  // Section force interpolation matrix
00923  static Matrix bElas(4,6);
00924  
00925  // Mapping from [-1,1] to [a,b]
00926  double alpha = 0.5*(b-a); // Jacobian
00927  double beta = 0.5*(a+b);
00928 
00929  // Integration points ... the weights are 1.0*(0.5*(b-a)) ==> alpha
00930  const double xsi = 1.0/sqrt(3.0);
00931  double x1 = alpha*(-xsi) + beta;
00932  double x2 = alpha*xsi + beta; 
00933 
00934  int dum; 
00935  // Get interpolations at sample points and integrate
00936  this->getForceInterpMatrix(bElas, x1, code, dum, dum);
00937  fElastic.addMatrixTripleProduct(1.0, bElas, fElas, alpha);
00938  vElastic.addMatrix(1.0, bElas^ fElas, alpha);
00939  
00940  this->getForceInterpMatrix(bElas, x2, code, dum, dum);
00941  fElastic.addMatrixTripleProduct(1.0, bElas, fElas, alpha);
00942  vElastic.addMatrix(1.0, bElas^ fElas, alpha);
00943  
00944  /*
00945  double shearFlex = 0.0;
00946 
00947  if (alpha > 0.0)
00948   shearFlex = 1/((G*A*alpha)*L*L) * (b-a);
00949 
00950  fElastic(0,0) = 1/(E*A) * ( b-a );
00951  
00952  fElastic(1,1) = 1/(E*Iz) * ( 1/(3*L*L)*(b*b*b-a*a*a) - 1/L*(b*b-a*a) + b-a ) + shearFlex;
00953  fElastic(2,2) = 1/(E*Iz) * ( 1/(3*L*L)*(b*b*b-a*a*a) ) + shearFlex;
00954  fElastic(1,2) = 1/(E*Iz) * ( 1/(3*L*L)*(b*b*b-a*a*a) - 1/(2*L)*(b*b-a*a) ) + shearFlex;
00955  fElastic(2,1) = fElastic(1,2);
00956 
00957  fElastic(3,3) = 1/(E*Iy) * ( 1/(3*L*L)*(b*b*b-a*a*a) - 1/L*(b*b-a*a) + b-a ) + shearFlex;
00958  fElastic(4,4) = 1/(E*Iy) * ( 1/(3*L*L)*(b*b*b-a*a*a) ) + shearFlex;
00959  fElastic(3,4) = 1/(E*Iy) * ( 1/(3*L*L)*(b*b*b-a*a*a) - 1/(2*L)*(b*b-a*a) ) + shearFlex;
00960  fElastic(4,3) = fElastic(3,4);
00961  
00962  fElastic(5,5) = 1/(G*J) * ( b-a );
00963 
00964  vElastic.Zero();
00965 
00966  vElastic(0,0) = 1/(E*A) * ( b-a - 1/(2*L)*(b*b-a*a) );
00967  vElastic(1,1) = 1/(E*Iz) * ( 1/(4*L*L*L)*(b*b*b*b-a*a*a*a) - 1/(3*L*L)*(b*b*b-a*a*a) );
00968  vElastic(3,2) = 1/(E*Iy) * ( 1/(4*L*L*L)*(b*b*b*b-a*a*a*a) - 1/(3*L*L)*(b*b*b-a*a*a) ); 
00969 
00970  if (alpha > 0.0) {
00971      vElastic(2,1) = 1/(G*A*alpha) * ( 1/(2*L*L)*(b*b-a*a) - 1/(2*L)*(b-a) );
00972      vElastic(4,2) = 1/(G*A*alpha) * ( 1/(2*L*L)*(b*b-a*a) - 1/(2*L)*(b-a) );
00973  }
00974  */
00975 }
00976 
00977 void
00978 BeamWithHinges3d::setStiffMatrix(void)
00979 {
00980     // Get element global end displacements
00981     static Vector Ue(12);
00982     this->getGlobalDispls(Ue);
00983     
00984     // Compute global end deformation increments
00985     static Vector dUe(12);
00986     //dUe = Ue - UePrev;
00987  dUe = Ue;
00988  dUe.addVector(1.0, UePrev, -1.0);
00989 
00990     // Check if global end displacements have been changed
00991     if (dUe.Norm() != 0.0 || initialFlag == false) {
00992  // Compute distributed loads and increments
00993  static Vector currDistrLoad(3);
00994  static Vector distrLoadIncr(3); 
00995  
00996  currDistrLoad.Zero();
00997  //distrLoadIncr = currDistrLoad - prevDistrLoad;
00998  distrLoadIncr = currDistrLoad;
00999  distrLoadIncr.addVector(1.0, prevDistrLoad, -1.0);
01000  
01001  prevDistrLoad = currDistrLoad;
01002  
01003  // Update the end deformations
01004  UePrev = Ue;
01005  
01006  theCoordTransf->update();
01007  
01008  // Convert to basic system from local coord's (eleminate rb-modes)
01009  static Vector v(6);    // basic system deformations
01010  static Vector dv(6);
01011 
01012  v = theCoordTransf->getBasicTrialDisp();
01013  dv = theCoordTransf->getBasicIncrDeltaDisp();
01014  
01015  // calculate nodal force increments and update nodal forces
01016  static Vector dq(6);
01017 
01018  //dq = kb * dv;     // using previous stiff matrix k,i
01019  dq.addMatrixVector(0.0, kb, dv, 1.0);
01020  
01021  // Element properties
01022  static Matrix f(6,6); // Element flexibility
01023  static Vector vr(6); // Residual element deformations
01024  
01025  
01026  Vector s1(sectionI->getStressResultant());
01027  Vector ds1(s1);
01028  Vector de1(s1);
01029  
01030  Vector s3(sectionJ->getStressResultant());
01031  Vector ds3(s3); 
01032  Vector de3(s3);
01033  
01034  static Matrix I(6,6);
01035  for (int i = 0; i < 6; i++)
01036   I(i,i) = 1.0;
01037 
01038  for (int j = 0; j < maxIter; j++) {
01039      
01040      //q += dq;
01041   q.addVector(1.0, dq, 1.0);
01042      
01043      // Section forces
01044      //s1 = b1*q + bp1*currDistrLoad;
01045   s1.addMatrixVector(0.0, b1, q, 1.0);
01046   s1.addMatrixVector(1.0, bp1, currDistrLoad, 1.0);
01047 
01048      //s3 = b3*q + bp3*currDistrLoad;
01049   s3.addMatrixVector(0.0, b3, q, 1.0);
01050   s3.addMatrixVector(1.0, bp3, currDistrLoad, 1.0);
01051      
01052      // Increment in section forces
01053   // ds1 = s1 - sr1
01054   ds1 = s1;
01055   ds1.addVector(1.0, sr1, -1.0);
01056 
01057   // ds3 = s3 - sr3
01058   ds3 = s3;
01059   ds3.addVector(1.0, sr3, -1.0);
01060 
01061      // compute section deformation increments and update current deformations
01062      //e1 += fs1 * ds1;
01063   //e3 += fs3 * ds3;
01064   de1.addMatrixVector(0.0, fs1, ds1, 1.0);
01065   if (initialFlag != false)
01066    e1.addVector(1.0, de1, 1.0);
01067   
01068      de3.addMatrixVector(0.0, fs3, ds3, 1.0);
01069   if (initialFlag != false)
01070    e3.addVector(1.0, de3, 1.0);
01071      
01072      /*** Dependent on section type ***/
01073      // set section deformations
01074      sectionI->setTrialSectionDeformation(e1);
01075      sectionJ->setTrialSectionDeformation(e3);
01076      
01077      /*** Dependent on section type ***/
01078      // get section resisting forces
01079      sr1 = sectionI->getStressResultant();
01080      sr3 = sectionJ->getStressResultant();
01081      
01082      /*** Dependent on section type ***/
01083      // get section flexibility matrix
01084      fs1 = sectionI->getSectionFlexibility();
01085      fs3 = sectionJ->getSectionFlexibility();
01086      
01087   // ds1 = s1 - sr1;
01088   // ds3 = s3 - sr3;
01089   ds1 = s1;
01090   ds1.addVector(1.0, sr1, -1.0);
01091   ds3 = s3;
01092   ds3.addVector(1.0, sr3, -1.0);
01093 
01094   de1.addMatrixVector(0.0, fs1, ds1, 1.0);
01095   de3.addMatrixVector(0.0, fs3, ds3, 1.0);
01096      
01097      // Use special integration on the diagonal shear flexibility and shear
01098   // deformation terms
01099   int i;
01100   int orderI = sectionI->getOrder();
01101   const ID &codeI = sectionI->getType();
01102   for (i = 0; i < orderI; i++) {
01103    if (codeI(i) == SECTION_RESPONSE_VY) {
01104     fs1(i,i) *= shearWeightIVY;
01105     e1(i) *= shearWeightIVY;
01106     de1(i) *= shearWeightIVY;
01107    }
01108    if (codeI(i) == SECTION_RESPONSE_VZ) {
01109     fs1(i,i) *= shearWeightIVZ;
01110     e1(i) *= shearWeightIVZ;
01111     de1(i) *= shearWeightIVZ;
01112    }
01113   }
01114 
01115   int orderJ = sectionJ->getOrder();
01116   const ID &codeJ = sectionJ->getType();
01117   for (i = 0; i < orderJ; i++) {
01118    if (codeJ(i) == SECTION_RESPONSE_VY) {
01119     fs3(i,i) *= shearWeightJVY;
01120     e3(i) *= shearWeightJVY;
01121     de3(i) *= shearWeightJVY;
01122    }
01123    if (codeJ(i) == SECTION_RESPONSE_VZ) {
01124     fs3(i,i) *= shearWeightJVZ;
01125     e3(i) *= shearWeightJVZ;
01126     de3(i) *= shearWeightJVZ;
01127    }
01128   }
01129      
01130   f = fElastic;
01131 
01132      // integrate section flexibility matrix
01133      // Matrix f1 = (b1^ fs1 * b1) * hingeIlen;
01134   f.addMatrixTripleProduct(1.0, b1, fs1, hingeIlen);
01135 
01136      // Matrix f3 = (b3^ fs3 * b3) * hingeJlen;
01137   f.addMatrixTripleProduct(1.0, b3, fs3, hingeJlen);
01138 
01139   // vr = fElastic * q;
01140   vr.addMatrixVector(0.0, fElastic, q, 1.0);
01141 
01142   // vr = vr + vElastic*currDistrLoad;
01143   vr.addMatrixVector(1.0, vElastic, currDistrLoad, 1.0);
01144 
01145      // vr += vr1, where vr1 = (b1^ (e1+de1)) * hingeIlen;
01146   vr.addMatrixTransposeVector(1.0, b1, e1 + de1, hingeIlen);
01147 
01148      // vr += vr3, where vr3 = (b3^ (e3+de3)) * hingeJlen;
01149      vr.addMatrixTransposeVector(1.0, b3, e3 + de3, hingeJlen);
01150 
01151      // Undo the temporary change for integrating shear terms, as
01152   // e1 and e3 are history variables
01153   for (i = 0; i < orderI; i++) {
01154    if (codeI(i) == SECTION_RESPONSE_VY) {
01155     fs1(i,i) /= shearWeightIVY;
01156     e1(i) /= shearWeightIVY;
01157     de1(i) /= shearWeightIVY;
01158    }
01159    if (codeI(i) == SECTION_RESPONSE_VZ) {
01160     fs1(i,i) /= shearWeightIVZ;
01161     e1(i) /= shearWeightIVZ;
01162     de1(i) /= shearWeightIVZ;
01163    }
01164   }
01165      
01166   for (i = 0; i < orderJ; i++) {
01167    if (codeJ(i) == SECTION_RESPONSE_VY) {
01168     fs3(i,i) /= shearWeightJVY;
01169     e3(i) /= shearWeightJVY;
01170     de3(i) /= shearWeightJVY;
01171    }
01172    if (codeJ(i) == SECTION_RESPONSE_VZ) {
01173     fs3(i,i) /= shearWeightJVZ;
01174     e3(i) /= shearWeightJVZ;
01175     de3(i) /= shearWeightJVZ;
01176    }
01177   }
01178 
01179      // calculate element stiffness matrix
01180      if (f.Solve(I,kb) < 0)
01181    g3ErrorHandler->warning("%s -- could not invert flexibility",
01182     "BeamWithHinges3d::setStiffMatrix");
01183  
01184      //dv = v - vr;
01185   dv = v;
01186   dv.addVector(1.0, vr, -1.0);
01187  
01188      // determine resisting forces
01189      // dq = kb * dv;
01190   dq.addMatrixVector(0.0, kb, dv, 1.0);
01191  
01192      double dW = dv^ dq;
01193 
01194      if (fabs(dW) < tolerance)
01195    break;
01196  } 
01197     
01198  // q += dq;
01199  q.addVector(1.0, dq, 1.0);
01200     
01201  P = theCoordTransf->getGlobalResistingForce (q, currDistrLoad);
01202  K = theCoordTransf->getGlobalStiffMatrix (kb, q);
01203 
01204  initialFlag = true;
01205     }
01206 
01207     return;
01208 }
01209 
01210 void
01211 BeamWithHinges3d::setMass(void)
01212 {
01213  //Note:  Lumped mass matrix only!
01214  //Note:  It is assumed that section's massDens is the same as beam's.
01215  m.Zero();
01216  m(0,0) = m(1,1) = m(2,2) = m(6,6) = m(7,7) = m(8,8) = massDens * L / 2.0;
01217 }
01218 
01219 void
01220 BeamWithHinges3d::setHinges (void)
01221 {
01222  // Get the number of section response quantities
01223  int orderI = sectionI->getOrder();
01224  int orderJ = sectionJ->getOrder();
01225 
01226  // Set interpolation matrices
01227  b1 = Matrix(orderI,6);
01228  b3 = Matrix(orderJ,6);
01229 
01230  // Set distributed load interpolation matrices
01231  bp1 = Matrix(orderI,3);
01232  bp3 = Matrix(orderJ,3);
01233 
01234  fs1 = Matrix(orderI,orderI);
01235  fs3 = Matrix(orderJ,orderJ);
01236 
01237  e1 = Vector(orderI);
01238  e3 = Vector(orderJ);
01239  
01240  sr1 = Vector(orderI);
01241  sr3 = Vector(orderJ);
01242 
01243  // Turn the hinge length ratios into actual lengths since L is not
01244  // known until setDomain() is called
01245  hingeIlen *= L;
01246  hingeJlen *= L;
01247  shearLength *= L;
01248 
01249  // Interpolation points
01250  double x1 = hingeIlen/2.0;
01251  double x3 = L - hingeJlen/2.0;
01252 
01253  // Get codes which indicate the ordering of section response quantities
01254  const ID &Icode = sectionI->getType();
01255  const ID &Jcode = sectionJ->getType();
01256 
01257  // Get the force interpolation matrix for each section
01258  this->getForceInterpMatrix (b1, x1, Icode, shearIkeyVY, shearIkeyVZ);
01259  this->getForceInterpMatrix (b3, x3, Jcode, shearJkeyVY, shearJkeyVZ);
01260 
01261  // Get the distributed load interpolation matrix for each section
01262  this->getDistrLoadInterpMatrix (bp1, x1, Icode);
01263  this->getDistrLoadInterpMatrix (bp3, x3, Jcode);
01264  
01265  if (shearIkeyVY >= 0 && hingeIlen > 0.0)
01266      shearWeightIVY = shearLength/hingeIlen;
01267  else {
01268      shearWeightIVY = 1.0;
01269      shearIkeyVY = 0;
01270  }
01271  
01272  if (shearIkeyVZ >= 0 && hingeIlen > 0.0)
01273      shearWeightIVZ = shearLength/hingeIlen;
01274  else {
01275      shearWeightIVZ = 1.0;
01276      shearIkeyVZ = 0;
01277  } 
01278  
01279  if (shearJkeyVY >= 0 && hingeJlen > 0.0)
01280      shearWeightJVY = shearLength/hingeJlen;
01281  else {
01282      shearWeightJVY = 1.0;
01283      shearJkeyVY = 0;
01284  }
01285  
01286  if (shearJkeyVZ >= 0 && hingeJlen > 0.0)
01287      shearWeightJVZ = shearLength/hingeJlen;
01288  else {
01289      shearWeightJVZ = 1.0;
01290      shearJkeyVZ = 0;
01291  }  
01292 }
01293 
01294 void
01295 BeamWithHinges3d::getForceInterpMatrix (Matrix &b, double x, const ID &code,
01296      int &shearKeyVY, int &shearKeyVZ)
01297 {   
01298     b.Zero();
01299 
01300  shearKeyVY = -1;
01301  shearKeyVZ = -1;
01302 
01303     double xsi = x/L;
01304 
01305     for (int i = 0; i < code.Size(); i++) {
01306  switch (code(i)) {
01307    case SECTION_RESPONSE_MZ:  // Moment, Mz, interpolation
01308      b(i,1) = xsi - 1.0;
01309      b(i,2) = xsi;
01310      break;
01311    case SECTION_RESPONSE_P:  // Axial, P, interpolation
01312      b(i,0) = 1.0;
01313      break;
01314    case SECTION_RESPONSE_VY:  // Shear, Vy, interpolation
01315      b(i,1) = 1.0/L;
01316      b(i,2) = 1.0/L;
01317      shearKeyVY = i;
01318      break;
01319    case SECTION_RESPONSE_MY:
01320      b(i,3) = xsi - 1.0;
01321      b(i,4) = xsi;
01322      break;
01323    case SECTION_RESPONSE_VZ:
01324      b(i,3) = 1.0/L;
01325      b(i,4) = 1.0/L;
01326      shearKeyVZ = i;
01327      break;
01328    case SECTION_RESPONSE_T:
01329      b(i,5) = 1.0;
01330      break;
01331    default:
01332      break;
01333  }
01334     }
01335 }
01336 
01337 void
01338 BeamWithHinges3d::getDistrLoadInterpMatrix (Matrix &bp, double x, const ID & code)
01339 {
01340     bp.Zero();
01341 
01342     double xsi = x/L;
01343 
01344     for (int i = 0; i < code.Size(); i++) {
01345  switch (code(i)) {
01346    case SECTION_RESPONSE_MZ:  // Moment, Mz, interpolation
01347      bp(i,1) = 0.5*xsi*(xsi-1);
01348      break;
01349    case SECTION_RESPONSE_P:  // Axial, P, interpolation
01350      bp(i,0) = 1 - xsi;
01351      break;
01352    case SECTION_RESPONSE_VY:  // Shear, Vy, interpolation
01353      bp(i,1) = xsi - 0.5;
01354      break;
01355    case SECTION_RESPONSE_MY:  // Moment, My, interpolation
01356      bp(i,1) = 0.5*xsi*(xsi-1);
01357      break;
01358    case SECTION_RESPONSE_VZ:  // Shear, Vz, interpolation
01359      bp(i,1) = xsi - 0.5;
01360      break;     
01361    case SECTION_RESPONSE_T:  // Torsion, T, interpolation
01362      break;
01363    default:
01364      break;
01365  }
01366     }
01367 }
01368 
01369 Response*
01370 BeamWithHinges3d::setResponse (char **argv, int argc, Information &info)
01371 {
01372     // hinge rotations
01373     if (strcmp(argv[0],"rotation") == 0)
01374   return new ElementResponse(this, 1, Vector(4));
01375 
01376     // global forces
01377     else if (strcmp(argv[0],"force") == 0 || strcmp(argv[0],"forces") == 0 ||
01378   strcmp(argv[0],"globalForce") == 0 || strcmp(argv[0],"globalForces") == 0)
01379   return new ElementResponse(this, 2, P);
01380     
01381     // stiffness
01382     else if (strcmp(argv[0],"stiffness") == 0)
01383   return new ElementResponse(this, 3, K);
01384 
01385  // local forces
01386     else if (strcmp(argv[0],"localForce") == 0 || strcmp(argv[0],"localForces") == 0)
01387   return new ElementResponse(this, 4, P);
01388 
01389  // section response
01390  else if (strcmp(argv[0],"section") == 0) {
01391   int sectionNum = atoi(argv[1]);
01392  
01393   if (sectionNum == 1)
01394    return sectionI->setResponse(&argv[2], argc-2, info);
01395   else if (sectionNum == 2)
01396    return sectionJ->setResponse(&argv[2], argc-2, info);
01397   else
01398    return 0;
01399     }
01400  else
01401   return 0;
01402 }
01403 
01404 int
01405 BeamWithHinges3d::getResponse (int responseID, Information &eleInfo)
01406 {
01407  double V;
01408  static Vector rot(4);
01409  static Vector force(12);
01410 
01411     switch (responseID) {
01412       case 1: { // hinge rotations ... flexibility formulation, so add deformations
01413   int i;
01414   rot.Zero();
01415   
01416   const Vector &defI = sectionI->getSectionDeformation();
01417   int orderI = sectionI->getOrder();
01418   const ID &codeI = sectionI->getType();
01419   for (i = 0; i < orderI; i++) {
01420    if (codeI(i) == SECTION_RESPONSE_MZ)
01421     rot(0) += defI(i)*hingeIlen;
01422    if (codeI(i) == SECTION_RESPONSE_MY)
01423     rot(1) += defI(i)*hingeIlen;
01424   }
01425 
01426   const Vector &defJ = sectionJ->getSectionDeformation();
01427   int orderJ = sectionJ->getOrder();
01428   const ID &codeJ = sectionJ->getType();
01429   for (i = 0; i < orderJ; i++) {
01430    if (codeJ(i) == SECTION_RESPONSE_MZ)
01431     rot(2) += defJ(i)*hingeJlen;
01432    if (codeJ(i) == SECTION_RESPONSE_MY)
01433     rot(3) += defJ(i)*hingeJlen;
01434   }
01435 
01436   return eleInfo.setVector(rot);
01437       }
01438 
01439       case 2: // global forces
01440     return eleInfo.setVector(P);
01441 
01442       case 3: // stiffness
01443     return eleInfo.setMatrix(K);
01444 
01445    case 4: // local forces
01446   // Axial
01447   force(6) = q(0);
01448   force(0) = -q(0);
01449 
01450   // Torsion
01451   force(11) = q(5);
01452   force(5)  = -q(5);
01453 
01454   // Moments about z and shears along y
01455   force(2) = q(1);
01456   force(8) = q(2);
01457   V = (q(1)+q(2))/L;
01458   force(1) = V;
01459   force(7) = -V;
01460 
01461   // Moments about y and shears along z
01462   force(4)  = q(3);
01463   force(10) = q(4);
01464   V = (q(3)+q(4))/L;
01465   force(3) = -V;
01466   force(9) = V;
01467 
01468   return eleInfo.setVector(force);
01469 
01470       default:
01471     return -1;
01472 
01473     }
01474 }
01475 
01476 int
01477 BeamWithHinges3d::displaySelf(Renderer &theViewer, int displayMode, float fact)
01478 {
01479     // first determine the end points of the quad based on
01480     // the display factor (a measure of the distorted image)
01481     const Vector &end1Crd = node1Ptr->getCrds();
01482     const Vector &end2Crd = node2Ptr->getCrds(); 
01483 
01484     const Vector &end1Disp = node1Ptr->getDisp();
01485     const Vector &end2Disp = node2Ptr->getDisp();
01486 
01487  static Vector v1(3);
01488  static Vector v2(3);
01489 
01490  for (int i = 0; i < 3; i++) {
01491   v1(i) = end1Crd(i) + end1Disp(i)*fact;
01492   v2(i) = end2Crd(i) + end2Disp(i)*fact;    
01493  }
01494  
01495  return theViewer.drawLine (v1, v2, 1.0, 1.0);
01496 }
01497 
01498 int
01499 BeamWithHinges3d::setParameter (char **argv, int argc, Information &info)
01500 {
01501     // E of the beam interior
01502     if (strcmp(argv[0],"E") == 0) {
01503  info.theType = DoubleType;
01504  return 1;
01505     }
01506     
01507     // G of the beam interior
01508     else if (strcmp(argv[0],"G") == 0) {
01509  info.theType = DoubleType;
01510  return 2;
01511     }
01512     
01513     // A of the beam interior
01514     else if (strcmp(argv[0],"A") == 0) {
01515  info.theType = DoubleType;
01516  return 3;
01517     }
01518     
01519     // I of the beam interior
01520     else if (strcmp(argv[0],"Iz") == 0) {
01521  info.theType = DoubleType;
01522  return 4;
01523     }
01524     
01525     // alpha of the beam interior
01526     else if (strcmp(argv[0],"a") == 0 || strcmp(argv[0],"alpha") == 0) {
01527  info.theType = DoubleType;
01528  return 5;
01529     }
01530     
01531     // Section parameter
01532     else if (strcmp(argv[0],"section") ==0) {
01533  if (argc <= 2)
01534      return -1;
01535  
01536  int sectionNum = atoi(argv[1]);
01537  
01538  int ok = -1;
01539  
01540  if (sectionNum == 1)
01541      ok = sectionI->setParameter (&argv[2], argc-2, info);
01542  if (sectionNum == 2)
01543      ok = sectionJ->setParameter (&argv[2], argc-2, info);
01544  
01545  if (ok < 0)
01546      return -1;
01547  else if (ok < 100)
01548      return sectionNum*100 + ok;
01549  else 
01550      return -1;
01551     }
01552     
01553     // Unknown parameter
01554     else
01555  return -1;
01556 } 
01557 
01558 int
01559 BeamWithHinges3d::updateParameter (int parameterID, Information &info)
01560 {
01561     switch (parameterID) {
01562       case 1:
01563  this->E = info.theDouble;
01564  return 0;
01565       case 2:
01566  this->G = info.theDouble;
01567  return 0;
01568       case 3:
01569  this->A = info.theDouble;
01570  return 0;
01571       case 4:
01572  this->Iz = info.theDouble;
01573  return 0;
01574       case 5:
01575  this->alpha = info.theDouble;
01576  return 0;
01577       default:
01578  if (parameterID >= 100) { // section quantity
01579      int sectionNum = parameterID/100; 
01580      if (sectionNum == 1)
01581   return sectionI->updateParameter (parameterID-100, info);
01582      else if (sectionNum == 2)
01583   return sectionJ->updateParameter (parameterID-2*100, info);
01584      else
01585   return -1;
01586  }
01587  else // unknown
01588      return -1;
01589  } 
01590 } 
Copyright Contact Us