MCPcopy Create free account
hub / github.com/OpenSees/OpenSees / mergeSubGraph

Method mergeSubGraph

SRC/analysis/numberer/ParallelNumberer.cpp:364–421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

362
363
364int
365ParallelNumberer::mergeSubGraph(Graph &theGraph, Graph &theSubGraph, ID &vertexTags, ID &vertexRefs, ID &theSubdomainMap)
366{
367 // for each vertex in the SubGraph we see if a vertex exists in the Graph which has the same
368 // reference tag (Reference tag in the AnalysisModel graph is the node tag) .. if so this will be
369 // the new vertex tag for SubGraph vertex in new graph, otherwise we assign it some new vertex tag,
370 // create a vertex for this new vertex tag & add it to the graph
371
372 Vertex *subVertexPtr;
373 VertexIter &theSubGraphIter1 = theSubGraph.getVertices();
374 int count =0;
375 int numVertex = theGraph.getNumVertex();
376 int numVertexSub = theSubGraph.getNumVertex();
377
378 while ((subVertexPtr = theSubGraphIter1()) != 0) {
379 int vertexTagSub = subVertexPtr->getTag();
380 int vertexTagRef = subVertexPtr->getRef();
381 int loc = vertexRefs.getLocation(vertexTagRef);
382
383 int vertexTagMerged;
384 if (loc < 0) {
385 // if not already in, we will be creating a new vertex
386 vertexTagMerged = theGraph.getFreeTag();
387 vertexTags[numVertex] = vertexTagMerged;
388 vertexRefs[numVertex] = vertexTagRef;
389 Vertex *newVertex = new Vertex(vertexTagMerged, vertexTagRef, subVertexPtr->getWeight(), subVertexPtr->getColor());
390
391 theGraph.addVertex(newVertex);
392 numVertex++;
393 } else
394 vertexTagMerged = vertexTags[loc];
395
396 // use the subgraphs ID to hold the mapping of vertex numbers between merged and original
397 theSubdomainMap[count] = vertexTagSub;
398 theSubdomainMap[count+numVertexSub] = vertexTagMerged;
399 count++;
400 }
401
402 // for each vertex in subgraph, we add it's adjacenecy into the merged graph
403 VertexIter &theSubGraphIter2 = theSubGraph.getVertices();
404 while ((subVertexPtr = theSubGraphIter2()) != 0) {
405 int vertexTagSub = subVertexPtr->getTag();
406 int loc = theSubdomainMap.getLocation(vertexTagSub);
407 int vertexTagMerged = theSubdomainMap[loc+numVertexSub];
408
409 const ID &adjacency = subVertexPtr->getAdjacency();
410
411 for (int i=0; i<adjacency.Size(); i++) {
412 int vertexTagSubAdjacent = adjacency(i);
413 int loc = theSubdomainMap.getLocation(vertexTagSubAdjacent);
414 int vertexTagMergedAdjacent = theSubdomainMap[loc+numVertexSub];
415 theGraph.addEdge(vertexTagMerged, vertexTagMergedAdjacent);
416 }
417 }
418
419
420 return 0;
421}

Callers 1

numberDOFMethod · 0.95

Calls 10

getNumVertexMethod · 0.45
getTagMethod · 0.45
getRefMethod · 0.45
getLocationMethod · 0.45
getFreeTagMethod · 0.45
getWeightMethod · 0.45
getColorMethod · 0.45
addVertexMethod · 0.45
SizeMethod · 0.45
addEdgeMethod · 0.45

Tested by

no test coverage detected