DOF_Graph.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.5 $
00022 // $Date: 2005/11/14 20:47:11 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/graph/graph/DOF_Graph.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/graph/graph/DOF_Graph.C
00027 // 
00028 // Written: fmk 
00029 // Created: Sun Sept 15 11:47:47: 1996
00030 // Revision: A
00031 //
00032 // Description: This file contains the class definition for DOF_Graph.
00033 // DOF_Graph is a graph of the DOFs in the analysis model. It is used
00034 // by the SysOfEqn to determine its size.
00035 //
00036 // What: "@(#) DOF_Graph.C, revA"
00037 
00038 
00039 #include <DOF_Graph.h>
00040 #include <Vertex.h>
00041 #include <AnalysisModel.h>
00042 #include <DOF_Group.h>
00043 #include <DOF_GrpIter.h>
00044 #include <FE_Element.h>
00045 #include <FE_EleIter.h>
00046 
00047 #define START_EQN_NUM 0
00048 // constructs the Graph
00049 // assumes eqn numbers are numbered continuously from START_EQN_NUM
00050 
00051 DOF_Graph::DOF_Graph(AnalysisModel &theModel)
00052 :Graph(theModel.getNumEqn()), 
00053  myModel(theModel)
00054 {
00055 
00056   /********************** old way to create vertices with dof Tags ********
00057     int numVertex = myModel.getNumEqn();
00058 
00059     if (numVertex <= 0) {
00060         opserr << "WARNING DOF_Graph::DOF_Graph";
00061         opserr << "  - 0 equations?\n";
00062         return;
00063     }   
00064 
00065     // now create the vertices with a reference equal to the eqn number.
00066     // and a tag which ranges from START_VERTEX_NUM through 
00067 
00068     for (int i =0; i<numVertex; i++) {
00069         Vertex *vertexPtr = new Vertex(i, i);
00070         
00071         if (vertexPtr == 0) {
00072             opserr << "WARNING DOF_Graph::DOF_Graph";
00073             opserr << " - Not Enough Memory to create " << i+1 << "th Vertex\n";
00074             return;
00075         }
00076         this->addVertex(vertexPtr,false);       
00077     }
00078     *****************************************************************************/
00079 
00080   //
00081   // create a vertex for each dof
00082   //
00083 
00084   DOF_Group *dofPtr =0;
00085   DOF_GrpIter &theDOFs = myModel.getDOFs();
00086   while ((dofPtr = theDOFs()) != 0) {
00087     const ID &id = dofPtr->getID();
00088     int size = id.Size();
00089     for (int i=0; i<size; i++) {
00090       int dofTag = id(i);
00091       if (dofTag >= START_EQN_NUM) {
00092         Vertex *vertexPtr = this->getVertexPtr(dofTag);
00093         if (vertexPtr == 0) {
00094           Vertex *vertexPtr = new Vertex(dofTag, dofTag);      
00095           if (vertexPtr == 0) {
00096             opserr << "WARNING DOF_Graph::DOF_Graph";
00097             opserr << " - Not Enough Memory to create " << i+1 << "th Vertex\n";
00098             return;
00099           }
00100           if (this->addVertex(vertexPtr, false) == false) {
00101             opserr << "WARNING DOF_Graph::DOF_Graph - error adding vertex\n";
00102           }
00103         }
00104       }
00105     }
00106   }
00107 
00108   // now add the edges, by looping over the FE_elements, getting their
00109   // IDs and adding edges between DOFs for equation numbers >= START_EQN_NUM
00110   
00111   FE_Element *elePtr =0;
00112   FE_EleIter &eleIter = myModel.getFEs();
00113   int cnt = 0;
00114 
00115   while((elePtr = eleIter()) != 0) {
00116     const ID &id = elePtr->getID();
00117     cnt++;
00118     int size = id.Size();
00119     for (int i=0; i<size; i++) {
00120       int eqn1 = id(i);
00121             
00122       // if eqnNum of DOF is a valid eqn number add an edge
00123       // to all other DOFs with valid eqn numbers.
00124       
00125       if (eqn1 >=START_EQN_NUM) {
00126         for (int j=i+1; j<size; j++) {
00127           int eqn2 = id(j);
00128           if (eqn2 >=START_EQN_NUM)
00129             this->addEdge(eqn1-START_EQN_NUM+START_VERTEX_NUM,
00130                           eqn2-START_EQN_NUM+START_VERTEX_NUM);
00131         }
00132       }
00133     }
00134   }
00135 }
00136 
00137 DOF_Graph::~DOF_Graph()
00138 {
00139 
00140 }    
00141 
00142 
00143 
00144 

Generated on Mon Oct 23 15:05:12 2006 for OpenSees by doxygen 1.5.0