35 void starMesh::mergeCoupleFacePoints()
57 labelList renumberPoints(points_.size(), -1);
60 label mergeIncrement = points_.
size()/10;
67 const faceList& curFaces = cellFaces_[cellI];
72 label nPointsInCell = 0;
74 scalar pointMergeTol = GREAT;
78 nPointsInCell += curFaces[faceI].
size();
80 edgeList curEdges = curFaces[faceI].edges();
84 scalar length = curEdges[edgeI].mag(points_);
86 if (length < pointMergeTol)
88 pointMergeTol = length;
94 pointMergeTol /= 100.0;
98 label nAddedPoints = 0;
102 const face&
f = curFaces[faceI];
106 cellPoints[nAddedPoints] = f[fI];
112 for (label firstPI = 0; firstPI < cellPoints.size() - 1; firstPI++)
116 label otherPI = firstPI;
117 otherPI < cellPoints.size();
121 if (cellPoints[firstPI] != cellPoints[otherPI])
123 label a = cellPoints[firstPI];
124 label
b = cellPoints[otherPI];
126 if (
edge (a, b).
mag(points_) < pointMergeTol)
130 Info<<
"Merging points " << a <<
" and " << b <<
endl;
134 label mergeSetA = -1;
135 label mergeSetB = -1;
137 if (renumberPoints[a] > -1)
139 mergeSetA = renumberPoints[a];
142 if (renumberPoints[b] > -1)
144 mergeSetB = renumberPoints[
b];
147 if (mergeSetA == -1 && mergeSetB == -1)
151 Info<<
"adding new merge group " << nMergeSets
156 renumberPoints[a] = nMergeSets;
157 renumberPoints[
b] = nMergeSets;
159 mergeSetID[nMergeSets] =
min(a, b);
162 if (nMergeSets >= mergeSetID.size())
164 Info <<
"Resizing mergeSetID" <<
endl;
167 (mergeSetID.size() + mergeIncrement);
170 else if (mergeSetA == -1 && mergeSetB != -1)
173 Info<<
"adding point a into the merge set of b. "
174 <<
"a: " << a <<
endl;
178 renumberPoints[a] = mergeSetB;
181 mergeSetID[mergeSetB] =
182 min(a, mergeSetID[mergeSetB]);
184 else if (mergeSetA != -1 && mergeSetB == -1)
187 Info<<
"adding point b into the merge set of a. "
188 <<
"b: " << b <<
endl;
192 renumberPoints[
b] = mergeSetA;
195 mergeSetID[mergeSetA] =
196 min(b, mergeSetID[mergeSetA]);
198 else if (mergeSetA != mergeSetB)
202 label minMerge =
min(mergeSetA, mergeSetB);
203 label maxMerge =
max(mergeSetA, mergeSetB);
206 Info<<
"Points already belong to two "
207 <<
"different merge sets. "
208 <<
"Eliminate the higher merge set. Sets: "
209 << minMerge <<
" and " << maxMerge <<
endl;
212 forAll (renumberPoints, elimI)
214 if (renumberPoints[elimI] == maxMerge)
216 renumberPoints[elimI] = minMerge;
221 mergeSetID[minMerge] =
222 min(mergeSetID[minMerge], mergeSetID[maxMerge]);
230 mergeSetID.setSize(nMergeSets);
232 Info<<
"Finished creating merge sets. Number of merge sets: "
233 << nMergeSets <<
"." <<
endl;
237 forAll (renumberPoints, pointI)
239 if (renumberPoints[pointI] < 0)
242 renumberPoints[pointI] = pointI;
246 renumberPoints[pointI] = mergeSetID[renumberPoints[pointI]];
255 forAll (cellFaces_, cellI)
257 faceList& prelimFaces = cellFaces_[cellI];
259 forAll (prelimFaces, faceI)
261 face oldFacePoints = prelimFaces[faceI];
263 face& prelimFacePoints = prelimFaces[faceI];
265 forAll (prelimFacePoints, pointI)
267 if (renumberPoints[oldFacePoints[pointI]] < 0)
270 <<
"Error in point renumbering. Old face: "
271 << oldFacePoints << endl
272 <<
"prelim face: " << prelimFacePoints
276 prelimFacePoints[pointI] =
277 renumberPoints[oldFacePoints[pointI]];
286 forAll (cellFaces_, cellI)
288 const faceList& curFaces = cellFaces_[cellI];
292 const face& curFacePoints = curFaces[faceI];
294 forAll (curFacePoints, pointI)
296 renumberPoints[curFacePoints[pointI]]++;
301 forAll (cellShapes_, cellI)
303 const labelList& curLabels = cellShapes_[cellI];
305 forAll (curLabels, pointI)
307 if (renumberPoints[curLabels[pointI]] == 0)
310 <<
"Error in point merging for cell "
311 << cellI <<
". STAR index: " << starCellID_[cellI]
313 <<
"Point index: " << curLabels[pointI] <<
" STAR index "
314 << starPointID_[curLabels[pointI]] << endl
315 <<
"Please check the geometry for the cell." <<
endl;
320 label nUsedPoints = 0;
322 forAll (renumberPoints, pointI)
324 if (renumberPoints[pointI] > 0)
330 renumberPoints[pointI] = nUsedPoints;
331 points_[nUsedPoints] = points_[pointI];
337 renumberPoints[pointI] = -1;
341 Info<<
"Total number of points: " << points_.size() << endl
342 <<
"Number of used points: " << nUsedPoints <<
endl;
345 points_.setSize(nUsedPoints);
347 Info <<
"Renumbering all faces" <<
endl;
349 forAll (cellFaces_, cellI)
351 faceList& newFaces = cellFaces_[cellI];
355 face oldFacePoints = newFaces[faceI];
357 face& newFacePoints = newFaces[faceI];
359 forAll (newFacePoints, pointI)
361 if (renumberPoints[oldFacePoints[pointI]] < 0)
364 <<
"Error in point renumbering for point "
365 << oldFacePoints[pointI]
366 <<
". Renumbering index is -1." << endl
367 <<
"Old face: " << oldFacePoints << endl
371 newFacePoints[pointI] = renumberPoints[oldFacePoints[pointI]];
376 Info <<
"Renumbering all cell shapes" <<
endl;
378 forAll (cellShapes_, cellI)
380 labelList oldLabels = cellShapes_[cellI];
382 labelList& curLabels = cellShapes_[cellI];
384 forAll (curLabels, pointI)
386 if (renumberPoints[curLabels[pointI]] < 0)
389 <<
"Error in point renumbering for cell "
390 << cellI <<
". STAR index: " << starCellID_[cellI]
392 <<
"Point index: " << curLabels[pointI] <<
" STAR index "
393 << starPointID_[curLabels[pointI]] <<
" returns invalid "
394 <<
"renumbering index: "
395 << renumberPoints[curLabels[pointI]] <<
"." << endl
396 <<
"Old cellShape: " << oldLabels << endl
400 curLabels[pointI] = renumberPoints[oldLabels[pointI]];
404 Info <<
"Renumbering STAR point lookup" <<
endl;
410 forAll (starPointID_, pointI)
412 if (renumberPoints[pointI] > -1)
414 starPointID_[renumberPoints[pointI]] = oldStarPointID[pointI];