PlainNumberer.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.3 $
00022 // $Date: 2003/02/14 23:00:51 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/analysis/numberer/PlainNumberer.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/analysis/numberer/PlainNumberer.C
00027 // 
00028 // Written: fmk 
00029 // Created: 9/96
00030 // Revision: A
00031 //
00032 // Description: This file contains the class definition for PlainNumberer.
00033 // PlainNumberer is a subclass of DOF_Numberer. The PlainNumberer assigns
00034 // equation numbers to the DOFs on a first come first serve basis; that is 
00035 // it gets the DOF_GrpIter and assigns the equation numbers to the DOFs
00036 // as it iterates through the iter.
00037 //
00038 // What: "@(#) PlainNumberer.C, revA"
00039 
00040 #include <PlainNumberer.h>
00041 #include <AnalysisModel.h>
00042 
00043 #include <DOF_Group.h>
00044 #include <DOF_GrpIter.h>
00045 #include <FE_Element.h>
00046 #include <FE_EleIter.h>
00047 #include <ID.h>
00048 #include <Channel.h>
00049 #include <FEM_ObjectBroker.h>
00050 
00051 #include <Domain.h>
00052 #include <MP_Constraint.h>
00053 #include <Node.h>
00054 #include <MP_ConstraintIter.h>
00055 
00056 PlainNumberer::PlainNumberer() 
00057 :DOF_Numberer(NUMBERER_TAG_PlainNumberer)
00058 {
00059 }
00060 
00061 PlainNumberer::~PlainNumberer() 
00062 {
00063 }
00064 
00065 
00066 // int numberDOF(void)
00067 //      Method to number the unnumbered DOFs in the DOF Groups. It does so
00068 //      on a first come fist serve basis, first assigning all DOFs with a -2
00069 //      a number, then all DOFs with a -3 a number.
00070 
00071 int
00072 PlainNumberer::numberDOF(int lastDOF)
00073 {
00074     int eqnNumber = 0; // start equation number = 0
00075 
00076     // get a pointer to the model & check its not null
00077     AnalysisModel *theModel = this->getAnalysisModelPtr();
00078     Domain *theDomain = 0;
00079     if (theModel != 0) theDomain = theModel->getDomainPtr();
00080 
00081     if (theModel == 0 || theDomain == 0) {
00082         opserr << "WARNING PlainNumberer::numberDOF(int) -";
00083         opserr << " - no AnalysisModel - has setLinks() been invoked?\n";
00084         return -1;
00085     }
00086     
00087     if (lastDOF != -1) {
00088         opserr << "WARNING PlainNumberer::numberDOF(int lastDOF):";
00089         opserr << " does not use the lastDOF as requested\n";
00090     }
00091     
00092     // iterate throgh  the DOFs first time setting -2 values
00093     DOF_GrpIter &theDOFs = theModel->getDOFs();
00094     DOF_Group *dofPtr;
00095     
00096     while ((dofPtr = theDOFs()) != 0) {
00097         const ID &theID = dofPtr->getID();
00098         for (int i=0; i<theID.Size(); i++)
00099             if (theID(i) == -2) 
00100               dofPtr->setID(i,eqnNumber++);
00101     }
00102 
00103     // iterate throgh  the DOFs second time setting -3 values
00104     DOF_GrpIter &moreDOFs = theModel->getDOFs();
00105     
00106     while ((dofPtr = moreDOFs()) != 0) {
00107         const ID &theID = dofPtr->getID();
00108         for (int i=0; i<theID.Size(); i++)
00109             if (theID(i) == -3) dofPtr->setID(i,eqnNumber++);
00110     }
00111 
00112     // iterate through the DOFs one last time setting any -4 values
00113     DOF_GrpIter &tDOFs = theModel->getDOFs();
00114     while ((dofPtr = tDOFs()) != 0) {
00115         const ID &theID = dofPtr->getID();
00116         int have4s = 0;
00117         for (int i=0; i<theID.Size(); i++)
00118             if (theID(i) == -4) have4s = 1;
00119 
00120         if (have4s == 1) {
00121                 int nodeID = dofPtr->getNodeTag();
00122                 // loop through the MP_Constraints to see if any of the
00123                 // DOFs are constrained, note constraint matrix must be diagonal
00124                 // with 1's on the diagonal
00125                 MP_ConstraintIter &theMPs = theDomain->getMPs();
00126                 MP_Constraint *mpPtr;
00127                 while ((mpPtr = theMPs()) != 0 ) {
00128                         // note keep looping over all in case multiple constraints
00129                         // are used to constrain a node -- can't assume intelli user
00130                         if (mpPtr->getNodeConstrained() == nodeID) {
00131                                 int nodeRetained = mpPtr->getNodeRetained();
00132                                 Node *nodeRetainedPtr = theDomain->getNode(nodeRetained);
00133                                 DOF_Group *retainedDOF = nodeRetainedPtr->getDOF_GroupPtr();
00134                                 const ID&retainedDOFIDs = retainedDOF->getID();
00135                                 const ID&constrainedDOFs = mpPtr->getConstrainedDOFs();
00136                                 const ID&retainedDOFs = mpPtr->getRetainedDOFs();
00137                                 for (int i=0; i<constrainedDOFs.Size(); i++) {
00138                                         int dofC = constrainedDOFs(i);
00139                                         int dofR = retainedDOFs(i);
00140                                         int dofID = retainedDOFIDs(dofR);
00141                                         dofPtr->setID(dofC, dofID);
00142                                 }
00143                         }
00144                 }               
00145         }       
00146     }
00147 
00148     eqnNumber--;
00149     int numEqn = eqnNumber - START_EQN_NUMBER +1;
00150         
00151     // iterate through the FE_Element getting them to set their IDs
00152     FE_EleIter &theEle = theModel->getFEs();
00153     FE_Element *elePtr;
00154     while ((elePtr = theEle()) != 0)
00155         elePtr->setID();
00156 
00157     // set the numOfEquation in the Model
00158     theModel->setNumEqn(numEqn);
00159 
00160     return numEqn;
00161 }
00162 
00163 
00164 int
00165 PlainNumberer::sendSelf(int cTag, Channel &theChannel)
00166 {
00167     return 0;
00168 }
00169 
00170 int
00171 PlainNumberer::recvSelf(int cTag, 
00172                         Channel &theChannel, 
00173                         FEM_ObjectBroker &theBroker)
00174 {
00175     return 0;
00176 }
00177 
00178 
00179 int
00180 PlainNumberer::numberDOF(ID &lastDOFs)
00181 {
00182    int eqnNumber = 0; // start equation number = 0
00183     
00184     // get a pointer to the model & check its not null
00185     AnalysisModel *theModel = this->getAnalysisModelPtr();
00186     Domain *theDomain =0;
00187     if (theModel != 0) theDomain = theModel->getDomainPtr();
00188 
00189     if (theModel == 0 || theDomain == 0) {
00190         opserr << "WARNING PlainNumberer::numberDOF(int) -";
00191         opserr << " - no AnalysisModel - has setLinks() been invoked?\n";
00192         return -1;
00193     }
00194     
00195     opserr << "WARNING PlainNumberer::numberDOF(ID):";
00196     opserr << " does not use the lastDOFs as requested\n";
00197     
00198     // iterate throgh  the DOFs first time setting -2 values
00199     DOF_GrpIter &theDOFs = theModel->getDOFs();
00200     DOF_Group *dofPtr;
00201     
00202     while ((dofPtr = theDOFs()) != 0) {
00203         const ID &theID = dofPtr->getID();
00204         for (int i=0; i<theID.Size(); i++)
00205             if (theID(i) == -2) dofPtr->setID(i,eqnNumber++);
00206     }
00207 
00208     // iterate throgh  the DOFs first time setting -3 values
00209     DOF_GrpIter &moreDOFs = theModel->getDOFs();
00210     
00211     while ((dofPtr = moreDOFs()) != 0) {
00212         const ID &theID = dofPtr->getID();
00213         for (int i=0; i<theID.Size(); i++)
00214             if (theID(i) == -3) dofPtr->setID(i,eqnNumber++);
00215     }
00216     // iterate through the DOFs one last time setting any -4 values
00217     // iterate through the DOFs one last time setting any -4 values
00218     DOF_GrpIter &tDOFs = theModel->getDOFs();
00219     while ((dofPtr = tDOFs()) != 0) {
00220         const ID &theID = dofPtr->getID();
00221         int have4s = 0;
00222         for (int i=0; i<theID.Size(); i++)
00223             if (theID(i) == -4) have4s = 1;
00224 
00225         if (have4s == 1) {
00226                 int nodeID = dofPtr->getNodeTag();
00227                 // loop through the MP_Constraints to see if any of the
00228                 // DOFs are constrained, note constraint matrix must be diagonal
00229                 // with 1's on the diagonal
00230                 MP_ConstraintIter &theMPs = theDomain->getMPs();
00231                 MP_Constraint *mpPtr;
00232                 while ((mpPtr = theMPs()) != 0 ) {
00233                         // note keep looping over all in case multiple constraints
00234                         // are used to constrain a node -- can't assume intelli user
00235                         if (mpPtr->getNodeConstrained() == nodeID) {
00236                                 int nodeRetained = mpPtr->getNodeRetained();
00237                                 Node *nodeRetainedPtr = theDomain->getNode(nodeRetained);
00238                                 DOF_Group *retainedDOF = nodeRetainedPtr->getDOF_GroupPtr();
00239                                 const ID&retainedDOFIDs = retainedDOF->getID();
00240                                 const ID&constrainedDOFs = mpPtr->getConstrainedDOFs();
00241                                 const ID&retainedDOFs = mpPtr->getRetainedDOFs();
00242                                 for (int i=0; i<constrainedDOFs.Size(); i++) {
00243                                         int dofC = constrainedDOFs(i);
00244                                         int dofR = retainedDOFs(i);
00245                                         int dofID = retainedDOFIDs(dofR);
00246                                         dofPtr->setID(dofC, dofID);
00247                                 }
00248                         }
00249                 }               
00250         }       
00251     }
00252 
00253     eqnNumber--;
00254     int numEqn = eqnNumber - START_EQN_NUMBER +1;
00255         
00256     // iterate through the FE_Element getting them to set their IDs
00257     FE_EleIter &theEle = theModel->getFEs();
00258     FE_Element *elePtr;
00259     while ((elePtr = theEle()) != 0)
00260         elePtr->setID();
00261 
00262     // set the numOfEquation in the Model
00263     theModel->setNumEqn(numEqn);
00264 
00265     return numEqn;
00266 }

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