DOF_Group.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.13 $
00022 // $Date: 2005/11/29 23:31:10 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/analysis/dof_grp/DOF_Group.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/analysis/dof_grp/DOF_Group.C
00027 //
00028 // Written: fmk 
00029 // Created: 11/96
00030 // Revision: A
00031 //
00032 // Purpose: This file contains the code for implementing the methods
00033 // of the DOF_Group class interface.
00034 //
00035 // What: "@(#) DOF_Group.C, revA"
00036 
00037 
00038 #include <DOF_Group.h>
00039 #include <stdlib.h>
00040 
00041 #include <Node.h>
00042 #include <Vector.h>
00043 #include <Matrix.h>
00044 #include <TransientIntegrator.h>
00045 
00046 #define MAX_NUM_DOF 256
00047 
00048 
00049 // static variables initialisation
00050 Matrix DOF_Group::errMatrix(1,1);
00051 Vector DOF_Group::errVect(1);
00052 Matrix **DOF_Group::theMatrices; // array of pointers to class wide matrices
00053 Vector **DOF_Group::theVectors;  // array of pointers to class widde vectors
00054 int DOF_Group::numDOFs(0);           // number of objects
00055 
00056 
00057 //  DOF_Group(Node *);
00058 //      construictor that take the corresponding model node.
00059 
00060 DOF_Group::DOF_Group(int tag, Node *node)
00061 :TaggedObject(tag),
00062  unbalance(0), tangent(0), myNode(node), 
00063  myID(node->getNumberDOF()), 
00064  numDOF(node->getNumberDOF())
00065 {
00066     // get number of DOF & verify valid
00067     int numDOF = node->getNumberDOF();
00068     if (numDOF <= 0) {
00069         opserr << "DOF_Group::DOF_Group(Node *) ";
00070         opserr << " node must have at least 1 dof " << *node;
00071         exit(-1);
00072     }   
00073 
00074     // check the ID created is of appropriate size
00075     if (myID.Size() != numDOF) {
00076         opserr << "DOF_Group::DOF_Group(Node *) ";
00077         opserr << " ran out of memory creating ID for node " << *node;
00078         exit(-1);
00079     }
00080 
00081     // initially set all the IDs to be -2
00082     for (int i=0; i<numDOF; i++)
00083         myID(i) = -2;
00084     
00085     // if this is the first DOF_Group we now
00086     // create the arrays used to store pointers to class wide
00087     // matrix and vector objects used to return tangent and residual
00088     if (numDOFs == 0) {
00089         theMatrices = new Matrix *[MAX_NUM_DOF+1];
00090         theVectors  = new Vector *[MAX_NUM_DOF+1];
00091         
00092         if (theMatrices == 0 || theVectors == 0) {
00093             opserr << "DOF_Group::DOF_Group(Node *) ";
00094             opserr << " ran out of memory";         
00095         }
00096         for (int i=0; i<MAX_NUM_DOF; i++) {
00097             theMatrices[i] = 0;
00098             theVectors[i] = 0;
00099         }
00100     }    
00101     
00102     // set the pointers for the tangent and residual
00103     if (numDOF <= MAX_NUM_DOF) {
00104         // use class wide objects
00105         if (theVectors[numDOF] == 0) {
00106             // have to create matrix and vector of size as none yet created
00107             theVectors[numDOF] = new Vector(numDOF);
00108             theMatrices[numDOF] = new Matrix(numDOF,numDOF);
00109             unbalance = theVectors[numDOF];
00110             tangent = theMatrices[numDOF];
00111             if (unbalance == 0 || unbalance->Size() != numDOF ||        
00112                 tangent == 0 || tangent->noCols() != numDOF)    {  
00113                 opserr << "DOF_Group::DOF_Group(Node *) ";
00114                 opserr << " ran out of memory for vector/Matrix of size :";
00115                 opserr << numDOF << endln;
00116                 exit(-1);
00117             }
00118         } else {
00119             unbalance = theVectors[numDOF];
00120             tangent = theMatrices[numDOF];
00121         }
00122     } else {
00123         // create matrices and vectors for each object instance
00124         unbalance = new Vector(numDOF);
00125         tangent = new Matrix(numDOF, numDOF);
00126         if (unbalance == 0 || unbalance->Size() ==0 ||
00127             tangent ==0 || tangent->noRows() ==0) {
00128             
00129             opserr << "DOF_Group::DOF_Group(Node *) ";
00130             opserr << " ran out of memory for vector/Matrix of size :";
00131             opserr << numDOF << endln;
00132             exit(-1);
00133         }
00134     }
00135     
00136     numDOFs++;
00137 }
00138 
00139 
00140 DOF_Group::DOF_Group(int tag, int ndof)
00141 :TaggedObject(tag),
00142  unbalance(0), tangent(0), myNode(0), 
00143  myID(ndof), 
00144  numDOF(ndof)
00145 {
00146     // get number of DOF & verify valid
00147     int numDOF = ndof;
00148     if (numDOF <= 0) {
00149         opserr << "DOF_Group::DOF_Group(int, int ndof) ";
00150         opserr << ndof << " ndof specified, there must be at least 1\n";
00151         exit(-1);
00152     }   
00153 
00154     // check the ID created is of appropriate size
00155     if (myID.Size() != numDOF) {
00156         opserr << "DOF_Group::DOF_Group(int, int ndof) ";
00157         opserr << " ran out of memory creating ID of size " << ndof << endln;
00158         exit(-1);
00159     }
00160 
00161     // initially set all the IDs to be -2
00162     for (int i=0; i<numDOF; i++)
00163         myID(i) = -2;
00164     
00165     // if this is the first DOF_Group we now
00166     // create the arrays used to store pointers to class wide
00167     // matrix and vector objects used to return tangent and residual
00168     if (numDOFs == 0) {
00169         theMatrices = new Matrix *[MAX_NUM_DOF+1];
00170         theVectors  = new Vector *[MAX_NUM_DOF+1];
00171         
00172         if (theMatrices == 0 || theVectors == 0) {
00173             opserr << "DOF_Group::DOF_Group(int, int ndof) ";
00174             opserr << " ran out of memory";         
00175         }
00176         for (int i=0; i<MAX_NUM_DOF; i++) {
00177             theMatrices[i] = 0;
00178             theVectors[i] = 0;
00179         }
00180     }    
00181 
00182     // set the pointers for the tangent and residual
00183     if (numDOF <= MAX_NUM_DOF) {
00184         // use class wide objects
00185         if (theVectors[numDOF] == 0) {
00186             // have to create matrix and vector of size as none yet created
00187             theVectors[numDOF] = new Vector(numDOF);
00188             theMatrices[numDOF] = new Matrix(numDOF,numDOF);
00189             unbalance = theVectors[numDOF];
00190             tangent = theMatrices[numDOF];
00191             if (unbalance == 0 || unbalance->Size() != numDOF ||        
00192                 tangent == 0 || tangent->noCols() != numDOF)    {  
00193                 opserr << "DOF_Group::DOF_Group(int, int ndof) ";
00194                 opserr << " ran out of memory for vector/Matrix of size :";
00195                 opserr << numDOF << endln;
00196                 exit(-1);
00197             }
00198         } else {
00199             unbalance = theVectors[numDOF];
00200             tangent = theMatrices[numDOF];
00201         }
00202     } else {
00203         // create matrices and vectors for each object instance
00204         unbalance = new Vector(numDOF);
00205         tangent = new Matrix(numDOF, numDOF);
00206         if (unbalance == 0 || tangent ==0 ||
00207             tangent ==0 || tangent->noRows() ==0) {
00208             
00209             opserr << "DOF_Group::DOF_Group(int, int ndof) ";
00210             opserr << " ran out of memory for vector/Matrix of size :";
00211             opserr << numDOF << endln;
00212             exit(-1);
00213         }
00214     }
00215     
00216     numDOFs++;
00217 }
00218 
00219 // ~DOF_Group();    
00220 //      destructor.
00221 
00222 DOF_Group::~DOF_Group()
00223 {
00224     numDOFs--;
00225 
00226     int numDOF = unbalance->Size();
00227 
00228     // set the pointer in the associated Node to 0, to stop
00229     // segmentation fault if node tries to use this object after destroyed
00230     if (myNode != 0) 
00231       myNode->setDOF_GroupPtr(0);
00232 
00233     // delete tangent and residual if created specially
00234     if (numDOF > MAX_NUM_DOF) {
00235         if (tangent != 0) delete tangent;
00236         if (unbalance != 0) delete unbalance;
00237     }
00238 
00239     // if this is the last FE_Element, clean up the
00240     // storage for the matrix and vector objects
00241     if (numDOFs == 0) {
00242         for (int i=0; i<MAX_NUM_DOF; i++) {
00243             if (theVectors[i] != 0)
00244                 delete theVectors[i];
00245             if (theMatrices[i] != 0)
00246                 delete theMatrices[i];
00247         }       
00248         delete [] theMatrices;
00249         delete [] theVectors;
00250     }    
00251 }    
00252 
00253 // void setID(int index, int value);
00254 //      Method to set the corresponding index of the ID to value.
00255 
00256 void
00257 DOF_Group::setID(int index, int value)
00258 {
00259     if ((index >= 0) && (index < numDOF))
00260         myID(index) = value;
00261     else {
00262         opserr << "WARNING DOF_Group::setID - invalid location ";
00263         opserr << index << " in ID of size " << numDOF << endln;
00264     }   
00265 }
00266 
00267 // void setID(const ID &);
00268 //      Method to set the ID to be same as that given.
00269 
00270 void
00271 DOF_Group::setID(const ID &copy)
00272 {
00273     myID = copy;
00274 }
00275  
00276 
00277 // const ID &getID(void) const;
00278 //      Method to return the current ID.
00279 
00280 const ID &
00281 DOF_Group::getID(void) const
00282 {
00283     return myID;
00284 }
00285 
00286 
00287 
00288 int
00289 DOF_Group::getNumDOF(void) const
00290 {
00291     return numDOF;
00292 }
00293 
00294 int
00295 DOF_Group::getNodeTag(void) const
00296 {
00297     if (myNode != 0)
00298         return myNode->getTag();
00299     else
00300         return -1;
00301 }
00302 
00303 int
00304 DOF_Group::getNumFreeDOF(void) const
00305 {
00306     int numFreeDOF = numDOF;
00307     for (int i=0; i<numDOF; i++)
00308         if (myID(i) == -1)
00309             numFreeDOF--;
00310     
00311     return numFreeDOF;
00312 }
00313 
00314 int
00315 DOF_Group::getNumConstrainedDOF(void) const
00316 {   
00317     int numConstr = 0;
00318     for (int i=0; i<numDOF; i++)
00319         if (myID(i) < 0)
00320             numConstr++;    
00321 
00322     return numConstr;
00323 }    
00324 
00325 
00326 
00327 const Matrix &
00328 DOF_Group::getTangent(Integrator *theIntegrator) 
00329 {       
00330     if (theIntegrator != 0)
00331         theIntegrator->formNodTangent(this);    
00332     return *tangent;
00333 }
00334 
00335 void  
00336 DOF_Group::zeroTangent(void)
00337 {
00338     tangent->Zero();
00339 }
00340 
00341 
00342 void  
00343 DOF_Group::addMtoTang(double fact)
00344 {
00345     if (myNode != 0) {
00346         if (tangent->addMatrix(1.0, myNode->getMass(), fact) < 0) {
00347             opserr << "DOF_Group::addMtoTang(void) ";
00348             opserr << " invoking addMatrix() on the tangent failed\n";      
00349         }
00350     }
00351     else {
00352         opserr << "DOF_Group::addMtoTang(void) - no Node associated";
00353         opserr << " subclass should provide the method \n";         
00354     }   
00355 }
00356 
00357 
00358 void  
00359 DOF_Group::addCtoTang(double fact)
00360 {
00361     if (myNode != 0) {
00362         if (tangent->addMatrix(1.0, myNode->getDamp(), fact) < 0) {
00363             opserr << "DOF_Group::addMtoTang(void) ";
00364             opserr << " invoking addMatrix() on the tangent failed\n";      
00365         }
00366     }
00367     else {
00368         opserr << "DOF_Group::addMtoTang(void) - no Node associated";
00369         opserr << " subclass should provide the method \n";         
00370     }   
00371 }
00372 
00373 
00374 
00375 void
00376 DOF_Group::zeroUnbalance(void) 
00377 {
00378     unbalance->Zero();
00379 }
00380 
00381 
00382 const Vector &
00383 DOF_Group::getUnbalance(Integrator *theIntegrator)
00384 {
00385     if (theIntegrator != 0)
00386         theIntegrator->formNodUnbalance(this);
00387 
00388     return *unbalance;
00389 }
00390 
00391 
00392 void
00393 DOF_Group::addPtoUnbalance(double fact)
00394 {
00395     if (myNode != 0) {
00396         if (unbalance->addVector(1.0, myNode->getUnbalancedLoad(), fact) < 0) {
00397             opserr << "DOF_Group::addPIncInertiaToUnbalance() -";
00398             opserr << " invoking addVector() on the unbalance failed\n";            
00399         }
00400     }
00401     else {
00402         opserr << "DOF_Group::addPtoUnbalance() - no Node associated";
00403         opserr << " subclass should provide the method \n";         
00404     }           
00405 }
00406 
00407 
00408 void
00409 DOF_Group::addPIncInertiaToUnbalance(double fact)
00410 {
00411     if (myNode != 0) {
00412         if (unbalance->addVector(1.0, myNode->getUnbalancedLoadIncInertia(), 
00413                                  fact) < 0) {
00414 
00415             opserr << "DOF_Group::addPIncInertiaToUnbalance() - ";
00416             opserr << " invoking addVector() on the unbalance failed\n";            
00417         }
00418     }
00419      else {
00420         opserr << "DOF_Group::addPIncInertiaToUnbalance() - no Node associated";
00421         opserr << " subclass should provide the method \n";         
00422     }           
00423 }
00424 
00425 
00426 void  
00427 DOF_Group::addM_Force(const Vector &Udotdot, double fact)
00428 {
00429     if (myNode == 0) {
00430         opserr << "DOF_Group::addM_Force() - no Node associated";       
00431         opserr << " subclass should not call this method \n";       
00432         return;
00433     }
00434 
00435     Vector accel(numDOF);
00436     // get accel for the unconstrained dof
00437     for (int i=0; i<numDOF; i++) {
00438         int loc = myID(i);
00439         if (loc >= 0)
00440             accel(i) = Udotdot(loc); 
00441         else accel(i) = 0.0;
00442     }
00443         
00444     if (unbalance->addMatrixVector(1.0, myNode->getMass(), accel, fact) < 0) {  
00445         opserr << "DOF_Group::addM_Force() ";
00446         opserr << " invoking addMatrixVector() on the unbalance failed\n";
00447     }
00448     else {
00449 
00450     }           
00451 }
00452 
00453 
00454 
00455 const Vector &
00456 DOF_Group::getTangForce(const Vector &Udotdot, double fact)
00457 {
00458   opserr << "DOF_Group::getTangForce() - not yet implemented";
00459   return *unbalance;
00460 }
00461 
00462 
00463 const Vector &
00464 DOF_Group::getM_Force(const Vector &Udotdot, double fact)
00465 {
00466     if (myNode == 0) {
00467         opserr << "DOF_Group::getM_Force() - no Node associated";       
00468         opserr << " subclass should not call this method \n";       
00469         return *unbalance;
00470     }
00471 
00472     Vector accel(numDOF);
00473     // get accel for the unconstrained dof
00474     for (int i=0; i<numDOF; i++) {
00475         int loc = myID(i);
00476         if (loc >= 0)
00477             accel(i) = Udotdot(loc); 
00478         else accel(i) = 0.0;
00479     }
00480         
00481     if (unbalance->addMatrixVector(0.0, myNode->getMass(), accel, fact) < 0) {  
00482         opserr << "DOF_Group::getM_Force() ";
00483         opserr << " invoking addMatrixVector() on the unbalance failed\n";
00484     }
00485     
00486     return *unbalance;
00487 }
00488 
00489 
00490 
00491 const Vector &
00492 DOF_Group::getC_Force(const Vector &Udotdot, double fact)
00493 {
00494     if (myNode == 0) {
00495         opserr << "DOF_Group::getC_Force() - no Node associated";       
00496         opserr << " subclass should not call this method \n";       
00497         return *unbalance;
00498     }
00499 
00500     Vector accel(numDOF);
00501     // get accel for the unconstrained dof
00502     for (int i=0; i<numDOF; i++) {
00503         int loc = myID(i);
00504         if (loc >= 0)
00505             accel(i) = Udotdot(loc); 
00506         else accel(i) = 0.0;
00507     }
00508         
00509     if (unbalance->addMatrixVector(0.0, myNode->getDamp(), accel, fact) < 0) {  
00510         opserr << "DOF_Group::getC_Force() ";
00511         opserr << " invoking addMatrixVector() on the unbalance failed\n";
00512     }
00513     return *unbalance;
00514 }
00515 
00516 
00517 const Vector & 
00518 DOF_Group::getCommittedDisp(void)
00519 {
00520     if (myNode == 0) {
00521         opserr << "DOF_Group::getCommittedDisp: no associated Node ";
00522         opserr << " returning the error Vector\n";
00523         return errVect;
00524     }
00525     return myNode->getDisp();
00526 }
00527 
00528 
00529 const Vector & 
00530 DOF_Group::getCommittedVel(void)
00531 {
00532     if (myNode == 0) {
00533         opserr << "DOF_Group::getCommittedVel: no associated Node ";
00534         opserr << " returning the error Vector\n";
00535         return errVect; 
00536     }
00537     return myNode->getVel();
00538 }
00539 
00540 
00541 const Vector & 
00542 DOF_Group::getCommittedAccel(void)
00543 {
00544     if (myNode == 0) {
00545         opserr << "DOF_Group::getCommittedAccel: no associated Node ";
00546         opserr << " returning the error Vector\n";
00547         return errVect; 
00548     }
00549     return myNode->getAccel();
00550 }
00551 
00552 // void setNodeDisp(const Vector &u);
00553 //      Method to set the corresponding nodes displacements to the
00554 //      values in u, components identified by myID;
00555 
00556 void
00557 DOF_Group::setNodeDisp(const Vector &u)
00558 {
00559     if (myNode == 0) {
00560         opserr << "DOF_Group::setNodeDisp: no associated Node\n";
00561         return;
00562     }
00563     
00564     Vector &disp = *unbalance;
00565     disp = myNode->getTrialDisp();
00566     int i;
00567     
00568     // get disp for my dof out of vector u
00569     for (i=0; i<numDOF; i++) {
00570         int loc = myID(i);
00571         if (loc >= 0)
00572             disp(i) = u(loc);  
00573     }
00574 
00575     myNode->setTrialDisp(disp);
00576 }
00577         
00578         
00579 // void setNodeVel(const Vector &udot);
00580 //      Method to set the corresponding nodes velocities to the
00581 //      values in udot, components identified by myID;
00582 
00583 void
00584 DOF_Group::setNodeVel(const Vector &udot)
00585 {
00586 
00587     if (myNode == 0) {
00588         opserr << "DOF_Group::setNodeVel: 0 Node Pointer\n";
00589         return;
00590     }
00591     
00592     Vector &vel = *unbalance;
00593     vel = myNode->getTrialVel();
00594     int i;
00595     
00596     // get vel for my dof out of vector udot
00597     for (i=0; i<numDOF; i++) {
00598         int loc = myID(i);              
00599         if (loc >= 0) 
00600             vel(i) = udot(loc);  
00601     }
00602 
00603     myNode->setTrialVel(vel);
00604 
00605 }
00606 
00607 
00608 
00609 // void setNodeAccel(const Vector &udotdot);
00610 //      Method to set the corresponding nodes accelerations to the
00611 //      values in udotdot, components identified by myID;
00612 
00613 void
00614 DOF_Group::setNodeAccel(const Vector &udotdot)
00615 {
00616 
00617     if (myNode == 0) {
00618         opserr << "DOF_Group::setNodeAccel: 0 Node Pointer\n";
00619         return;
00620     }
00621 
00622     Vector &accel = *unbalance;;
00623     accel = myNode->getTrialAccel();
00624     int i;
00625     
00626     // get disp for the unconstrained dof
00627     for (i=0; i<numDOF; i++) {
00628         int loc = myID(i);                      
00629         if (loc >= 0)
00630             accel(i) = udotdot(loc); 
00631     }
00632 
00633     myNode->setTrialAccel(accel);
00634 }
00635 
00636 
00637 // void setNodeIncrDisp(const Vector &u);
00638 //      Method to set the corresponding nodes displacements to the
00639 //      values in u, components identified by myID;
00640 
00641 void
00642 DOF_Group::incrNodeDisp(const Vector &u)
00643 {
00644     if (myNode == 0) {
00645         opserr << "DOF_Group::setNodeDisp: 0 Node Pointer\n";
00646         exit(-1);
00647     }
00648 
00649     Vector &disp = *unbalance;;
00650 
00651     if (disp.Size() == 0) {
00652       opserr << "DOF_Group::setNodeIncrDisp - out of space\n";
00653       return;
00654     }
00655     int i;
00656 
00657     // get disp for my dof out of vector u
00658     for (i=0; i<numDOF; i++) {
00659         int loc = myID(i);                              
00660         if (loc >= 0)
00661             disp(i) = u(loc);  
00662         else disp(i) = 0.0;  
00663     }
00664 
00665     myNode->incrTrialDisp(disp);
00666 }
00667         
00668         
00669 // void setNodeincrVel(const Vector &udot);
00670 //      Method to set the corresponding nodes velocities to the
00671 //      values in udot, components identified by myID;
00672 
00673 void
00674 DOF_Group::incrNodeVel(const Vector &udot)
00675 {
00676 
00677     if (myNode == 0) {
00678         opserr << "DOF_Group::setNodeVel: 0 Node Pointer\n";
00679         exit(-1);
00680     }
00681     
00682     Vector &vel = *unbalance;
00683     int i;
00684     
00685     // get vel for my dof out of vector udot
00686     for (i=0; i<numDOF; i++) {
00687         int loc = myID(i);
00688         if (loc >= 0)
00689             vel(i) = udot(loc);  // -1 for dof labelled 1 through ndof
00690         else  vel(i) = 0.0;
00691     }
00692     myNode->incrTrialVel(vel);
00693 }
00694 
00695 
00696 
00697 // void setNodeIncrAccel(const Vector &udotdot);
00698 //      Method to set the corresponding nodes accelerations to the
00699 //      values in udotdot, components identified by myID;
00700 
00701 void
00702 DOF_Group::incrNodeAccel(const Vector &udotdot)
00703 {
00704 
00705     if (myNode == 0) {
00706         opserr << "DOF_Group::setNodeAccel: 0 Node Pointer\n";
00707         exit(-1);
00708     }
00709 
00710     Vector &accel = *unbalance;
00711     int i;
00712     
00713     // get disp for the unconstrained dof
00714     for (i=0; i<numDOF; i++) {
00715         int loc = myID(i);
00716         if (loc >= 0)
00717             accel(i) = udotdot(loc); 
00718         else accel(i) = 0.0;
00719     }    
00720     myNode->incrTrialAccel(accel);
00721 }
00722 
00723 
00724 
00725 void
00726 DOF_Group::setEigenvector(int mode, const Vector &theVector)
00727 {
00728 
00729     if (myNode == 0) {
00730         opserr << "DOF_Group::setNodeAccel: 0 Node Pointer\n";
00731         exit(-1);
00732     }
00733 
00734     Vector &eigenvector = *unbalance;
00735     int i;
00736     
00737     // get disp for the unconstrained dof
00738     for (i=0; i<numDOF; i++) {
00739         int loc = myID(i);
00740         if (loc >= 0)
00741             eigenvector(i) = theVector(loc); 
00742         else eigenvector(i) = 0.0;
00743     }    
00744     myNode->setEigenvector(mode, eigenvector);
00745 }
00746 
00747 
00748 Matrix *
00749 DOF_Group::getT(void)
00750 {
00751     return 0;
00752 }
00753 
00754 
00755 
00756 void  
00757 DOF_Group::addLocalM_Force(const Vector &accel, double fact)
00758 {
00759     if (myNode != 0) {
00760         if (unbalance->addMatrixVector(1.0, myNode->getMass(), accel, fact) < 0) {  
00761                                        
00762             opserr << "DOF_Group::addLocalM_Force() ";
00763             opserr << " invoking addMatrixVector() on the unbalance failed\n"; 
00764         }
00765     }
00766     else {
00767         opserr << "DOF_Group::addM_Force() - no Node associated";
00768         opserr << " subclass should not call this method \n";       
00769     }           
00770 }
00771 
00772 
00773 // AddingSensitivity:BEGIN ////////////////////////////////////////
00774 const Vector &
00775 DOF_Group::getDispSensitivity(int gradNumber)
00776 {
00777     Vector &result = *unbalance;
00778         for (int i=0; i<numDOF; i++) {
00779                 result(i) = myNode->getDispSensitivity(i+1,gradNumber);
00780         }
00781         return result;
00782 }
00783         
00784 const Vector &
00785 DOF_Group::getVelSensitivity(int gradNumber)
00786 {
00787     Vector &result = *unbalance;
00788         for (int i=0; i<numDOF; i++) {
00789                 result(i) = myNode->getVelSensitivity(i+1,gradNumber);
00790         }
00791         return result;
00792 }
00793         
00794 const Vector &
00795 DOF_Group::getAccSensitivity(int gradNumber)
00796 {
00797     Vector &result = *unbalance;
00798         for (int i=0; i<numDOF; i++) {
00799                 result(i) = myNode->getAccSensitivity(i+1,gradNumber);
00800         }
00801         return result;
00802 }
00803         
00804         
00805 
00806 int 
00807 DOF_Group::saveSensitivity(Vector *v,Vector *vdot,Vector *vdotdot,int gradNum,int numGrads)
00808 {
00809         // Initial declarations
00810         int i;
00811 
00812 
00813     // Get sensitivities for my dof out of vectors
00814     Vector *myV = 0;
00815         Vector *myVdot = 0;
00816         Vector *myVdotdot = 0;
00817 
00818 
00819         // Displacement sensitivities
00820         myV = new Vector(numDOF);
00821     for (i=0; i<numDOF; i++) {
00822                 int loc = myID(i);                              
00823                 if (loc >= 0) {
00824                         (*myV)(i) = (*v)(loc);  
00825                 }
00826                 else {
00827                         (*myV)(i) = 0.0;  
00828                 }
00829     }
00830 
00831 
00832         // Vel and Acc sensitivities only if they are being delivered
00833         if ( (vdot != 0) && (vdotdot != 0) ) {
00834                 myVdot = new Vector(numDOF);
00835                 for (i=0; i<numDOF; i++) {
00836                         int loc = myID(i);                              
00837                         if (loc >= 0) {
00838                                 (*myVdot)(i) = (*vdot)(loc);  
00839                         }
00840                         else {
00841                                 (*myVdot)(i) = 0.0;  
00842                         }
00843                 }
00844                 myVdotdot = new Vector(numDOF);
00845                 for (i=0; i<numDOF; i++) {
00846                         int loc = myID(i);                              
00847                         if (loc >= 0) {
00848                                 (*myVdotdot)(i) = (*vdotdot)(loc);  
00849                         }
00850                         else {
00851                                 (*myVdotdot)(i) = 0.0;  
00852                         }
00853                 }
00854         }
00855 
00856     myNode->saveSensitivity(myV, myVdot, myVdotdot, gradNum, numGrads);
00857 
00858         delete myV;
00859         delete myVdot;
00860         delete myVdotdot;
00861 
00862         return 0;
00863 }
00864 
00865 void  
00866 DOF_Group::addM_ForceSensitivity(const Vector &Udotdot, double fact)
00867 {
00868     if (myNode == 0) {
00869         opserr << "DOF_Group::addM_Force() - no Node associated";       
00870         opserr << " subclass should not call this method \n";       
00871         return;
00872     }
00873 
00874     Vector accel(numDOF);
00875     // get accel for the unconstrained dof
00876     for (int i=0; i<numDOF; i++) {
00877         int loc = myID(i);
00878         if (loc >= 0)
00879             accel(i) = Udotdot(loc); 
00880         else accel(i) = 0.0;
00881     }
00882         
00883     if (unbalance->addMatrixVector(1.0, myNode->getMassSensitivity(), accel, fact) < 0) {  
00884         opserr << "DOF_Group::addM_Force() ";
00885         opserr << " invoking addMatrixVector() on the unbalance failed\n";
00886     }
00887     else {
00888 
00889     }           
00890 }
00891 
00892 void
00893 DOF_Group::addD_Force(const Vector &Udot, double fact)
00894 {
00895     if (myNode == 0) {
00896         opserr << "DOF_Group::addD_Force() - no Node associated";
00897         opserr << " subclass should not call this method \n";
00898         return;
00899     }
00900 
00901     Vector vel(numDOF);
00902     // get velocity for the unconstrained dof
00903     for (int i=0; i<numDOF; i++) {
00904         int loc = myID(i);
00905         if (loc >= 0)
00906             vel(i) = Udot(loc);
00907         else vel(i) = 0.0;
00908     }
00909 
00910     if (unbalance->addMatrixVector(1.0, myNode->getDamp(), vel, fact) < 0) {
00911         opserr << "DOF_Group::addD_Force() ";
00912         opserr << " invoking addMatrixVector() on the unbalance failed\n";
00913     }
00914     else {
00915 
00916     }
00917 }
00918 
00919 void
00920 DOF_Group::addD_ForceSensitivity(const Vector &Udot, double fact)
00921 {
00922     if (myNode == 0) {
00923         opserr << "DOF_Group::addD_ForceSensitivity() - no Node associated";
00924         opserr << " subclass should not call this method \n";
00925         return;
00926     }
00927 
00928     Vector vel(numDOF);
00929     // get velocity for the unconstrained dof
00930     for (int i=0; i<numDOF; i++) {
00931         int loc = myID(i);
00932         if (loc >= 0)
00933             vel(i) = Udot(loc);
00934         else vel(i) = 0.0;
00935     }
00936 
00937     if (unbalance->addMatrixVector(1.0, myNode->getDampSensitivity(), vel, fact) < 0) {
00938         opserr << "DOF_Group::addD_ForceSensitivity() ";
00939         opserr << " invoking addMatrixVector() on the unbalance failed\n";
00940     }
00941     else {
00942 
00943     }
00944 }
00945 
00946 // AddingSensitivity:END //////////////////////////////////////////
00947 void
00948 DOF_Group::resetNodePtr(void)
00949 {
00950   myNode = 0;
00951 }
00952 
00953 

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