DOF_GroupGraph.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: 2005/11/03 23:11:55 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/graph/graph/DOF_GroupGraph.cpp,v $
00024                                                                         
00025                                                                         
00026 // Written: fmk 
00027 // Revision: A
00028 //
00029 // Description: This file contains the class definition for DOF_GroupGraph.
00030 // DOF_GroupGraph is a graph of the DOF_Groups in the domain. It is used by the
00031 // DOF_Numberer to assign equation numbers to the DOFs.
00032 //
00033 // What: "@(#) DOF_GroupGraph.C, revA"
00034 
00035 
00036 #include <DOF_GroupGraph.h>
00037 #include <Vertex.h>
00038 #include <AnalysisModel.h>
00039 #include <FE_Element.h>
00040 #include <DOF_Group.h>
00041 #include <FE_EleIter.h>
00042 #include <DOF_GrpIter.h>
00043 
00044 // constructs the Graph
00045 DOF_GroupGraph::DOF_GroupGraph(AnalysisModel &theModel)
00046 :Graph(theModel.getNumDOF_Groups()+START_VERTEX_NUM), 
00047  myModel(theModel)
00048 {
00049 
00050     int numVertex = myModel.getNumDOF_Groups();
00051 
00052     if (numVertex == 0) {
00053         opserr << "WARNING DOF_GroupGraph::DOF_GroupGraph";
00054         opserr << "  - 0 vertices, has the Domain been populated?\n";
00055         return;
00056     }   
00057         
00058     DOF_Group *dofPtr;
00059 
00060     // now create the vertices with a reference equal to the DOF_Group number.
00061     // and a tag which ranges from 0 through numVertex-1
00062 
00063     DOF_GrpIter &dofIter2 = theModel.getDOFs();
00064     int count = START_VERTEX_NUM;
00065     while ((dofPtr = dofIter2()) != 0) {
00066         int DOF_GroupTag = dofPtr->getTag();
00067         int DOF_GroupNodeTag = dofPtr->getNodeTag();
00068         int numDOF = dofPtr->getNumFreeDOF();
00069         Vertex *vertexPtr = new Vertex(DOF_GroupTag, DOF_GroupNodeTag, 0, numDOF);
00070 
00071         if (vertexPtr == 0) {
00072             opserr << "WARNING DOF_GroupGraph::DOF_GroupGraph";
00073             opserr << " - Not Enough Memory to create ";
00074             opserr << count << "th Vertex\n";
00075             return;
00076         }
00077         
00078         this->addVertex(vertexPtr);
00079     }
00080 
00081 
00082     // now add the edges, by looping over the Elements, getting their
00083     // IDs and adding edges between DOFs for equation numbers >= START_EQN_NUM
00084     
00085     FE_Element *elePtr;
00086     FE_EleIter &eleIter = myModel.getFEs();
00087 
00088     while((elePtr = eleIter()) != 0) {
00089         const ID &id = elePtr->getDOFtags();
00090         int size = id.Size();
00091         for (int i=0; i<size; i++) {
00092             int dof1 = id(i);
00093             for (int j=0; j<size; j++) 
00094                 if (i != j) {
00095                     int dof2 = id(j);
00096                     this->addEdge(dof1,dof2);
00097                 }
00098         }
00099     }
00100 }
00101 
00102 DOF_GroupGraph::~DOF_GroupGraph()
00103 {
00104 
00105 }    
00106 
00107 

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