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

NLBeamColumn3d.cpp

Go to the documentation of this file.
00001 
00002 /* ****************************************************************** **
00003 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00004 **          Pacific Earthquake Engineering Research Center            **
00005 **                                                                    **
00006 **                                                                    **
00007 ** (C) Copyright 1999, The Regents of the University of California    **
00008 ** All Rights Reserved.                                               **
00009 **                                                                    **
00010 ** Commercial use of this program without express permission of the   **
00011 ** University of California, Berkeley, is strictly prohibited.  See   **
00012 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00013 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00014 **                                                                    **
00015 ** Developed by:                                                      **
00016 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00017 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00018 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00019 **                                                                    **
00020 ** ****************************************************************** */
00021                                                                         
00022 // $Revision: 1.7 $
00023 // $Date: 2001/07/12 21:54:57 $
00024 // $Source: /usr/local/cvs/OpenSees/SRC/element/nonlinearBeamColumn/element/NLBeamColumn3d.cpp,v $
00025                                                                         
00026                                                                         
00027 // File: ~/element/NLBeamColumn3d.C
00028 //
00029 // Written: Remo Magalhaes de Souza (rmsouza.ce.berkeley.edu) on 03/99 
00030 // Revised: rms 06/99 (mass matrix)
00031 //          rms 07/99 (using setDomain)
00032 //          rms 08/99 (included P-Delta effect)
00033 //     fmk 10/99 setResponse() & getResponse()
00034 //          rms 11/99 (included rigid joint offsets)
00035 //          rms 04/00 (using transformation class w/ linear or corotational transf)
00036 //          rms 04/00 (generalized to iterative/non-iterative algorithm)
00037 //          mhs 06/00 (using new section class w/ variable dimensions)
00038 //          rms 06/00 (torsional stiffness considered at the section level)
00039 //          rms 06/00 (making copy of the sections)
00040 //          rms 06/00 (storing section history variables at the element level)
00041 //          rms 07/00 (new state determination procedure, no need to store fscommit) 
00042 //
00043 // Purpose: This file contains the implementation for the NLBeamColumn3d class.
00044 //          NLBeamColumn3d is a materially nonlinear flexibility based frame element.
00045 
00046 #include <math.h>
00047 #include <stdlib.h>
00048 #include <string.h>
00049 #include <float.h>
00050 #include <iomanip.h>
00051 
00052 #include <Information.h>
00053 #include <NLBeamColumn3d.h>
00054 #include <MatrixUtil.h>
00055 #include <GaussQuadRule1d01.h>
00056 #include <GaussLobattoQuadRule1d01.h>
00057 #include <Domain.h>
00058 #include <Channel.h>
00059 #include <FEM_ObjectBroker.h>
00060 #include <Renderer.h>
00061 #include <G3Globals.h>
00062 #include <ElementResponse.h>
00063 
00064 #define  NDM   3         // dimension of the problem (3d)
00065 #define  NL    3         // size of uniform load vector
00066 #define  NND   6         // number of nodal dof's
00067 #define  NEGD 12         // number of element global dof's
00068 #define  NEBD  6         // number of element dof's in the basic system
00069 
00070 // constructor:
00071 // invoked by a FEM_ObjectBroker, recvSelf() needs to be invoked on this object.
00072 NLBeamColumn3d::NLBeamColumn3d():
00073 
00074 Element(0,ELE_TAG_NLBeamColumn3d), connectedExternalNodes(2), 
00075 nSections(0), sections(0), crdTransf(0), node1Ptr(0), node2Ptr(0),
00076 rho(0), maxIters(0), tol(0), initialFlag(0), prevDistrLoad(NL),
00077 K(NEGD,NEGD), m(NEGD,NEGD), d(NEGD,NEGD), P(NEGD), Pinert(NEGD), load(NEGD), Uepr(NEGD),
00078 kv(NEBD,NEBD), Se(NEBD), 
00079 distrLoadcommit(NL), Uecommit(NEGD), kvcommit(NEBD,NEBD), Secommit(NEBD), b(0), bp(0),
00080 fs(0), vs(0), Ssr(0), vscommit(0), isTorsion(false)
00081 {
00082 
00083 }
00084 
00085 // constructor which takes the unique element tag, sections,
00086 // and the node ID's of it's nodal end points. 
00087 // allocates the necessary space needed by each object
00088 NLBeamColumn3d::NLBeamColumn3d (int tag, int nodeI, int nodeJ, 
00089                                 int numSections, SectionForceDeformation *sectionPtrs[],
00090                                 CrdTransf3d &coordTransf, double massDensPerUnitLength,
00091                                 int maxNumIters, double tolerance):
00092 
00093 Element(tag,ELE_TAG_NLBeamColumn3d), connectedExternalNodes(2), 
00094 nSections(numSections), node1Ptr(0), node2Ptr(0),
00095 rho(massDensPerUnitLength), maxIters(maxNumIters), tol(tolerance), 
00096 initialFlag(0), prevDistrLoad(NL), 
00097 K(NEGD,NEGD), m(NEGD,NEGD), d(NEGD,NEGD), P(NEGD), Pinert(NEGD), load(NEGD), 
00098 Uepr(NEGD), kv(NEBD,NEBD), Se(NEBD),  
00099 distrLoadcommit(NL), Uecommit(NEGD), kvcommit(NEBD,NEBD), Secommit(NEBD), b(0), bp(0),
00100 fs(0), vs(0), Ssr(0), vscommit(0), isTorsion(false)
00101 {
00102    connectedExternalNodes(0) = nodeI;
00103    connectedExternalNodes(1) = nodeJ;    
00104 
00105    // get copy of the sections
00106    
00107    if (!sectionPtrs)
00108    {
00109        cerr << "Error: NLBeamColumn3d::NLBeamColumn3d:  invalid section pointer ";
00110        exit(-1);
00111    }   
00112    
00113    sections = new SectionForceDeformation *[nSections];
00114    if (!sections)
00115    {
00116        cerr << "Error: NLBeamColumn3d::NLBeamColumn3d: could not alocate section pointer";
00117        exit(-1);
00118    }  
00119    
00120    for (int i = 0; i < nSections; i++)
00121    {
00122       if (!sectionPtrs[i])
00123       {
00124    cerr << "Error: NLBeamColumn3d::NLBeamColumn3d: section pointer " << i << endl;
00125           exit(-1);
00126       }  
00127        
00128       sections[i] = sectionPtrs[i]->getCopy();
00129       if (!sections[i])
00130       {
00131    cerr << "Error: NLBeamColumn3d::NLBeamColumn3d: could not create copy of section " << i << endl;
00132           exit(-1);
00133       }
00134 
00135    int order = sections[i]->getOrder();
00136    const ID &code = sections[i]->getType();
00137    for (int j = 0; j < order; j++) {
00138   if (code(j) == SECTION_RESPONSE_T)
00139    isTorsion = true;
00140    }
00141    }
00142 
00143    if (!isTorsion)
00144     g3ErrorHandler->warning("%s -- no torsion detected in sections, %s",
00145    "NLBeamColumn3d::NLBeamColumn3d",
00146    "continuing with element torsional stiffness of 1.0e10");
00147 
00148    // get copy of the transformation object   
00149    crdTransf = coordTransf.getCopy(); 
00150    if (!crdTransf)
00151    {
00152       cerr << "Error: NLBeamColumn3d::NLBeamColumn3d: could not create copy of coordinate transformation object" << endl;
00153       exit(-1);
00154    }
00155 
00156    // alocate force interpolation matrices
00157    
00158    b  = new Matrix [nSections];
00159    if (!b)
00160    {
00161        cerr << "NLBeamColumn3d::NLBeamColumn3d() -- failed to allocate b array";
00162        exit(-1);
00163    }
00164    
00165    bp = new Matrix [nSections];
00166    if (!bp)
00167    {
00168        cerr << "NLBeamColumn3d::NLBeamColumn3d() -- failed to allocate bp array";
00169        exit(-1);
00170    }
00171 
00172    // alocate section flexibility matrices and section deformation vectors
00173    fs  = new Matrix [nSections];
00174    if (!fs)
00175    {
00176        cerr << "NLBeamColumn3d::NLBeamColumn3d() -- failed to allocate fs array";
00177        exit(-1);
00178    }
00179    
00180    vs = new Vector [nSections];
00181    if (!vs)
00182    {
00183        cerr << "NLBeamColumn3d::NLBeamColumn3d() -- failed to allocate vs array";
00184        exit(-1);
00185    }
00186 
00187    Ssr = new Vector [nSections];
00188    if (!Ssr)
00189    {
00190        cerr << "NLBeamColumn3d::NLBeamColumn3d() -- failed to allocate Ssr array";
00191        exit(-1);
00192    }
00193  
00194    vscommit = new Vector [nSections];
00195    if (!vscommit)
00196    {
00197        cerr << "NLBeamColumn3d::NLBeamColumn3d() -- failed to allocate vscommit array";   
00198        exit(-1);
00199    }
00200 }
00201 
00202 
00203 // ~NLBeamColumn3d():
00204 //  destructor
00205 //      delete must be invoked on any objects created by the object
00206 NLBeamColumn3d::~NLBeamColumn3d()
00207 {
00208    int i;
00209    
00210    if (sections)
00211    {
00212       for (i=0; i < nSections; i++)
00213          if (sections[i])
00214             delete sections[i];
00215       delete [] sections;
00216    }  
00217    
00218    if (b)
00219      delete [] b;
00220 
00221    if (bp)
00222      delete [] bp;
00223 
00224    if (fs) 
00225      delete [] fs;
00226 
00227    if (vs) 
00228      delete [] vs;
00229 
00230    if (Ssr) 
00231      delete [] Ssr;
00232 
00233    if (vscommit) 
00234      delete [] vscommit;
00235 
00236    if (crdTransf)
00237      delete crdTransf;   
00238 }
00239 
00240 
00241 
00242 int
00243 NLBeamColumn3d::getNumExternalNodes(void) const
00244 {
00245    return connectedExternalNodes.Size();
00246 }
00247 
00248 
00249 const ID &
00250 NLBeamColumn3d::getExternalNodes(void)
00251 {
00252    return connectedExternalNodes;
00253 }
00254 
00255 
00256 int
00257 NLBeamColumn3d::getNumDOF(void) 
00258 {
00259    return NEGD;
00260 }
00261 
00262 void
00263 NLBeamColumn3d::setDomain(Domain *theDomain)
00264 {
00265    // check Domain is not null - invoked when object removed from a domain
00266    if (theDomain == 0) {
00267       node1Ptr = 0;
00268       node2Ptr = 0;
00269    return;
00270    }
00271 
00272    // get pointers to the nodes
00273    
00274    int Nd1 = connectedExternalNodes(0);  
00275    int Nd2 = connectedExternalNodes(1);
00276    
00277    node1Ptr = theDomain->getNode(Nd1);
00278    node2Ptr = theDomain->getNode(Nd2);  
00279 
00280    if (node1Ptr == 0)
00281    {
00282       cerr << "NLBeamColumn3d::setDomain: Nd1: ";
00283       cerr << Nd1 << "does not exist in model\n";
00284       exit(0);
00285    }
00286 
00287    if (node2Ptr == 0) 
00288    {
00289       cerr << "NLBeamColumn3d::setDomain: Nd2: ";
00290       cerr << Nd2 << "does not exist in model\n";
00291       exit(0);
00292    }
00293 
00294    // call the DomainComponent class method 
00295    this->DomainComponent::setDomain(theDomain);
00296     
00297    // ensure connected nodes have correct number of dof's
00298    int dofNode1 = node1Ptr->getNumberDOF();
00299    int dofNode2 = node2Ptr->getNumberDOF();
00300    
00301    if ((dofNode1 !=NND ) || (dofNode2 != NND))
00302    {
00303       cerr << "NLBeamColumn3d::setDomain(): Nd2 or Nd1 incorrect dof ";
00304       exit(0);
00305    }
00306    
00307 
00308    // initialize the transformation
00309    if (crdTransf->initialize(node1Ptr, node2Ptr))
00310    {
00311       cerr << "NLBeamColumn3d::setDomain(): Error initializing coordinate transformation";  
00312       exit(0);
00313    }
00314     
00315    // get element length
00316    L = crdTransf->getInitialLength();
00317    if (L == 0)
00318    {
00319       cerr << "NLBeamColumn3d::setDomain(): Zero element length:" << this->getTag();  
00320       exit(0);
00321    }
00322    this->initializeSectionHistoryVariables();
00323    this->setSectionInterpolation();
00324 
00325    if (initialFlag == 2) {
00326      static Vector currDistrLoad(NL);
00327      currDistrLoad.Zero();  // SPECIFY LOAD HERE!!!!!!!!! 
00328      crdTransf->update();
00329      P = crdTransf->getGlobalResistingForce(Se, currDistrLoad);
00330      K = crdTransf->getGlobalStiffMatrix(kv, Se);
00331    } else
00332      this->update();
00333 }
00334 
00335 
00336 int
00337 NLBeamColumn3d::commitState()
00338 {
00339    int err = 0;
00340    int i = 0;
00341 
00342    do
00343    {
00344       vscommit[i] = vs[i];
00345       err = sections[i++]->commitState();  
00346    } while (err == 0 && i < nSections);
00347    
00348    if (err)
00349       return err;
00350    
00351    // commit the transformation between coord. systems
00352    if (err = crdTransf->commitState())
00353       return err;
00354       
00355    // commit the element variables state
00356 
00357    distrLoadcommit = prevDistrLoad;
00358    Uecommit = Uepr;
00359    kvcommit = kv;
00360    Secommit = Se;
00361 
00362    return err;
00363 }
00364 
00365 
00366 int 
00367 NLBeamColumn3d::revertToLastCommit()
00368 {
00369    int err;
00370    int i = 0;
00371       
00372    do
00373    {
00374       vs[i] = vscommit[i];
00375       err = sections[i]->revertToLastCommit();
00376       
00377       Ssr[i] = sections[i]->getStressResultant();
00378       fs[i]  = sections[i]->getSectionFlexibility();
00379       
00380       i++;
00381    } while (err == 0 && i < nSections);
00382    
00383        
00384    if (err)
00385       return err;
00386    
00387    // revert the transformation to last commit
00388    if (err = crdTransf->revertToLastCommit())
00389       return err;
00390      
00391    // revert the element state to last commit
00392    prevDistrLoad = distrLoadcommit;
00393    Uepr = Uecommit;
00394    Se   = Secommit;
00395    kv   = kvcommit;
00396    
00397    // compute global resisting forces and tangent
00398    static Vector currDistrLoad(NL);
00399    currDistrLoad.Zero();  // SPECIFY LOAD HERE!!!!!!!!! 
00400    P = crdTransf->getGlobalResistingForce(Se, currDistrLoad);
00401    K = crdTransf->getGlobalStiffMatrix(kv, Se);
00402    
00403    initialFlag = 0;
00404    this->update();
00405 
00406    return err;
00407 }
00408 
00409 
00410 int 
00411 NLBeamColumn3d::revertToStart()
00412 {
00413    // revert the sections state to start
00414    int err;
00415    int i = 0;
00416      
00417    do
00418    {
00419       fs[i].Zero();
00420       vs[i].Zero();
00421       Ssr[i].Zero();
00422       err = sections[i++]->revertToStart();
00423  
00424    } while (err == 0 && i < nSections);
00425 
00426    if (err)
00427       return err;
00428    
00429    // revert the transformation to start
00430    if (err = crdTransf->revertToStart())
00431       return err;
00432   
00433    // revert the element state to start
00434    prevDistrLoad.Zero();
00435    Uepr.Zero();
00436    Se.Zero();
00437    kv.Zero();
00438 
00439    P.Zero();
00440    K.Zero();
00441 
00442    initialFlag = 0;
00443    this->update();
00444    
00445    return err;
00446 }
00447 
00448 
00449 
00450 const Matrix &
00451 NLBeamColumn3d::getTangentStiff(void)
00452 {
00453    return K;
00454 }
00455     
00456 
00457 const Vector &
00458 NLBeamColumn3d::getResistingForce(void)
00459 {
00460    return P;
00461 }
00462 
00463 
00464 void
00465 NLBeamColumn3d::initializeSectionHistoryVariables (void)
00466 {
00467     for (int i = 0; i < nSections; i++)
00468     {
00469  int order = sections[i]->getOrder();
00470  
00471  fs[i] = Matrix(order,order);
00472  vs[i] = Vector(order);
00473         Ssr[i] = Vector(order);
00474  
00475  vscommit[i] = Vector(order);
00476     }
00477 }
00478 
00479 
00480 
00481 void
00482 NLBeamColumn3d::setSectionInterpolation (void)
00483 {
00484     GaussLobattoQuadRule1d01 quadrat(nSections);
00485     Matrix xi_pt = quadrat.getIntegrPointCoords();   
00486 
00487     for (int i = 0; i < nSections; i++)
00488     {
00489  int order = sections[i]->getOrder();
00490  const ID &code = sections[i]->getType();
00491  
00492  b[i] = Matrix(order,NEBD);
00493  this->getForceInterpolatMatrix(xi_pt(i,0), b[i], code);
00494 
00495  bp[i] = Matrix(order,NL);
00496  this->getDistrLoadInterpolatMatrix(xi_pt(i,0), bp[i], code);
00497     }
00498 }
00499 
00500 
00501 
00502 int 
00503 NLBeamColumn3d::update(void)
00504 {
00505   // get element global end displacements
00506   static Vector Ue(NEGD);
00507   this->getGlobalDispls(Ue);
00508  
00509   // compute global end displacement increments
00510   static Vector dUe(NEGD);
00511   // dUe = Ue - Uepr
00512   dUe = Ue;
00513   dUe.addVector(1.0, Uepr,-1.0);
00514   
00515   if (dUe.Norm() != 0.0  || initialFlag == 0) 
00516   {
00517     // compute distributed loads and increments
00518     static Vector currDistrLoad(NL);
00519     static Vector distrLoadIncr(NL); 
00520 
00521     currDistrLoad.Zero();  // SPECIFY LOAD HERE!!!!!!!!! 
00522     distrLoadIncr = currDistrLoad - prevDistrLoad;
00523     prevDistrLoad = currDistrLoad;
00524 
00525     // update the end displacements
00526     Uepr = Ue;
00527 
00528     // update the transformation
00529     crdTransf->update();
00530        
00531     // get basic displacements and increments
00532     static Vector v(NEBD);
00533     static Vector dv(NEBD);
00534      
00535     v = crdTransf->getBasicTrialDisp();    
00536     dv = crdTransf->getBasicIncrDeltaDisp();    
00537 
00538     // get integration point positions and weights
00539     int nIntegrPts = nSections;
00540     // GaussQuadRule1d01 quadrat(nIntegrPts);
00541     GaussLobattoQuadRule1d01 quadrat(nIntegrPts);
00542     // const Matrix &xi_pt = quadrat.getIntegrPointCoords();
00543     const Vector &weight = quadrat.getIntegrPointWeights();
00544      
00545     // numerical integration 
00546     static Vector dSs;       // section internal force increments
00547     static Vector Ss;        // section "applied" forces (in equilibrium with end forces)
00548     static Vector dvs;       // section residual deformations
00549     
00550     static Vector vr(NEBD);       // element residual displacements
00551     static Matrix f(NEBD,NEBD);   // element flexibility matrix
00552 
00553     static Matrix I(NEBD,NEBD);   // an identity matrix for matrix inverse
00554     double dW;                    // section strain energy (work) norm 
00555     int i;
00556     
00557     I.Zero();
00558     for (i=0; i<NEBD; i++)
00559       I(i,i) = 1.0;
00560 
00561     // calculate nodal force increments and update nodal forces
00562     static Vector dSe(NEBD);
00563 
00564     // dSe = kv * dv;
00565     dSe.addMatrixVector(0.0, kv, dv, 1.0);
00566 
00567     for (int j=0; j < maxIters; j++)
00568     {
00569       Se += dSe;
00570   
00571       // initialize f and vr for integration
00572       f.Zero();
00573       vr.Zero();
00574 
00575       for (i=0; i<nIntegrPts; i++)
00576       {
00577    
00578           // initialize vectors with correct size  - CHANGE LATER
00579    Ss  = Ssr[i];
00580    dSs = vs[i];
00581           dvs = vs[i];    
00582    
00583    // calculate total section forces
00584    // Ss = b*Se + bp*currDistrLoad;
00585    Ss.addMatrixVector(0.0, b[i], Se, 1.0);
00586    Ss.addMatrixVector(1.0, bp[i], currDistrLoad, 1.0);
00587 
00588    dSs = Ss;
00589    dSs.addVector(1.0, Ssr[i], -1.0);  // dSs = Ss - Ssr[i];
00590  
00591    // compute section deformation increments and update current deformations
00592    //       vs += fs * dSs;     
00593    
00594    dvs.addMatrixVector(0.0, fs[i], dSs, 1.0);
00595    
00596    vs[i] += dvs;
00597    
00598    sections[i]->setTrialSectionDeformation(vs[i]);
00599    
00600    // get section resisting forces
00601    Ssr[i] = sections[i]->getStressResultant();
00602    
00603    // get section flexibility matrix
00604           fs[i] = sections[i]->getSectionFlexibility();
00605    
00606    // calculate section residual deformations
00607    // dvs = fs * (Ss - Ssr);
00608    
00609    dSs = Ss;
00610    dSs.addVector(1.0, Ssr[i], -1.0);  // dSs = Ss - Ssr[i];
00611             
00612    dvs.addMatrixVector(0.0, fs[i], dSs, 1.0);
00613        
00614           // integrate element flexibility matrix
00615    // f = f + (b^ fs * b) * weight(i);
00616          f.addMatrixTripleProduct(1.0, b[i], fs[i], weight(i));
00617 
00618    // integrate residual deformations
00619    // vr += (b^ (vs + dvs)) * weight(i);
00620    vr.addMatrixTransposeVector(1.0, b[i], vs[i] + dvs, weight(i));
00621       }  
00622       
00623       f  *= L;
00624       vr *= L;
00625 
00626    if (!isTorsion)
00627     f(5,5) = 1.0e-10;
00628 
00629       // calculate element stiffness matrix
00630       // invertMatrix(5, f, kv);
00631  if (f.Solve(I,kv) < 0)
00632   g3ErrorHandler->warning("NLBeamColumn3d::updateElementState() - could not invert flexibility\n");
00633 
00634       dv = v - vr;
00635       
00636       // dSe = kv * dv;
00637       dSe.addMatrixVector(0.0, kv, dv, 1.0);
00638       
00639       dW = dv^ dSe;
00640       if (fabs(dW) < tol)
00641         break;
00642     }     
00643       
00644     // determine resisting forces
00645     Se += dSe;
00646 
00647     // get resisting forces and stiffness matrix in global coordinates
00648     P = crdTransf->getGlobalResistingForce(Se, currDistrLoad);
00649     K = crdTransf->getGlobalStiffMatrix(kv, Se);
00650 
00651     initialFlag = 1;
00652 
00653     return 1;
00654   }
00655   
00656   else
00657     return 0;
00658 }
00659 
00660 
00661 
00662 void NLBeamColumn3d::getGlobalDispls(Vector &dg) const
00663 {
00664    // determine global displacements
00665    const Vector &disp1 = node1Ptr->getTrialDisp();
00666    const Vector &disp2 = node2Ptr->getTrialDisp();
00667 
00668    for (int i = 0; i < NND; i++)
00669    {
00670       dg(i)     = disp1(i);
00671       dg(i+NND) = disp2(i);
00672    }
00673 }
00674 
00675 
00676 
00677 void NLBeamColumn3d::getGlobalAccels(Vector &ag) const
00678 {
00679    // determine global displacements
00680    const Vector &accel1 = node1Ptr->getTrialAccel();
00681    const Vector &accel2 = node2Ptr->getTrialAccel();
00682 
00683    for (int i = 0; i < NND; i++)
00684    {
00685       ag(i)     = accel1(i);
00686       ag(i+NND) = accel2(i);
00687    }
00688 }
00689 
00690 
00691 void NLBeamColumn3d::getForceInterpolatMatrix(double xi, Matrix &b, const ID &code)
00692 {
00693    b.Zero();
00694     
00695    for (int i = 0; i < code.Size(); i++)
00696    {
00697       switch (code(i))
00698       {
00699          case SECTION_RESPONSE_MZ:  // Moment, Mz, interpolation
00700             b(i,1) = xi - 1.0;
00701      b(i,2) = xi;
00702      break;
00703   case SECTION_RESPONSE_P:  // Axial, P, interpolation
00704      b(i,0) = 1.0;
00705      break;
00706   case SECTION_RESPONSE_VY:  // Shear, Vy, interpolation
00707      b(i,1) = 1.0/L;
00708      b(i,2) = 1.0/L;
00709      break;
00710   case SECTION_RESPONSE_MY:  // Moment, My, interpolation
00711      b(i,3) = xi - 1.0;
00712      b(i,4) = xi;
00713      break;
00714   case SECTION_RESPONSE_VZ:  // Shear, Vz, interpolation
00715      b(i,3) = 1.0/L;
00716      b(i,4) = 1.0/L;
00717      break;
00718   case SECTION_RESPONSE_T:  // Torque, T, interpolation
00719      b(i,5) = 1.0;
00720      break;
00721   default:
00722      break;
00723       } 
00724    }
00725 }
00726 
00727 
00728 void NLBeamColumn3d::getDistrLoadInterpolatMatrix(double xi, Matrix &bp, const ID &code)
00729 {
00730    bp.Zero();
00731 
00732    for (int i = 0; i < code.Size(); i++)
00733    {
00734       switch (code(i))
00735       {
00736   case SECTION_RESPONSE_MZ:  // Moment, Mz, interpolation
00737      bp(i,1) = xi*(xi-1)*L*L/2;
00738      break;
00739   case SECTION_RESPONSE_P:  // Axial, P, interpolation
00740      bp(i,0) = (1-xi)*L;
00741      break;
00742   case SECTION_RESPONSE_VY:  // Shear, Vy, interpolation
00743      bp(i,1) = (xi-0.5)*L;
00744      break;
00745   case SECTION_RESPONSE_MY:  // Moment, My, interpolation
00746      bp(i,2) = xi*(1-xi)*L*L/2;
00747      break;
00748   case SECTION_RESPONSE_VZ:  // Shear, Vz, interpolation
00749      bp(i,2) = (0.5-xi)*L;
00750      break;
00751   case SECTION_RESPONSE_T:  // Torsion, T, interpolation
00752      break;
00753   default:
00754      break;
00755       }
00756    }
00757 }
00758 
00759 
00760 const Matrix &
00761 NLBeamColumn3d::getSecantStiff(void)
00762 {
00763     return this->getTangentStiff();
00764 }
00765 
00766     
00767 const Matrix &
00768 NLBeamColumn3d::getDamp(void)
00769 {
00770     return d;  // zero matrix still 
00771 }
00772 
00773 
00774 const Matrix &
00775 NLBeamColumn3d::getMass(void)
00776 { 
00777     m(0,0) = m(1,1) = m(2,2) =
00778     m(6,6) = m(7,7) = m(8,8) = rho * L/2;
00779   
00780     return m;
00781 }
00782 
00783 
00784 void 
00785 NLBeamColumn3d::zeroLoad(void)
00786 {
00787     load.Zero();
00788 }
00789 
00790 int
00791 NLBeamColumn3d::addLoad(const Vector &moreLoad)
00792 {
00793     if (moreLoad.Size() != NEGD) 
00794     {
00795  cerr << "NLBeamColumn3d::addLoad: vector not of correct size\n";
00796  return -1;
00797     }
00798     load += moreLoad;
00799     return 0;
00800 }
00801 
00802 
00803 const Vector &
00804 NLBeamColumn3d::getResistingForceIncInertia()
00805 { 
00806     static Vector f(NEGD);
00807     static Vector ag(NEGD);
00808     
00809     f = this->getResistingForce();
00810     this->getMass();
00811     this->getGlobalAccels(ag);
00812     
00813     // Pinert = f + m * ag;
00814     Pinert = f;
00815     Pinert.addMatrixVector(1.0, m, ag, 1.0);
00816    
00817     return Pinert;
00818 }
00819 
00820 
00821 
00822 
00823 bool
00824 NLBeamColumn3d::isSubdomain(void)
00825 {
00826     return false;
00827 }
00828 
00829 int
00830 NLBeamColumn3d::sendSelf(int commitTag, Channel &theChannel)
00831 {
00832   // place the integer data into an ID
00833 
00834   int dbTag = this->getDbTag();
00835   int i, j , k;
00836   int loc = 0;
00837   
00838   static ID idData(9);
00839   idData(0) = this->getTag();
00840   idData(1) = connectedExternalNodes(0);
00841   idData(2) = connectedExternalNodes(1);
00842   idData(3) = nSections;
00843   idData(4) = maxIters;
00844   idData(5) = initialFlag;
00845   idData(6) = crdTransf->getClassTag();
00846   int crdTransfDbTag  = crdTransf->getDbTag();
00847   if (crdTransfDbTag  == 0) {
00848       crdTransfDbTag = theChannel.getDbTag();
00849       if (crdTransfDbTag  != 0) {
00850     crdTransf->setDbTag(crdTransfDbTag);
00851        }
00852   }
00853   idData(7) = crdTransfDbTag;
00854   idData(8) = (isTorsion) ? 1 : 0;
00855   
00856 
00857   if (theChannel.sendID(dbTag, commitTag, idData) < 0)  
00858   {
00859      g3ErrorHandler->warning("NLBeamColumn3d::sendSelf() - %s\n",
00860              "failed to send ID data");
00861      return -1;
00862   }    
00863   
00864   if (crdTransf->sendSelf(commitTag, theChannel) < 0)  
00865   {
00866      g3ErrorHandler->warning("NLBeamColumn3d::sendSelf() - %s\n",
00867              "failed to send crdTranf");
00868      return -1;
00869   }      
00870 
00871   
00872   //
00873   // send an ID for the sections containing each sections dbTag and classTag
00874   // if section ha no dbTag get one and assign it
00875   //
00876 
00877   ID idSections(2*nSections);
00878   loc = 0;
00879   for (i = 0; i<nSections; i++) 
00880   {
00881     int sectClassTag = sections[i]->getClassTag();
00882     int sectDbTag = sections[i]->getDbTag();
00883     if (sectDbTag == 0) 
00884     {
00885       sectDbTag = theChannel.getDbTag();
00886       sections[i]->setDbTag(sectDbTag);
00887     }
00888 
00889     idSections(loc) = sectClassTag;
00890     idSections(loc+1) = sectDbTag;
00891     loc += 2;
00892   }
00893 
00894   if (theChannel.sendID(dbTag, commitTag, idSections) < 0)  {
00895     g3ErrorHandler->warning("NLBeamColumn3d::sendSelf() - %s\n",
00896        "failed to send ID data");
00897     return -1;
00898   }    
00899 
00900   //
00901   // send the sections
00902   //
00903   
00904   for (j = 0; j<nSections; j++) {
00905     if (sections[j]->sendSelf(commitTag, theChannel) < 0) {
00906       g3ErrorHandler->warning("NLBeamColumn3d::sendSelf() - section %d %s\n",
00907          j,"failed to send itself");
00908       return -1;
00909     }
00910   }
00911   
00912   // into a vector place distrLoadCommit, rho, UeCommit, Secommit and kvcommit
00913   int secDefSize = 0;
00914   for (i = 0; i < nSections; i++)
00915   {
00916      int size = sections[i]->getOrder();
00917      secDefSize   += size;
00918   }
00919 
00920   
00921   
00922   static Vector dData(1+1+NL+NEGD+NEBD+NEBD*NEBD+secDefSize); 
00923   loc = 0;
00924 
00925   // place double variables into Vector
00926   dData(loc++) = rho;
00927   dData(loc++) = tol;
00928   
00929   // put  distrLoadCommit into the Vector
00930   for (i=0; i<NL; i++) 
00931   {
00932     dData(loc) = distrLoadcommit(i);
00933     loc++;
00934   }
00935 
00936   // place UeCommit into Vector
00937   for (i=0; i<NEGD; i++)
00938     dData(loc++) = Uecommit(i);
00939 
00940   // place kvcommit into vector
00941   for (i=0; i<NEBD; i++) 
00942     dData(loc++) = Secommit(i);
00943 
00944   // place kvcommit into vector
00945   for (i=0; i<NEBD; i++) 
00946      for (j=0; j<NEBD; j++)
00947         dData(loc++) = kvcommit(i,j);
00948   
00949   // place vscommit into vector
00950   for (k=0; k<nSections; k++)
00951      for (i=0; i<sections[k]->getOrder(); i++)
00952  dData(loc++) = (vscommit[k])(i);
00953 
00954   
00955   if (theChannel.sendVector(dbTag, commitTag, dData) < 0)  
00956   {
00957      g3ErrorHandler->warning("NLBeamColumn3d::sendSelf() - %s\n",
00958          "failed to send Vector data");
00959      return -1;
00960   }    
00961 
00962 
00963   return 0;
00964 }
00965 
00966 
00967 int
00968 NLBeamColumn3d::recvSelf(int commitTag, Channel &theChannel, FEM_ObjectBroker &theBroker)
00969 {
00970    //
00971   // into an ID of size 9 place the integer data
00972   //
00973   int dbTag = this->getDbTag();
00974   int i,j,k;
00975   
00976 
00977   static ID idData(9);
00978 
00979   if (theChannel.recvID(dbTag, commitTag, idData) < 0)  {
00980     g3ErrorHandler->warning("NLBeamColumn3d::recvSelf() - %s\n",
00981        "failed to recv ID data");
00982     return -1;
00983   }    
00984 
00985   this->setTag(idData(0));
00986   connectedExternalNodes(0) = idData(1);
00987   connectedExternalNodes(1) = idData(2);
00988   maxIters = idData(4);
00989   initialFlag = idData(5);
00990   isTorsion = (idData(8) == 1) ? true : false;
00991   
00992   int crdTransfClassTag = idData(6);
00993   int crdTransfDbTag = idData(7);
00994 
00995   // create a new crdTransf object if one needed
00996   if (crdTransf == 0 || crdTransf->getClassTag() != crdTransfClassTag) {
00997       if (crdTransf != 0)
00998    delete crdTransf;
00999       crdTransf = theBroker.getNewCrdTransf3d(crdTransfClassTag);
01000       if (crdTransf == 0) {
01001    g3ErrorHandler->warning("NLBeamColumn3d::recvSelf() - %s %d\n",
01002       "failed to obtain a CrdTrans object with classTag",
01003       crdTransfClassTag);
01004    return -2;   
01005       }
01006   }
01007   crdTransf->setDbTag(crdTransfDbTag);
01008   
01009   // invoke recvSelf on the crdTransf obkject
01010   if (crdTransf->recvSelf(commitTag, theChannel, theBroker) < 0)  
01011   {
01012      g3ErrorHandler->warning("NLBeamColumn3d::sendSelf() - %s\n",
01013              "failed to recv crdTranf");
01014      return -3;
01015   }      
01016 
01017   
01018   
01019   //
01020   // recv an ID for the sections containing each sections dbTag and classTag
01021   //
01022 
01023   ID idSections(2*idData(3));
01024   int loc = 0;
01025 
01026   if (theChannel.recvID(dbTag, commitTag, idSections) < 0)  {
01027     g3ErrorHandler->warning("NLBeamColumn3d::recvSelf() - %s\n",
01028        "failed to recv ID data");
01029     return -1;
01030   }    
01031 
01032   //
01033   // now receive the sections
01034   //
01035 
01036   
01037   if (nSections != idData(3)) {
01038     //
01039     // we do not have correct number of sections, must delete the old and create
01040     // new ones before can recvSelf on the sections
01041     //
01042 
01043     // delete the old
01044     if (nSections != 0) {
01045       for (int i=0; i<nSections; i++)
01046  delete sections[i];
01047       delete [] sections;
01048     }
01049 
01050     // create a new array to hold pointers
01051     sections = new SectionForceDeformation *[idData(3)];
01052     if (sections == 0) {
01053       g3ErrorHandler->fatal("NLBeamColumn3d::recvSelf() - %s %d\n",
01054          "out of memory creating sections array of size",idData(3));
01055       return -1;
01056     }    
01057 
01058     // create a section and recvSelf on it
01059     nSections = idData(3);
01060     loc = 0;
01061     
01062     for (i=0; i<nSections; i++) {
01063       int sectClassTag = idSections(loc);
01064       int sectDbTag = idSections(loc+1);
01065       loc += 2;
01066       sections[i] = theBroker.getNewSection(sectClassTag);
01067       if (sections[i] == 0) {
01068  g3ErrorHandler->fatal("NLBeamColumn3d::recvSelf() - %s %d\n",
01069          "Broker could not create Section of class type",sectClassTag);
01070  return -1;
01071       }
01072       sections[i]->setDbTag(sectDbTag);
01073       if (sections[i]->recvSelf(commitTag, theChannel, theBroker) < 0) {
01074  g3ErrorHandler->warning("NLBeamColumn3d::recvSelf() - section %d %s\n",
01075     i,"failed to recv itself");
01076  return -1;
01077       }     
01078     }
01079   } else {
01080 
01081     // 
01082     // for each existing section, check it is of correct type
01083     // (if not delete old & create a new one) then recvSelf on it
01084     //
01085     
01086     loc = 0;
01087     for (i=0; i<nSections; i++) {
01088       int sectClassTag = idSections(loc);
01089       int sectDbTag = idSections(loc+1);
01090       loc += 2;
01091 
01092       // check of correct type
01093       if (sections[i]->getClassTag() !=  sectClassTag) {
01094  // delete the old section[i] and create a new one
01095  delete sections[i];
01096  sections[i] = theBroker.getNewSection(sectClassTag);
01097  if (sections[i] == 0) {
01098    g3ErrorHandler->fatal("NLBeamColumn3d::recvSelf() - %s %d\n",
01099     "Broker could not create Section of class type",sectClassTag);
01100    return -1;
01101  }
01102       }
01103 
01104       // recvvSelf on it
01105       sections[i]->setDbTag(sectDbTag);
01106       if (sections[i]->recvSelf(commitTag, theChannel, theBroker) < 0) {
01107  g3ErrorHandler->warning("NLBeamColumn3d::recvSelf() - section %d %s\n",
01108     i,"failed to recv itself");
01109  return -1;
01110       }     
01111     }
01112   }
01113   
01114   
01115   
01116   // into a vector place distrLoadCommit, rho, UeCommit, Secommit and kvcommit
01117   int secDefSize = 0;
01118   for (int ii = 0; ii < nSections; ii++)
01119   {
01120      int size = sections[ii]->getOrder();
01121      secDefSize   += size;
01122   }
01123   
01124   Vector dData(1+1+NL+NEGD+NEBD+NEBD*NEBD+secDefSize);   
01125   
01126   if (theChannel.recvVector(dbTag, commitTag, dData) < 0)  {
01127     g3ErrorHandler->warning("NLBeamColumn3d::sendSelf() - %s\n",
01128        "failed to send Vector data");
01129     return -1;
01130   }    
01131   
01132   loc = 0;
01133   
01134   // place double variables into Vector
01135   rho = dData(loc++);
01136   tol = dData(loc++);
01137   
01138   // put  distrLoadCommit into the Vector
01139   for (i=0; i<NL; i++) 
01140     distrLoadcommit(i) = dData(loc++);
01141 
01142   // place UeCommit into Vector
01143   for (i=0; i<NEGD; i++)
01144     Uecommit(i) = dData(loc++);
01145 
01146   // place kvcommit into vector
01147   for (i=0; i<NEBD; i++) 
01148     Secommit(i) = dData(loc++);
01149 
01150   // place kvcommit into vector
01151   for (i=0; i<NEBD; i++) 
01152      for (j=0; j<NEBD; j++)
01153         kvcommit(i,j) = dData(loc++);
01154 
01155  prevDistrLoad = distrLoadcommit;
01156  Uepr = Uecommit;
01157  kv   = kvcommit;
01158  Se   = Secommit;
01159 
01160  // Delete the old
01161  if (vscommit != 0)
01162   delete [] vscommit;
01163 
01164  // Allocate the right number
01165  vscommit = new Vector[nSections];
01166  if (vscommit == 0) {
01167   g3ErrorHandler->warning("%s -- failed to allocate vscommit array",
01168    "NLBeamColumn3d::recvSelf");
01169   return -1;
01170  }
01171 
01172  for (k = 0; k < nSections; k++) {
01173   int order = sections[k]->getOrder();
01174 
01175   // place vscommit into vector
01176   vscommit[k] = Vector(order);
01177   for (i = 0; i < order; i++)
01178    (vscommit[k])(i) = dData(loc++);
01179  }
01180  
01181  // Delete the old
01182  if (fs != 0)
01183   delete [] fs;
01184 
01185  // Allocate the right number
01186  fs = new Matrix[nSections];  
01187  if (fs == 0) {
01188   g3ErrorHandler->warning("%s -- failed to allocate fs array",
01189    "NLBeamColumn3d::recvSelf");
01190   return -1;
01191  }
01192    
01193  // Delete the old
01194  if (vs != 0)
01195   delete [] vs;
01196 
01197  // Allocate the right number
01198  vs = new Vector[nSections];  
01199  if (vs == 0) {
01200   g3ErrorHandler->warning("%s -- failed to allocate vs array",
01201    "NLBeamColumn3d::recvSelf");
01202   return -1;
01203  }
01204  
01205  // Delete the old
01206  if (Ssr != 0)
01207   delete [] Ssr;
01208 
01209  // Allocate the right number
01210  Ssr = new Vector[nSections];  
01211  if (Ssr == 0) {
01212   g3ErrorHandler->warning("%s -- failed to allocate Ssr array",
01213    "NLBeamColumn3d::recvSelf");
01214   return -1;
01215  }
01216 
01217  // Set up section history variables 
01218  this->initializeSectionHistoryVariables();
01219 
01220  // Delete the old
01221  if (b != 0)
01222   delete [] b;
01223 
01224  // Allocate the right number
01225  b = new Matrix[nSections];  
01226  if (b == 0) {
01227   g3ErrorHandler->warning("%s -- failed to allocate b array",
01228    "NLBeamColumn3d::recvSelf");
01229   return -1;
01230  }
01231 
01232  // Delete the old
01233  if (bp != 0)
01234   delete [] bp;
01235 
01236  // Allocate the right number
01237  bp = new Matrix[nSections];  
01238  if (bp == 0) {
01239   g3ErrorHandler->warning("%s -- failed to allocate bp array",
01240    "NLBeamColumn3d::recvSelf");
01241   return -1;
01242  }
01243 
01244  // Set up section force interpolation matrices
01245  this->setSectionInterpolation();
01246 
01247 
01248   if (node1Ptr != 0) {
01249      static Vector currDistrLoad(NL);
01250      currDistrLoad.Zero();  // SPECIFY LOAD HERE!!!!!!!!! 
01251      crdTransf->update();
01252      P = crdTransf->getGlobalResistingForce(Se, currDistrLoad);
01253      K = crdTransf->getGlobalStiffMatrix(kv, Se);
01254   }
01255 
01256   initialFlag = 2;  
01257 
01258   return 0;
01259 }
01260 
01261 
01262 void 
01263 NLBeamColumn3d::compSectionDisplacements(Vector sectionCoords[], Vector sectionDispls[]) const
01264 {
01265    // update the transformation
01266    crdTransf->update();
01267        
01268    // get basic displacements and increments
01269    static Vector ub(NEBD);
01270    ub = crdTransf->getBasicTrialDisp();    
01271   
01272    // get integration point positions and weights
01273    int nIntegrPts = nSections;
01274    GaussLobattoQuadRule1d01 quadrat(nIntegrPts);
01275    const Matrix &xi_pt  = quadrat.getIntegrPointCoords();
01276 
01277    // setup Vandermode and CBDI influence matrices
01278    int i;
01279    double xi;
01280  
01281    // get CBDI influence matrix
01282    Matrix ls(nIntegrPts, nIntegrPts);
01283    getCBDIinfluenceMatrix(nIntegrPts, xi_pt, L, ls);
01284      
01285    // get section curvatures
01286    Vector kappa_y(nIntegrPts);  // curvature
01287    Vector kappa_z(nIntegrPts);  // curvature
01288    static Vector vs;                // section deformations 
01289         
01290    for (i=0; i<nSections; i++)
01291    {
01292        // THIS IS VERY INEFFICIENT ... CAN CHANGE IF RUNS TOO SLOW
01293        int sectionKey1 = 0;
01294        int sectionKey2 = 0;
01295        const ID &code = sections[i]->getType();
01296        int j;
01297        for (j = 0; j < code.Size(); j++)
01298        {
01299     if (code(j) == SECTION_RESPONSE_MZ)
01300         sectionKey1 = j;
01301     if (code(j) == SECTION_RESPONSE_MY)
01302         sectionKey2 = j;
01303        }
01304        if (sectionKey1 == 0)
01305     g3ErrorHandler->fatal("FATAL NLBeamColumn3d::compSectionResponse - section does not provide Mz response\n");
01306        if (sectionKey2 == 0)
01307     g3ErrorHandler->fatal("FATAL NLBeamColumn3d::compSectionResponse - section does not provide My response\n");
01308 
01309        // get section deformations
01310        vs = sections[i]->getSectionDeformation();
01311        
01312        kappa_z(i) = vs(sectionKey1);
01313        kappa_y(i) = vs(sectionKey2); 
01314    }
01315 
01316    //cout << "kappa_y: " << kappa_y;   
01317    //cout << "kappa_z: " << kappa_z;   
01318    
01319    Vector v(nIntegrPts), w(nIntegrPts);
01320    static Vector xl(NDM), uxb(NDM);
01321    static Vector xg(NDM), uxg(NDM); 
01322    // double theta;                             // angle of twist of the sections
01323 
01324    // v = ls * kappa_z;  
01325    v.addMatrixVector (0.0, ls, kappa_z, 1.0);  
01326    // w = ls * kappa_y *  (-1);  
01327    w.addMatrixVector (0.0, ls, kappa_y, -1.0);
01328    
01329    for (i=0; i<nSections; i++)
01330    {
01331       xi = xi_pt(i,0);
01332 
01333       xl(0) = xi * L;
01334       xl(1) = 0;
01335       xl(2) = 0;
01336 
01337       // get section global coordinates
01338       sectionCoords[i] = crdTransf->getPointGlobalCoordFromLocal(xl);
01339 
01340       // compute section displacements
01341       //theta  = xi * ub(5); // consider linear variation for angle of twist. CHANGE LATER!!!!!!!!!!
01342       uxb(0) = xi * ub(0); // consider linear variation for axial displacement. CHANGE LATER!!!!!!!!!!
01343       uxb(1) = v(i);
01344       uxb(2) = w(i);
01345           
01346       // get section displacements in global system 
01347       sectionDispls[i] = crdTransf->getPointGlobalDisplFromBasic(xi, uxb);
01348    }        
01349 }
01350 
01351 
01352 
01353 void
01354 NLBeamColumn3d::Print(ostream &s, int flag)
01355 {
01356    if (flag == 1)
01357    {
01358       s << "\nElement: " << this->getTag() << " Type: NLBeamColumn3d ";
01359       s << "\tConnected Nodes: " << connectedExternalNodes ;
01360       s << "\tNumber of Sections: " << nSections;
01361 
01362 //    for (int i = 0; i < nSections; i++)
01363 //       s << "\nSection "<<i<<" :" << *sections[i];
01364 
01365 //       s << "\nSection "<<0<<" :" << *sections[0];
01366 
01367        s << "\tStiffness Matrix:\n" << kv;
01368        s << "\tResisting Force: " << Se;
01369    }
01370    else
01371    {
01372       s << "\nElement: " << this->getTag() << " Type: NLBeamColumn3d ";
01373       s << "\tConnected Nodes: " << connectedExternalNodes ;
01374       s << "\tNumber of Sections: " << nSections << endl;
01375       s << "\tElement End Forces (P MZ1 MZ2 MY1 MY2 T): " << Secommit;
01376       s << "\tResisting Force: " << P;
01377    }
01378 }
01379 
01380 
01381 ostream &operator<<(ostream &s, NLBeamColumn3d &E)
01382 {
01383     E.Print(s);
01384     return s;
01385 }
01386 
01387 int
01388 NLBeamColumn3d::displaySelf(Renderer &theViewer, int displayMode, float fact)
01389 {
01390    
01391    if (displayMode == 1) 
01392    {
01393        // first determine the two end points of the element based on
01394        //  the display factor (a measure of the distorted image)
01395     
01396        static Vector v1(NDM), v2(NDM);
01397 
01398        const Vector &node1Crd = node1Ptr->getCrds();
01399        const Vector &node2Crd = node2Ptr->getCrds(); 
01400        const Vector &node1Disp = node1Ptr->getDisp();
01401        const Vector &node2Disp = node2Ptr->getDisp();    
01402 
01403        int i;
01404        
01405        // allocate array of vectors to store section coordinates and displacements
01406        
01407        Vector *coords = new Vector [nSections];
01408      
01409        if (!coords)
01410        {
01411     cerr << "NLBeamColumn3d::displaySelf() -- failed to allocate coords array";   
01412     exit(-1);
01413        }
01414        
01415        for (i = 0; i < nSections; i++)
01416    coords[i] = Vector(NDM);
01417        
01418        Vector *displs = new Vector [nSections];
01419      
01420        if (!displs)
01421        {
01422     cerr << "NLBeamColumn3d::displaySelf() -- failed to allocate coords array";   
01423     exit(-1);
01424        }
01425 
01426        for (i = 0; i < nSections; i++)
01427    displs[i] = Vector(NDM);
01428        
01429        int error;
01430        
01431        this->compSectionDisplacements(coords, displs);
01432 
01433        // get global displacements and coordinates of each section          
01434 
01435        v1 = node1Crd + node1Disp*fact;
01436  
01437        // get global displacements and coordinates of each section          
01438 
01439        for (i = 0; i<nSections; i++) 
01440        {
01441           v2 = coords[i] + displs[i]*fact;
01442        
01443           error = theViewer.drawLine(v1, v2, 1.0, 1.0);
01444 
01445           if (error)
01446             return error;
01447           v1 = v2;
01448 
01449        }  
01450        
01451        v2 = node2Crd + node2Disp*fact;
01452        
01453        error = theViewer.drawLine(v1, v2, 1.0, 1.0);
01454 
01455        if (error)
01456    return error;
01457    }
01458    return 0;
01459 }
01460 
01461 Response* 
01462 NLBeamColumn3d::setResponse(char **argv, int argc, Information &eleInformation)
01463 {
01464     //
01465     // we compare argv[0] for known response types 
01466     //
01467 
01468     // global force - 
01469     if (strcmp(argv[0],"forces") == 0 || strcmp(argv[0],"force") == 0
01470  || strcmp(argv[0],"globalForce") == 0 || strcmp(argv[0],"globalForces") == 0)
01471   return new ElementResponse(this, 1, P);
01472 
01473     // local force -
01474     else if (strcmp(argv[0],"localForce") == 0 || strcmp(argv[0],"localForces") == 0)
01475   return new ElementResponse(this, 2, P);
01476 
01477     else if ((strcmp(argv[0],"defoANDforce") == 0) ||
01478       (strcmp(argv[0],"deformationANDforce") == 0) ||
01479       (strcmp(argv[0],"deformationsANDforces") == 0))
01480   return new ElementResponse(this, 4, Vector(24));
01481 
01482     // section response -
01483     else if (strcmp(argv[0],"section") ==0) {
01484   if (argc <= 2)
01485    return 0;
01486  
01487   int sectionNum = atoi(argv[1]);
01488   if (sectionNum > 0 && sectionNum <= nSections)
01489    return sections[sectionNum-1]->setResponse(&argv[2], argc-2, eleInformation);
01490   else
01491    return 0;
01492     }
01493     
01494  else
01495   return 0;
01496 }
01497 
01498 int 
01499 NLBeamColumn3d::getResponse(int responseID, Information &eleInfo)
01500 {
01501   static Vector force(12);
01502   static Vector defoAndForce(24);
01503   double V;
01504   int i;
01505 
01506   switch (responseID) {      
01507     case 1:  // forces
01508   return eleInfo.setVector(P);
01509 
01510     case 4:
01511       for (i = 0; i < 12; i++) {
01512  defoAndForce(i) = Uecommit(i);
01513  defoAndForce(i+12) = P(i);
01514       }
01515       return eleInfo.setVector(defoAndForce);
01516 
01517     case 2:
01518   // Axial
01519   force(6) = Se(0);
01520   force(0) = -Se(0);
01521 
01522   // Torsion
01523   force(11) = Se(5);
01524   force(5)  = -Se(5);
01525 
01526   // Moments about z and shears along y
01527   force(2) = Se(1);
01528   force(8) = Se(2);
01529   V = (Se(1)+Se(2))/L;
01530   force(1) = V;
01531   force(7) = -V;
01532 
01533   // Moments about y and shears along z
01534   force(4)  = Se(3);
01535   force(10) = Se(4);
01536   V = (Se(3)+Se(4))/L;
01537   force(3) = -V;
01538   force(9) = V;
01539 
01540   return eleInfo.setVector(force);
01541 
01542     default: 
01543    return -1;
01544   }
01545 }
01546 
01547 
Copyright Contact Us