SimpleNumberer.cppGo 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: 2006/01/12 23:39:21 $ 00023 // $Source: /usr/local/cvs/OpenSees/SRC/graph/numberer/SimpleNumberer.cpp,v $ 00024 00025 00026 00027 // Written: fmk 00028 // Revision: A 00029 // 00030 // Description: This file contains the class definition for SimpleNumberer. 00031 // SimpleNumberer is an object to perform a simple numbering of the vertices. 00032 // It does this by using the graphs VertexIter and assigning the numbers as 00033 // it comes across the vertices. 00034 // 00035 // What: "@(#) SimpleNumberer.C, revA" 00036 00037 #include <SimpleNumberer.h> 00038 #include <Graph.h> 00039 #include <Vertex.h> 00040 #include <VertexIter.h> 00041 #include <ID.h> 00042 #include <Channel.h> 00043 #include <FEM_ObjectBroker.h> 00044 00045 // Constructor 00046 SimpleNumberer::SimpleNumberer() 00047 :GraphNumberer(GraphNUMBERER_TAG_SimpleNumberer), 00048 numVertex(-1), theRefResult(0) 00049 { 00050 00051 } 00052 00053 // Destructor 00054 SimpleNumberer::~SimpleNumberer() 00055 { 00056 if (theRefResult != 0) 00057 delete theRefResult; 00058 } 00059 00060 // const ID &number(Graph &theGraph) 00061 // 00062 00063 00064 const ID & 00065 SimpleNumberer::number(Graph &theGraph, int lastVertex) 00066 { 00067 // first check our size, if not same make new 00068 00069 if (numVertex != theGraph.getNumVertex()) { 00070 00071 if (theRefResult != 0) 00072 delete theRefResult; 00073 00074 numVertex = theGraph.getNumVertex(); 00075 theRefResult = new ID(numVertex); 00076 00077 if (theRefResult == 0) { 00078 opserr << "ERROR: SimpleNumberer::number - Out of Memory\n"; 00079 theRefResult = new ID(0); 00080 numVertex = 0; 00081 return *theRefResult; 00082 } 00083 } 00084 00085 // see if we can do quick return 00086 00087 if (numVertex == 0) 00088 return *theRefResult; 00089 00090 00091 // Now we go through the iter and assign the numbers 00092 00093 if (lastVertex != -1) { 00094 opserr << "WARNING: SimpleNumberer::number -"; 00095 opserr << " - does not deal with lastVertex"; 00096 } 00097 00098 Vertex *vertexPtr; 00099 VertexIter &vertexIter = theGraph.getVertices(); 00100 int count = 0; 00101 00102 while ((vertexPtr = vertexIter()) != 0) { 00103 00104 (*theRefResult)(count++) = vertexPtr->getTag(); 00105 vertexPtr->setTmp(count); 00106 } 00107 00108 return *theRefResult; 00109 } 00110 00111 00112 int 00113 SimpleNumberer::sendSelf(int commitTag, Channel &theChannel) 00114 { 00115 return 0; 00116 } 00117 00118 int 00119 SimpleNumberer::recvSelf(int commitTag, Channel &theChannel, FEM_ObjectBroker &theBroker) 00120 { 00121 return 0; 00122 } 00123 00124 const ID & 00125 SimpleNumberer::number(Graph &theGraph, const ID &startVertices) 00126 { 00127 return this->number(theGraph); 00128 } |