//! @brief Constructor. //! //! The constructor is responsible for constructing the graph given {\em //! theModel}. It creates the vertices of the graph, one for every //! equation (each DOF that has not been constrained out by the //! constraint handler) in the model and adds all edges based on the //! FE\_Element connectivity. For this reason the model must be fully //! populated with the DOF\_Group and FE\_Element objects before // the constructor is called. XC::DOF_GroupGraph::DOF_GroupGraph(const AnalysisModel &theModel) :ModelGraph(theModel.getNumDOF_Groups()+START_VERTEX_NUM,theModel) { assert(myModel); const int numVertex= myModel->getNumDOF_Groups(); if(numVertex>0) { const DOF_Group *dofGroupPtr= nullptr; // now create the vertices with a reference equal to the DOF_Group number. // and a tag which ranges from 0 through numVertex-1 DOF_GrpConstIter &dofIter2 = myModel->getConstDOFs(); while((dofGroupPtr = dofIter2()) != 0) { const int DOF_GroupTag = dofGroupPtr->getTag(); const int DOF_GroupNodeTag = dofGroupPtr->getNodeTag(); const int numDOF = dofGroupPtr->getNumFreeDOF(); Vertex vrt(DOF_GroupTag, DOF_GroupNodeTag, 0, numDOF); this->addVertex(vrt); } // now add the edges, by looping over the Elements, getting their // IDs and adding edges between DOFs for equation numbers >= START_EQN_NUM const FE_Element *elePtr= nullptr; FE_EleConstIter &eleIter = myModel->getConstFEs(); while((elePtr = eleIter()) != 0) { const ID &id= elePtr->getDOFtags(); const int size = id.Size(); for(int i=0; i<size; i++) { int dof1 = id(i); for(int j=0; j<size; j++) if(i != j) { const int dof2 = id(j); this->addEdge(dof1,dof2); } } } } }
Graph & AnalysisModel::getDOFGroupGraph(void) { if (myGroupGraph == 0) { int numVertex = this->getNumDOF_Groups(); if (numVertex == 0) { opserr << "WARNING AnalysisMode::getGroupGraph"; opserr << " - 0 vertices, has the Domain been populated?\n"; exit(-1); } // myGroupGraph = new Graph(numVertex); MapOfTaggedObjects *graphStorage = new MapOfTaggedObjects(); myGroupGraph = new Graph(*graphStorage); if (numVertex == 0) { opserr << "WARNING AnalysisMode::getGroupGraph"; opserr << " - out of memory\n"; exit(-1); } DOF_Group *dofPtr; // now create the vertices with a reference equal to the DOF_Group number. // and a tag which ranges from 0 through numVertex-1 DOF_GrpIter &dofIter2 = this->getDOFs(); int count = START_VERTEX_NUM; while ((dofPtr = dofIter2()) != 0) { int DOF_GroupTag = dofPtr->getTag(); int DOF_GroupNodeTag = dofPtr->getNodeTag(); int numDOF = dofPtr->getNumFreeDOF(); Vertex *vertexPtr = new Vertex(DOF_GroupTag, DOF_GroupNodeTag, 0, numDOF); if (vertexPtr == 0) { opserr << "WARNING DOF_GroupGraph::DOF_GroupGraph"; opserr << " - Not Enough Memory to create "; opserr << count << "th Vertex\n"; return *myGroupGraph; } myGroupGraph->addVertex(vertexPtr); } // now add the edges, by looping over the Elements, getting their // IDs and adding edges between DOFs for equation numbers >= START_EQN_NUM FE_Element *elePtr; FE_EleIter &eleIter = this->getFEs(); while((elePtr = eleIter()) != 0) { const ID &id = elePtr->getDOFtags(); int size = id.Size(); for (int i=0; i<size; i++) { int dof1 = id(i); for (int j=0; j<size; j++) if (i != j) { int dof2 = id(j); myGroupGraph->addEdge(dof1,dof2); } } } } return *myGroupGraph; }