MCPcopy Create free account
hub / github.com/OpenFOAM/OpenFOAM-dev / fixWeights

Function fixWeights

applications/test/router/router.C:74–187  ·  view source on GitHub ↗

Mark shortest path from endNode to startNode by setting the weights to 0.

Source from the content-addressed store, hash-verified

72// Mark shortest path from endNode to startNode by setting the weights
73// to 0.
74void Foam::router::fixWeights
75(
76 const label startNodeI,
77 const label endNodeI,
78
79 const label nodeI,
80 const label prevNodeI
81)
82{
83 // Mark this node
84 weights_[nodeI] = 0;
85
86 label minNodeI = -1;
87 label minDist = labelMax;
88 label nMinNodes = 0;
89
90 const labelList& myNeighbours = connections_[nodeI];
91
92 forAll(myNeighbours, neighbourI)
93 {
94 label nbrNodeI = myNeighbours[neighbourI];
95
96 if (nbrNodeI != prevNodeI)
97 {
98 if (weights_[nbrNodeI] == 0)
99 {
100 // Reached end
101 minDist = 0;
102 break;
103 }
104 else if (weights_[nbrNodeI] > 0)
105 {
106 if (weights_[nbrNodeI] < minDist)
107 {
108 minDist = weights_[nbrNodeI];
109 minNodeI = nbrNodeI;
110 nMinNodes = 1;
111 }
112 else if (weights_[nbrNodeI] == minDist)
113 {
114 nMinNodes++;
115 }
116 }
117 }
118 }
119
120 if (minDist == 0)
121 {
122 // Reached starting point.
123 return;
124 }
125
126 if (minNodeI == -1)
127 {
128 WarningInFunction
129 << "Cannot route from node " << nodeI
130 << " since all neigbours of node "
131 << "already allocated:" << endl;

Callers 1

routeFunction · 0.85

Calls 2

forAllFunction · 0.50
magClass · 0.50

Tested by

no test coverage detected