FE_Element.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.18 $
00022 // $Date: 2006/02/08 20:20:00 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/analysis/fe_ele/FE_Element.cpp,v $
00024                                                                         
00025                                                                         
00026 // Written: fmk 
00027 // Created: 11/96
00028 // Revision: A
00029 //
00030 // Purpose: This file contains the code for implementing the methods
00031 // of the FE_Element class interface.
00032 
00033 #include <FE_Element.h>
00034 #include <stdlib.h>
00035 
00036 #include <Element.h>
00037 #include <Domain.h>
00038 #include <Node.h>
00039 #include <DOF_Group.h>
00040 #include <Integrator.h>
00041 #include <Subdomain.h>
00042 #include <AnalysisModel.h>
00043 #include <Matrix.h>
00044 #include <Vector.h>
00045 
00046 #define MAX_NUM_DOF 64
00047 
00048 // static variables initialisation
00049 Matrix FE_Element::errMatrix(1,1);
00050 Vector FE_Element::errVector(1);
00051 Matrix **FE_Element::theMatrices; // pointers to class wide matrices
00052 Vector **FE_Element::theVectors;  // pointers to class widde vectors
00053 int FE_Element::numFEs(0);           // number of objects
00054 
00055 //  FE_Element(Element *, Integrator *theIntegrator);
00056 //      construictor that take the corresponding model element.
00057 FE_Element::FE_Element(int tag, Element *ele)
00058   :TaggedObject(tag),
00059    myDOF_Groups((ele->getExternalNodes()).Size()), myID(ele->getNumDOF()), 
00060  numDOF(ele->getNumDOF()), theModel(0), myEle(ele), 
00061  theResidual(0), theTangent(0), theIntegrator(0)
00062 {
00063     if (numDOF <= 0) {
00064         opserr << "FE_Element::FE_Element(Element *) ";
00065         opserr << " element must have 1 dof " << *ele;
00066         exit(-1);
00067     }
00068     
00069     // get elements domain & check it is valid
00070     Domain *theDomain = ele->getDomain();
00071     if (theDomain == 0) {
00072         opserr << "FATAL FE_Element::FE_Element() - element has no domain "<< *ele;
00073         exit(-1);
00074     }
00075 
00076     // keep a pointer to all DOF_Groups
00077     int numGroups = ele->getNumExternalNodes();
00078     const ID &nodes = ele->getExternalNodes();
00079 
00080     for (int i=0; i<numGroups; i++) {
00081         Node *nodePtr =theDomain->getNode(nodes(i));
00082         if (nodePtr == 0) {
00083             opserr << "FATAL FE_Element::FE_Element() - Node: ";
00084             opserr <<  nodes(i) <<  "does not exist in the Domain\n";
00085             opserr << *ele;
00086             exit(-1);
00087         }
00088         
00089         DOF_Group *dofGrpPtr = nodePtr->getDOF_GroupPtr();
00090         if (dofGrpPtr != 0) 
00091             myDOF_Groups(i) = dofGrpPtr->getTag();      
00092         else {
00093             opserr << "FATAL FE_Element::FE_Element() - Node: ";
00094             opserr <<  *nodePtr <<  " has no DOF_Group associated with it\n";
00095             exit(-1);
00096         }
00097     }
00098 
00099     // if this is the first FE_Element we now
00100     // create the arrays used to store pointers to class wide
00101     // matrix and vector objects used to return tangent and residual
00102     if (numFEs == 0) {
00103         theMatrices = new Matrix *[MAX_NUM_DOF+1];
00104         theVectors  = new Vector *[MAX_NUM_DOF+1];
00105         
00106         if (theMatrices == 0 || theVectors == 0) {
00107             opserr << "FE_Element::FE_Element(Element *) ";
00108             opserr << " ran out of memory";         
00109         }
00110         for (int i=0; i<MAX_NUM_DOF; i++) {
00111             theMatrices[i] = 0;
00112             theVectors[i] = 0;
00113         }
00114     }
00115 
00116     if (ele->isSubdomain() == false) {
00117         
00118         // if Elements are not subdomains, set up pointers to
00119         // objects to return tangent Matrix and residual Vector.
00120 
00121         if (numDOF <= MAX_NUM_DOF) {
00122             // use class wide objects
00123             if (theVectors[numDOF] == 0) {
00124                 theVectors[numDOF] = new Vector(numDOF);
00125                 theMatrices[numDOF] = new Matrix(numDOF,numDOF);
00126                 theResidual = theVectors[numDOF];
00127                 theTangent = theMatrices[numDOF];
00128                 if (theResidual == 0 || theResidual->Size() != numDOF ||        
00129                     theTangent == 0 || theTangent->noCols() != numDOF)  {  
00130                     opserr << "FE_Element::FE_Element(Element *) ";
00131                     opserr << " ran out of memory for vector/Matrix of size :";
00132                     opserr << numDOF << endln;
00133                     exit(-1);
00134                 }
00135             } else {
00136                 theResidual = theVectors[numDOF];
00137                 theTangent = theMatrices[numDOF];
00138             }
00139         } else {
00140             // create matrices and vectors for each object instance
00141             theResidual = new Vector(numDOF);
00142             theTangent = new Matrix(numDOF, numDOF);
00143             if (theResidual == 0 || theTangent ==0 ||
00144                 theTangent ==0 || theTangent->noRows() ==0) {
00145             
00146                 opserr << "FE_Element::FE_Element(Element *) ";
00147                 opserr << " ran out of memory for vector/Matrix of size :";
00148                 opserr << numDOF << endln;
00149                 exit(-1);
00150             }
00151         } 
00152     } else {
00153 
00154         // as subdomains have own matrix for tangent and residual don't need
00155         // to set matrix and vector pointers to these objects
00156         theResidual = new Vector(numDOF);       
00157         // invoke setFE_ElementPtr() method on Subdomain
00158         Subdomain *theSub = (Subdomain *)ele;
00159         theSub->setFE_ElementPtr(this);
00160     }
00161  
00162     // increment number of FE_Elements by 1
00163     numFEs++;
00164 }
00165 
00166 
00167 FE_Element::FE_Element(int tag, int numDOF_Group, int ndof)
00168   :TaggedObject(tag),
00169    myDOF_Groups(numDOF_Group), myID(ndof), numDOF(ndof), theModel(0),
00170    myEle(0), theResidual(0), theTangent(0), theIntegrator(0)
00171 {
00172     // this is for a subtype, the subtype must set the myDOF_Groups ID array
00173     numFEs++;
00174 
00175     // if this is the first FE_Element we now
00176     // create the arrays used to store pointers to class wide
00177     // matrix and vector objects used to return tangent and residual
00178     if (numFEs == 0) {
00179         theMatrices = new Matrix *[MAX_NUM_DOF+1];
00180         theVectors  = new Vector *[MAX_NUM_DOF+1];
00181         
00182         if (theMatrices == 0 || theVectors == 0) {
00183             opserr << "FE_Element::FE_Element(Element *) ";
00184             opserr << " ran out of memory";         
00185         }
00186         for (int i=0; i<MAX_NUM_DOF; i++) {
00187             theMatrices[i] = 0;
00188             theVectors[i] = 0;
00189         }
00190     }
00191     
00192     // as subtypes have no access to the tangent or residual we don't set them
00193     // this way we can detect if subclass does not provide all methods it should
00194 }
00195 
00196 
00197 
00198 // ~FE_Element();    
00199 //      destructor.
00200 FE_Element::~FE_Element()
00201 {
00202 
00203     // decrement number of FE_Elements
00204     numFEs--;
00205 
00206     // delete tangent and residual if created specially
00207     if (numDOF > MAX_NUM_DOF) {
00208         if (theTangent != 0) delete theTangent;
00209         if (theResidual != 0) delete theResidual;
00210     }
00211 
00212     // if this is the last FE_Element, clean up the
00213     // storage for the matrix and vector objects
00214     if (numFEs == 0) {
00215         for (int i=0; i<MAX_NUM_DOF; i++) {
00216             if (theVectors[i] != 0)
00217                 delete theVectors[i];
00218             if (theMatrices[i] != 0)
00219                 delete theMatrices[i];
00220         }       
00221         delete [] theMatrices;
00222         delete [] theVectors;
00223     }
00224 }    
00225 
00226 
00227 const ID &
00228 FE_Element::getDOFtags(void) const 
00229 {
00230     return myDOF_Groups;
00231 }
00232 
00233 
00234 // const ID &getID(void) const;
00235 //      Method to return the current ID.
00236 
00237 const ID &
00238 FE_Element::getID(void) const
00239 {
00240     return myID;
00241 }
00242 
00243 void 
00244 FE_Element::setAnalysisModel(AnalysisModel &theAnalysisModel)
00245 {
00246     theModel = &theAnalysisModel;
00247 }
00248 
00249 // void setID(int index, int value);
00250 //      Method to set the corresponding index of the ID to value.
00251 
00252 int
00253 FE_Element::setID(void)
00254 {
00255     int current = 0;
00256     
00257     if (theModel == 0) {
00258         opserr << "WARNING FE_Element::setID() - no AnalysisModel set\n";
00259         return -1;
00260     }
00261     
00262     int numGrps = myDOF_Groups.Size();
00263     for (int i=0; i<numGrps; i++) {
00264         int tag = myDOF_Groups(i);
00265 
00266         DOF_Group *dofPtr = theModel->getDOF_GroupPtr(tag);
00267         if (dofPtr == 0) {
00268             opserr << "WARNING FE_Element::setID: 0 DOF_Group Pointer\n";
00269             return -2;
00270         }
00271             
00272         const ID &theDOFid = dofPtr->getID();
00273 
00274         for (int j=0; j<theDOFid.Size(); j++)  
00275             if (current < numDOF)
00276                 myID(current++) = theDOFid(j);
00277             else {
00278                 opserr << "WARNING FE_Element::setID() - numDOF and";
00279                 opserr << " number of dof at the DOF_Groups\n";
00280                 return -3;
00281             }           
00282     }
00283     return 0;
00284 }
00285 
00286 
00287 const Matrix &
00288 FE_Element::getTangent(Integrator *theNewIntegrator)
00289 {
00290     theIntegrator = theNewIntegrator;
00291     
00292     if (myEle == 0) {
00293         opserr << "FATAL FE_Element::getTangent() - no Element *given ";
00294         opserr << "- subclasses must provide implementation - ";
00295         opserr << " - a 1x1 error matrix will be returned.\n";
00296         exit(-1);
00297     }
00298 
00299     if (myEle->isSubdomain() == false) {
00300       if (theNewIntegrator != 0)
00301         theNewIntegrator->formEleTangent(this);             
00302 
00303       return *theTangent;
00304     } else {
00305       Subdomain *theSub = (Subdomain *)myEle;
00306       theSub->computeTang();        
00307       return theSub->getTang();
00308     }
00309 }
00310 
00311 const Vector &
00312 FE_Element::getResidual(Integrator *theNewIntegrator)
00313 {
00314     theIntegrator = theNewIntegrator;
00315 
00316     if (theIntegrator == 0)
00317       return *theResidual;
00318 
00319     if (myEle == 0) {
00320         opserr << "FATAL FE_Element::getTangent() - no Element *given ";
00321         opserr << "- subclasses must provide implementation - ";
00322         opserr << " - an error Vector of order 1 will be returned.\n";
00323         exit(-1);
00324     }    
00325 
00326     if (myEle->isSubdomain() == false) {
00327       theNewIntegrator->formEleResidual(this);
00328       return *theResidual;
00329     } else {
00330       Subdomain *theSub = (Subdomain *)myEle;
00331       theSub->computeResidual();            
00332       return theSub->getResistingForce();
00333     }
00334 }
00335 
00336 
00337 
00338 void  
00339 FE_Element::zeroTangent(void)
00340 {
00341     if (myEle != 0) {
00342         if (myEle->isSubdomain() == false)
00343             theTangent->Zero();
00344         else {
00345             opserr << "WARNING FE_Element::zeroTangent() - ";
00346             opserr << "- this should not be called on a Subdomain!\n";
00347         }                   
00348     }
00349     else {
00350         opserr << "WARNING FE_Element::zeroTangent() - no Element *given ";
00351         opserr << "- subclasses must provide implementation\n";
00352     }
00353 }
00354 
00355 void  
00356 FE_Element::addKtToTang(double fact)
00357 {
00358     if (myEle != 0) {
00359         
00360         // check for a quick return     
00361         if (fact == 0.0) 
00362             return;
00363         else if (myEle->isSubdomain() == false)     
00364             theTangent->addMatrix(1.0, myEle->getTangentStiff(),fact);
00365         else {
00366             opserr << "WARNING FE_Element::addKToTang() - ";
00367             opserr << "- this should not be called on a Subdomain!\n";
00368         }                   
00369     }
00370     else {
00371         opserr << "WARNING FE_Element::addKToTang() - no Element *given ";
00372         opserr << "- subclasses must provide implementation\n";
00373     }               
00374 }
00375 
00376 void  
00377 FE_Element::addCtoTang(double fact)
00378 {
00379     if (myEle != 0) {
00380         
00381         // check for a quick return     
00382         if (fact == 0.0) 
00383           return;
00384         else if (myEle->isSubdomain() == false)             
00385           theTangent->addMatrix(1.0, myEle->getDamp(),fact);
00386         else {
00387           opserr << "WARNING FE_Element::addCToTang() - ";
00388           opserr << "- this should not be called on a Subdomain!\n";
00389         }                       
00390     }
00391     else {
00392         opserr << "WARNING FE_Element::addCToTang() - no Element *given ";
00393         opserr << "- subclasses must provide implementation\n";
00394     }                   
00395 }
00396     
00397 void  
00398 FE_Element::addMtoTang(double fact)
00399 {
00400     if (myEle != 0) {
00401 
00402         // check for a quick return     
00403         if (fact == 0.0) 
00404           return;
00405         else if (myEle->isSubdomain() == false)             
00406           theTangent->addMatrix(1.0, myEle->getMass(),fact);
00407         else {
00408           opserr << "WARNING FE_Element::addMToTang() - ";
00409           opserr << "- this should not be called on a Subdomain!\n";
00410         }                       
00411     }   
00412     else {
00413         opserr << "WARNING FE_Element::addMToTang() - no Element *given ";
00414         opserr << "- subclasses must provide implementation\n";
00415     }                   
00416 }    
00417 
00418 
00419 void
00420 FE_Element::addKiToTang(double fact)
00421 {
00422   if (myEle != 0) {
00423     // check for a quick return 
00424     if (fact == 0.0) 
00425       return;
00426     else if (myEle->isSubdomain() == false)                 
00427       theTangent->addMatrix(1.0, myEle->getInitialStiff(), fact);
00428     else {
00429         opserr << "WARNING FE_Element::addKiToTang() - ";
00430         opserr << "- this should not be called on a Subdomain!\n";
00431     }                           
00432   }     
00433   else {
00434     opserr << "WARNING FE_Element::addKiToTang() - no Element *given ";
00435     opserr << "- subclasses must provide implementation\n";
00436   }             
00437 }    
00438 
00439 
00440 void  
00441 FE_Element::zeroResidual(void)
00442 {
00443     if (myEle != 0) {
00444         if (myEle->isSubdomain() == false)
00445             theResidual->Zero();
00446         else {
00447             opserr << "WARNING FE_Element::zeroResidual() - ";
00448             opserr << "- this should not be called on a Subdomain!\n";
00449         }                   
00450     }
00451     else {
00452         opserr << "WARNING FE_Element::zeroResidual() - no Element *given ";
00453         opserr << "- subclasses must provide implementation\n";
00454     }    
00455 }
00456 
00457 void  
00458 FE_Element::addRtoResidual(double fact)
00459 {
00460     if (myEle != 0) {
00461         // check for a quick return     
00462         if (fact == 0.0) 
00463             return;
00464         else if (myEle->isSubdomain() == false) {
00465           const Vector &eleResisting = myEle->getResistingForce();
00466           theResidual->addVector(1.0, eleResisting, -fact);
00467         }
00468         else {
00469             opserr << "WARNING FE_Element::addRtoResidual() - ";
00470             opserr << "- this should not be called on a Subdomain!\n";
00471         }                       
00472     }
00473     else {
00474         opserr << "WARNING FE_Element::addRtoResidual() - no Element *given ";
00475         opserr << "- subclasses must provide implementation\n";
00476     }                   
00477 }
00478 
00479 
00480 void  
00481 FE_Element::addRIncInertiaToResidual(double fact)
00482 {
00483     if (myEle != 0) {
00484         // check for a quick return     
00485         if (fact == 0.0) 
00486             return;
00487         else if (myEle->isSubdomain() == false) {
00488           const Vector &eleResisting = myEle->getResistingForceIncInertia();
00489           theResidual->addVector(1.0, eleResisting, -fact);
00490         }
00491         else {
00492             opserr << "WARNING FE_Element::addRtoResidual() - ";
00493             opserr << "- this should not be called on a Subdomain!\n";
00494         }                       
00495     }
00496     else {
00497         opserr << "WARNING FE_Element::addRtoResidual() - no Element *given ";
00498         opserr << "- subclasses must provide implementation\n";
00499     }                   
00500 }
00501 
00502 
00503 const Vector &
00504 FE_Element::getTangForce(const Vector &disp, double fact)
00505 {
00506     if (myEle != 0) {    
00507 
00508         // zero out the force vector
00509         theResidual->Zero();
00510 
00511         // check for a quick return
00512         if (fact == 0.0) 
00513             return *theResidual;
00514 
00515         // get the components we need out of the vector
00516         // and place in a temporary vector
00517         Vector tmp(numDOF);
00518         for (int i=0; i<numDOF; i++) {
00519           int dof = myID(i);
00520           if (dof >= 0)
00521             tmp(i) = disp(myID(i));
00522           else
00523             tmp(i) = 0.0;
00524         }
00525 
00526         if (myEle->isSubdomain() == false) {
00527             // form the tangent again and then add the force
00528             theIntegrator->formEleTangent(this);
00529             if (theResidual->addMatrixVector(1.0, *theTangent,tmp,fact) < 0) {
00530                 opserr << "WARNING FE_Element::getTangForce() - ";
00531                 opserr << "- addMatrixVector returned error\n";          
00532             }                           
00533         }
00534         else {
00535             Subdomain *theSub = (Subdomain *)myEle;
00536             if (theResidual->addMatrixVector(1.0, theSub->getTang(),tmp,fact) < 0) {
00537                 opserr << "WARNING FE_Element::getTangForce() - ";
00538                 opserr << "- addMatrixVector returned error\n";          
00539             }                                           
00540         }
00541         return *theResidual;
00542     }
00543     else {
00544         opserr << "WARNING FE_Element::addTangForce() - no Element *given ";
00545         opserr << "- subclasses must provide implementation\n";
00546         return errVector;       
00547     }                       
00548 }
00549 
00550 
00551 
00552 const Vector &
00553 FE_Element::getK_Force(const Vector &disp, double fact)
00554 {
00555     if (myEle != 0) {    
00556 
00557         // zero out the force vector
00558         theResidual->Zero();
00559 
00560         // check for a quick return
00561         if (fact == 0.0) 
00562             return *theResidual;
00563 
00564         // get the components we need out of the vector
00565         // and place in a temporary vector
00566         Vector tmp(numDOF);
00567         for (int i=0; i<numDOF; i++) {
00568           int dof = myID(i);
00569           if (dof >= 0)
00570             tmp(i) = disp(myID(i));
00571           else
00572             tmp(i) = 0.0;
00573         }
00574 
00575         if (theResidual->addMatrixVector(1.0, myEle->getTangentStiff(), tmp, fact) < 0){
00576           opserr << "WARNING FE_Element::getKForce() - ";
00577           opserr << "- addMatrixVector returned error\n";                
00578         }               
00579 
00580         return *theResidual;
00581     }
00582     else {
00583         opserr << "WARNING FE_Element::getKForce() - no Element *given ";
00584         opserr << "- subclasses must provide implementation\n";
00585         return errVector;       
00586     }                       
00587 }
00588 
00589 
00590 const Vector &
00591 FE_Element::getKi_Force(const Vector &disp, double fact)
00592 {
00593     if (myEle != 0) {    
00594 
00595         // zero out the force vector
00596         theResidual->Zero();
00597 
00598         // check for a quick return
00599         if (fact == 0.0) 
00600             return *theResidual;
00601 
00602         // get the components we need out of the vector
00603         // and place in a temporary vector
00604         Vector tmp(numDOF);
00605         for (int i=0; i<numDOF; i++) {
00606           int dof = myID(i);
00607           if (dof >= 0)
00608             tmp(i) = disp(myID(i));
00609           else
00610             tmp(i) = 0.0;
00611         }
00612 
00613         if (theResidual->addMatrixVector(1.0, myEle->getInitialStiff(), tmp, fact) < 0){
00614           opserr << "WARNING FE_Element::getKForce() - ";
00615           opserr << "- addMatrixVector returned error\n";                
00616         }               
00617 
00618         return *theResidual;
00619     }
00620     else {
00621         opserr << "WARNING FE_Element::getKForce() - no Element *given ";
00622         opserr << "- subclasses must provide implementation\n";
00623         return errVector;       
00624     }                       
00625 }
00626 
00627 const Vector &
00628 FE_Element::getM_Force(const Vector &disp, double fact)
00629 {
00630 
00631     if (myEle != 0) {    
00632 
00633         // zero out the force vector
00634         theResidual->Zero();
00635 
00636         // check for a quick return
00637         if (fact == 0.0) 
00638             return *theResidual;
00639 
00640         // get the components we need out of the vector
00641         // and place in a temporary vector
00642         Vector tmp(numDOF);
00643         for (int i=0; i<numDOF; i++) {
00644           int dof = myID(i);
00645           if (dof >= 0)
00646             tmp(i) = disp(myID(i));
00647           else
00648             tmp(i) = 0.0;
00649         }
00650 
00651         if (theResidual->addMatrixVector(1.0, myEle->getMass(), tmp, fact) < 0){
00652           opserr << "WARNING FE_Element::getMForce() - ";
00653           opserr << "- addMatrixVector returned error\n";                
00654         }               
00655 
00656 
00657         return *theResidual;
00658     }
00659     else {
00660         opserr << "WARNING FE_Element::getMForce() - no Element *given ";
00661         opserr << "- subclasses must provide implementation\n";
00662         return errVector;       
00663     }                       
00664 }
00665 
00666 const Vector &
00667 FE_Element::getC_Force(const Vector &disp, double fact)
00668 {
00669     if (myEle != 0) {    
00670 
00671         // zero out the force vector
00672         theResidual->Zero();
00673 
00674         // check for a quick return
00675         if (fact == 0.0) 
00676             return *theResidual;
00677 
00678         // get the components we need out of the vector
00679         // and place in a temporary vector
00680         Vector tmp(numDOF);
00681         for (int i=0; i<numDOF; i++) {
00682           int dof = myID(i);
00683           if (dof >= 0)
00684             tmp(i) = disp(myID(i));
00685           else
00686             tmp(i) = 0.0;
00687         }
00688 
00689         if (theResidual->addMatrixVector(1.0, myEle->getDamp(), tmp, fact) < 0){
00690           opserr << "WARNING FE_Element::getDForce() - ";
00691           opserr << "- addMatrixVector returned error\n";                
00692         }               
00693 
00694         return *theResidual;
00695     }
00696     else {
00697         opserr << "WARNING FE_Element::getDForce() - no Element *given ";
00698         opserr << "- subclasses must provide implementation\n";
00699         return errVector;       
00700     }                       
00701 }
00702 
00703 
00704 
00705 Integrator *
00706 FE_Element::getLastIntegrator(void)
00707 {
00708     return theIntegrator;
00709 }
00710 
00711 const Vector &
00712 FE_Element::getLastResponse(void)
00713 {
00714     if (myEle != 0) {
00715       if (theIntegrator != 0) {
00716         if (theIntegrator->getLastResponse(*theResidual,myID) < 0) {
00717           opserr << "WARNING FE_Element::getLastResponse(void)";
00718           opserr << " - the Integrator had problems with getLastResponse()\n";
00719         }
00720       }
00721       else {
00722         theResidual->Zero();
00723         opserr << "WARNING  FE_Element::getLastResponse()";
00724         opserr << " No Integrator yet passed\n";
00725       }
00726     
00727       Vector &result = *theResidual;
00728       return result;
00729     }
00730     else {
00731         opserr << "WARNING  FE_Element::getLastResponse()";
00732         opserr << " No Element passed in constructor\n";
00733         return errVector;
00734     }
00735 }
00736 
00737 void  
00738 FE_Element::addM_Force(const Vector &accel, double fact)
00739 {
00740     if (myEle != 0) {    
00741 
00742         // check for a quick return
00743         if (fact == 0.0) 
00744             return;
00745         if (myEle->isSubdomain() == false) {
00746             // get the components we need out of the vector
00747             // and place in a temporary vector
00748             Vector tmp(numDOF);
00749             for (int i=0; i<numDOF; i++) {
00750                 int loc = myID(i);
00751                 if (loc >= 0)
00752                     tmp(i) = accel(loc);
00753                 else
00754                     tmp(i) = 0.0;               
00755             }    
00756                 
00757             if (theResidual->addMatrixVector(1.0, myEle->getMass(), tmp, fact) < 0){
00758                 opserr << "WARNING FE_Element::addM_Force() - ";
00759                 opserr << "- addMatrixVector returned error\n";          
00760             }           
00761         }
00762         else {
00763             opserr << "WARNING FE_Element::addM_Force() - ";
00764             opserr << "- this should not be called on a Subdomain!\n";
00765         }                                               
00766     }
00767     else {
00768         opserr << "WARNING FE_Element::addM_Force() - no Element *given ";
00769         opserr << "- subclasses must provide implementation\n";
00770     }                       
00771 }
00772 
00773 void  
00774 FE_Element::addD_Force(const Vector &accel, double fact)
00775 {
00776     if (myEle != 0) {    
00777 
00778         // check for a quick return
00779         if (fact == 0.0) 
00780             return;
00781         if (myEle->isSubdomain() == false) {
00782             // get the components we need out of the vector
00783             // and place in a temporary vector
00784             Vector tmp(numDOF);
00785             for (int i=0; i<numDOF; i++) {
00786                 int loc = myID(i);
00787                 if (loc >= 0)
00788                     tmp(i) = accel(loc);
00789                 else
00790                     tmp(i) = 0.0;               
00791             }     
00792                 
00793             if (theResidual->addMatrixVector(1.0, myEle->getDamp(), tmp, fact) < 0){
00794                 opserr << "WARNING FE_Element::addD_Force() - ";
00795                 opserr << "- addMatrixVector returned error\n";          
00796             }           
00797         }
00798         else {
00799             opserr << "WARNING FE_Element::addD_Force() - ";
00800             opserr << "- this should not be called on a Subdomain!\n";
00801         }                                               
00802     }
00803     else {
00804         opserr << "WARNING FE_Element::addD_Force() - no Element *given ";
00805         opserr << "- subclasses must provide implementation\n";
00806     }                       
00807 }
00808 
00809 void  
00810 FE_Element::addLocalM_Force(const Vector &accel, double fact)
00811 {
00812     if (myEle != 0) {    
00813 
00814         // check for a quick return
00815         if (fact == 0.0) 
00816             return;
00817         if (myEle->isSubdomain() == false) {
00818             if (theResidual->addMatrixVector(1.0, myEle->getMass(),
00819                                              accel, fact) < 0){
00820 
00821               opserr << "WARNING FE_Element::addLocalM_Force() - ";
00822               opserr << "- addMatrixVector returned error\n"; 
00823             }           
00824         }
00825         else {
00826             opserr << "WARNING FE_Element::addLocalM_Force() - ";
00827             opserr << "- this should not be called on a Subdomain!\n";
00828         }                                               
00829     }
00830     else {
00831         opserr << "WARNING FE_Element::addLocalM_Force() - no Element *given ";
00832         opserr << "- subclasses must provide implementation\n";
00833     }                       
00834 }
00835 
00836 void  
00837 FE_Element::addLocalD_Force(const Vector &accel, double fact)
00838 {
00839     if (myEle != 0) {    
00840 
00841         // check for a quick return
00842         if (fact == 0.0) 
00843             return;
00844         if (myEle->isSubdomain() == false) {
00845             if (theResidual->addMatrixVector(1.0, myEle->getDamp(),
00846                                              accel, fact) < 0){
00847 
00848               opserr << "WARNING FE_Element::addLocalD_Force() - ";
00849               opserr << "- addMatrixVector returned error\n"; 
00850             }           
00851         }
00852         else {
00853             opserr << "WARNING FE_Element::addLocalD_Force() - ";
00854             opserr << "- this should not be called on a Subdomain!\n";
00855         }                                               
00856     }
00857     else {
00858         opserr << "WARNING FE_Element::addLocalD_Force() - no Element *given ";
00859         opserr << "- subclasses must provide implementation\n";
00860     }                       
00861 }
00862 
00863 
00864 Element *
00865 FE_Element::getElement(void)
00866 {
00867   return myEle;
00868 }
00869 
00870 
00871 // AddingSensitivity:BEGIN /////////////////////////////////
00872 void  
00873 FE_Element::addResistingForceSensitivity(int gradNumber, double fact)
00874 {
00875   theResidual->addVector(1.0, myEle->getResistingForceSensitivity(gradNumber), -fact);
00876 }
00877 
00878 void  
00879 FE_Element::addM_ForceSensitivity(int gradNumber, const Vector &vect, double fact)
00880 {
00881   // Get the components we need out of the vector
00882   // and place in a temporary vector
00883   Vector tmp(numDOF);
00884   for (int i=0; i<numDOF; i++) {
00885     int loc = myID(i);
00886     if (loc >= 0) {
00887       tmp(i) = vect(loc);
00888     }
00889     else {
00890       tmp(i) = 0.0;
00891     }
00892   }
00893   if (theResidual->addMatrixVector(1.0, myEle->getMassSensitivity(gradNumber),tmp,fact) < 0) {
00894     opserr << "WARNING FE_Element::addM_ForceSensitivity() - ";
00895     opserr << "- addMatrixVector returned error\n";              
00896   }
00897 }
00898 
00899 void  
00900 FE_Element::addD_ForceSensitivity(int gradNumber, const Vector &vect, double fact)
00901 {
00902   if (myEle != 0) {    
00903     
00904     // check for a quick return
00905     if (fact == 0.0) 
00906       return;
00907     if (myEle->isSubdomain() == false) {
00908       // get the components we need out of the vector
00909       // and place in a temporary vector
00910       Vector tmp(numDOF);
00911       for (int i=0; i<numDOF; i++) {
00912         int loc = myID(i);
00913         if (loc >= 0)
00914           tmp(i) = vect(loc);
00915         else
00916           tmp(i) = 0.0;         
00917       } 
00918       if (theResidual->addMatrixVector(1.0, myEle->getDampSensitivity(gradNumber), tmp, fact) < 0){
00919         opserr << "WARNING FE_Element::addD_ForceSensitivity() - ";
00920         opserr << "- addMatrixVector returned error\n";          
00921       }         
00922     }
00923     else {
00924       opserr << "WARNING FE_Element::addD_ForceSensitivity() - ";
00925       opserr << "- this should not be called on a Subdomain!\n";
00926     }                                                   
00927   }
00928   else {
00929     opserr << "WARNING FE_Element::addD_ForceSensitivity() - no Element *given ";
00930     opserr << "- subclasses must provide implementation\n";
00931   }                 
00932 }
00933 
00934 void  
00935 FE_Element::addLocalD_ForceSensitivity(int gradNumber, const Vector &accel, double fact)
00936 {
00937     if (myEle != 0) {    
00938 
00939         // check for a quick return
00940         if (fact == 0.0) 
00941             return;
00942         if (myEle->isSubdomain() == false) {
00943             if (theResidual->addMatrixVector(1.0, myEle->getDampSensitivity(gradNumber),
00944                                              accel, fact) < 0){
00945 
00946               opserr << "WARNING FE_Element::addLocalD_ForceSensitivity() - ";
00947               opserr << "- addMatrixVector returned error\n"; 
00948             }           
00949         }
00950         else {
00951             opserr << "WARNING FE_Element::addLocalD_ForceSensitivity() - ";
00952             opserr << "- this should not be called on a Subdomain!\n";
00953         }                                               
00954     }
00955     else {
00956         opserr << "WARNING FE_Element::addLocalD_ForceSensitivity() - no Element *given ";
00957         opserr << "- subclasses must provide implementation\n";
00958     }                       
00959 }
00960 
00961 void  
00962 FE_Element::addLocalM_ForceSensitivity(int gradNumber, const Vector &accel, double fact)
00963 {
00964     if (myEle != 0) {    
00965 
00966         // check for a quick return
00967         if (fact == 0.0) 
00968             return;
00969         if (myEle->isSubdomain() == false) {
00970             if (theResidual->addMatrixVector(1.0, myEle->getMassSensitivity(gradNumber),
00971                                              accel, fact) < 0){
00972 
00973               opserr << "WARNING FE_Element::addLocalD_ForceSensitivity() - ";
00974               opserr << "- addMatrixVector returned error\n"; 
00975             }           
00976         }
00977         else {
00978             opserr << "WARNING FE_Element::addLocalD_ForceSensitivity() - ";
00979             opserr << "- this should not be called on a Subdomain!\n";
00980         }                                               
00981     }
00982     else {
00983         opserr << "WARNING FE_Element::addLocalD_ForceSensitivity() - no Element *given ";
00984         opserr << "- subclasses must provide implementation\n";
00985     }                       
00986 }
00987 
00988 
00989 
00990 
00991 
00992 int  
00993 FE_Element::commitSensitivity(int gradNum, int numGrads)
00994 {
00995   myEle->commitSensitivity(gradNum, numGrads);
00996   
00997   return 0;
00998 }
00999 
01000 // AddingSensitivity:END ////////////////////////////////////
01001 
01002 
01003 int  
01004 FE_Element::updateElement(void)
01005 {
01006   if (myEle != 0)
01007     return myEle->update();
01008 
01009   return 0;
01010 }

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