| 2726 | |
| 2727 | |
| 2728 | int |
| 2729 | Domain::buildEleGraph(Graph *theEleGraph) |
| 2730 | { |
| 2731 | // see if quick return |
| 2732 | int numVertex = this->getNumElements(); |
| 2733 | if (numVertex == 0) |
| 2734 | return 0; |
| 2735 | |
| 2736 | // |
| 2737 | // iterate over the lements of the domain |
| 2738 | // create a vertex with a unique tag for each element |
| 2739 | // also create a map to hold element tag - vertex tag mapping |
| 2740 | // |
| 2741 | |
| 2742 | MAP_INT theEleToVertexMap; |
| 2743 | MAP_INT_ITERATOR theEleToVertexMapEle; |
| 2744 | |
| 2745 | Element *theEle; |
| 2746 | ElementIter &theElements = this->getElements(); |
| 2747 | int count = START_VERTEX_NUM; |
| 2748 | while ((theEle = theElements()) != 0) { |
| 2749 | int eleTag = theEle->getTag(); |
| 2750 | Vertex *vertexPtr = new Vertex(count, eleTag); |
| 2751 | |
| 2752 | if (vertexPtr == 0) { |
| 2753 | opserr << "WARNING Domain::buildEleGraph - Not Enough Memory to create the " << count << " vertex\n"; |
| 2754 | return -1; |
| 2755 | } |
| 2756 | |
| 2757 | theEleGraph->addVertex(vertexPtr); |
| 2758 | theEleToVertexMapEle = theEleToVertexMap.find(eleTag); |
| 2759 | if (theEleToVertexMapEle == theEleToVertexMap.end()) { |
| 2760 | theEleToVertexMap.insert(MAP_INT_TYPE(eleTag, count)); |
| 2761 | |
| 2762 | // check if successfully added |
| 2763 | theEleToVertexMapEle = theEleToVertexMap.find(eleTag); |
| 2764 | if (theEleToVertexMapEle == theEleToVertexMap.end()) { |
| 2765 | opserr << "Domain::buildEleGraph - map STL failed to add object with tag : " << eleTag << endln; |
| 2766 | return false; |
| 2767 | } |
| 2768 | |
| 2769 | count++; |
| 2770 | } |
| 2771 | } |
| 2772 | |
| 2773 | // |
| 2774 | // We now need to determine which elements are associated with each node. |
| 2775 | // As this info is not in the Node interface we must build it; |
| 2776 | // |
| 2777 | // again we will use an stl map, index will be nodeTag, object will be Vertex |
| 2778 | // do using vertices for each node, when we addVertex at these nodes we |
| 2779 | // will not be adding vertices but element tags. |
| 2780 | // |
| 2781 | |
| 2782 | MAP_ID theNodeToVertexMap; |
| 2783 | MAP_ID_ITERATOR theNodeEle; |
| 2784 | |
| 2785 | Node *nodPtr; |
no test coverage detected