30 void Foam::blockMesh::calcMergeInfo()
36 Info<<
"Creating block offsets" <<
endl;
39 blockOffsets_.
setSize(blocks.size());
46 blockOffsets_[blocki] = nPoints_;
48 nPoints_ += blocks[blocki].nPoints();
49 nCells_ += blocks[blocki].nCells();
59 mergeList_.
setSize(nPoints_, -1);
72 forAll(blockFaces, blockFaceLabel)
74 label blockPlabel = faceOwnerBlocks[blockFaceLabel];
75 const pointField& blockPpoints = blocks[blockPlabel].points();
76 const labelList& blockPfaces = blockCells[blockPlabel];
78 bool foundFace =
false;
79 label blockPfaceLabel;
83 blockPfaceLabel < blockPfaces.size();
87 if (blockPfaces[blockPfaceLabel] == blockFaceLabel)
97 <<
"Cannot find merge face for block " << blockPlabel
101 const List<FixedList<label, 4>>& blockPfaceFaces =
102 blocks[blockPlabel].boundaryPatches()[blockPfaceLabel];
105 curPairs.
setSize(blockPfaceFaces.size());
116 blockCells[blockPlabel].
points(blockFaces, blockPoints)
118 const scalar mergeSqrDist =
magSqr(50*small*bb.span());
122 scalar sqrMergeTol = great;
124 forAll(blockPfaceFaces, blockPfaceFaceLabel)
126 const FixedList<label, 4>& blockPfaceFacePoints
127 = blockPfaceFaces[blockPfaceFaceLabel];
129 forAll(blockPfaceFacePoints, blockPfaceFacePointLabel)
131 forAll(blockPfaceFacePoints, blockPfaceFacePointLabel2)
133 if (blockPfaceFacePointLabel != blockPfaceFacePointLabel2)
135 scalar magSqrDist =
magSqr 137 blockPpoints[blockPfaceFacePoints
138 [blockPfaceFacePointLabel]]
139 - blockPpoints[blockPfaceFacePoints
140 [blockPfaceFacePointLabel2]]
143 if (magSqrDist < mergeSqrDist)
146 blockPfaceFacePoints[blockPfaceFacePointLabel]
147 + blockOffsets_[blockPlabel];
150 blockPfaceFacePoints[blockPfaceFacePointLabel2]
151 + blockOffsets_[blockPlabel];
153 label minPP2 =
min(PpointLabel, PpointLabel2);
155 if (mergeList_[PpointLabel] != -1)
157 minPP2 =
min(minPP2, mergeList_[PpointLabel]);
160 if (mergeList_[PpointLabel2] != -1)
162 minPP2 =
min(minPP2, mergeList_[PpointLabel2]);
165 mergeList_[PpointLabel] = mergeList_[PpointLabel2]
170 sqrMergeTol =
min(sqrMergeTol, magSqrDist);
180 if (
topology().isInternalFace(blockFaceLabel))
182 label blockNlabel = faceNeighbourBlocks[blockFaceLabel];
183 const pointField& blockNpoints = blocks[blockNlabel].points();
184 const labelList& blockNfaces = blockCells[blockNlabel];
187 label blockNfaceLabel;
191 blockNfaceLabel < blockNfaces.size();
197 blockFaces[blockNfaces[blockNfaceLabel]]
198 == blockFaces[blockFaceLabel]
209 <<
"Cannot find merge face for block " << blockNlabel
213 const List<FixedList<label, 4>>& blockNfaceFaces =
214 blocks[blockNlabel].boundaryPatches()[blockNfaceLabel];
218 checkFaceCorrespondence_
219 && blockPfaceFaces.size() != blockNfaceFaces.size()
223 <<
"Inconsistent number of faces between block pair " 224 << blockPlabel <<
" and " << blockNlabel
231 forAll(blockPfaceFaces, blockPfaceFaceLabel)
233 const FixedList<label, 4>& blockPfaceFacePoints
234 = blockPfaceFaces[blockPfaceFaceLabel];
236 labelList& cp = curPairs[blockPfaceFaceLabel];
237 cp.
setSize(blockPfaceFacePoints.size());
240 forAll(blockPfaceFacePoints, blockPfaceFacePointLabel)
242 forAll(blockNfaceFaces, blockNfaceFaceLabel)
244 const FixedList<label, 4>& blockNfaceFacePoints
245 = blockNfaceFaces[blockNfaceFaceLabel];
247 forAll(blockNfaceFacePoints, blockNfaceFacePointLabel)
254 [blockPfaceFacePoints[blockPfaceFacePointLabel]]
256 [blockNfaceFacePoints[blockNfaceFacePointLabel]]
262 cp[blockPfaceFacePointLabel] =
263 blockNfaceFacePoints[blockNfaceFacePointLabel];
266 blockPfaceFacePoints[blockPfaceFacePointLabel]
267 + blockOffsets_[blockPlabel];
270 blockNfaceFacePoints[blockNfaceFacePointLabel]
271 + blockOffsets_[blockNlabel];
273 label minPN =
min(PpointLabel, NpointLabel);
275 if (mergeList_[PpointLabel] != -1)
277 minPN =
min(minPN, mergeList_[PpointLabel]);
280 if (mergeList_[NpointLabel] != -1)
282 minPN =
min(minPN, mergeList_[NpointLabel]);
285 mergeList_[PpointLabel] = mergeList_[NpointLabel]
291 forAll(blockPfaceFacePoints, blockPfaceFacePointLabel)
293 if (cp[blockPfaceFacePointLabel] == -1)
296 <<
"Inconsistent point locations between block pair " 297 << blockPlabel <<
" and " << blockNlabel <<
nl 298 <<
" probably due to inconsistent grading." 313 bool changedPointMerge =
false;
318 changedPointMerge =
false;
321 forAll(blockinternalFaces, blockFaceLabel)
323 label blockPlabel = faceOwnerBlocks[blockFaceLabel];
324 label blockNlabel = faceNeighbourBlocks[blockFaceLabel];
326 const labelList& blockPfaces = blockCells[blockPlabel];
327 const labelList& blockNfaces = blockCells[blockNlabel];
329 const labelListList& curPairs = glueMergePairs[blockFaceLabel];
331 label blockPfaceLabel;
335 blockPfaceLabel < blockPfaces.size();
341 blockFaces[blockPfaces[blockPfaceLabel]]
342 == blockinternalFaces[blockFaceLabel]
350 label blockNfaceLabel;
354 blockNfaceLabel < blockNfaces.size();
360 blockFaces[blockNfaces[blockNfaceLabel]]
361 == blockinternalFaces[blockFaceLabel]
369 const List<FixedList<label, 4>>& blockPfaceFaces =
370 blocks[blockPlabel].boundaryPatches()[blockPfaceLabel];
372 forAll(blockPfaceFaces, blockPfaceFaceLabel)
374 const FixedList<label, 4>& blockPfaceFacePoints
375 = blockPfaceFaces[blockPfaceFaceLabel];
377 const labelList& cp = curPairs[blockPfaceFaceLabel];
379 forAll(blockPfaceFacePoints, blockPfaceFacePointLabel)
382 blockPfaceFacePoints[blockPfaceFacePointLabel]
383 + blockOffsets_[blockPlabel];
386 cp[blockPfaceFacePointLabel]
387 + blockOffsets_[blockNlabel];
391 mergeList_[PpointLabel]
392 != mergeList_[NpointLabel]
395 changedPointMerge =
true;
397 mergeList_[PpointLabel]
398 = mergeList_[NpointLabel]
401 mergeList_[PpointLabel],
402 mergeList_[NpointLabel]
416 <<
"Point merging failed after max number of passes." 420 while (changedPointMerge);
427 forAll(blockinternalFaces, blockFaceLabel)
429 label blockPlabel = faceOwnerBlocks[blockFaceLabel];
430 label blockNlabel = faceNeighbourBlocks[blockFaceLabel];
432 const labelList& blockPfaces = blockCells[blockPlabel];
433 const labelList& blockNfaces = blockCells[blockNlabel];
435 const pointField& blockPpoints = blocks[blockPlabel].points();
436 const pointField& blockNpoints = blocks[blockNlabel].points();
438 bool foundFace =
false;
439 label blockPfaceLabel;
443 blockPfaceLabel < blockPfaces.size();
449 blockFaces[blockPfaces[blockPfaceLabel]]
450 == blockinternalFaces[blockFaceLabel]
461 <<
"Cannot find merge face for block " << blockPlabel
466 label blockNfaceLabel;
470 blockNfaceLabel < blockNfaces.size();
476 blockFaces[blockNfaces[blockNfaceLabel]]
477 == blockinternalFaces[blockFaceLabel]
488 <<
"Cannot find merge face for block " << blockNlabel
492 const List<FixedList<label, 4>>& blockPfaceFaces =
493 blocks[blockPlabel].boundaryPatches()[blockPfaceLabel];
495 const List<FixedList<label, 4>>& blockNfaceFaces =
496 blocks[blockNlabel].boundaryPatches()[blockNfaceLabel];
498 forAll(blockPfaceFaces, blockPfaceFaceLabel)
500 const FixedList<label, 4>& blockPfaceFacePoints
501 = blockPfaceFaces[blockPfaceFaceLabel];
503 forAll(blockPfaceFacePoints, blockPfaceFacePointLabel)
506 blockPfaceFacePoints[blockPfaceFacePointLabel]
507 + blockOffsets_[blockPlabel];
509 if (mergeList_[PpointLabel] == -1)
512 <<
"Unable to merge point " 513 << blockPfaceFacePointLabel
514 <<
' ' << blockPpoints[blockPfaceFacePointLabel]
524 forAll(blockNfaceFaces, blockNfaceFaceLabel)
526 const FixedList<label, 4>& blockNfaceFacePoints
527 = blockNfaceFaces[blockNfaceFaceLabel];
529 forAll(blockNfaceFacePoints, blockNfaceFacePointLabel)
532 blockNfaceFacePoints[blockNfaceFacePointLabel]
533 + blockOffsets_[blockNlabel];
535 if (mergeList_[NpointLabel] == -1)
538 <<
"unable to merge point " 539 << blockNfaceFacePointLabel
540 <<
' ' << blockNpoints[blockNfaceFacePointLabel]
553 label nUniqPoints = 0;
555 forAll(mergeList_, pointi)
557 if (mergeList_[pointi] > pointi)
560 <<
"Merge list contains point index out of range" 564 if (mergeList_[pointi] == -1 || mergeList_[pointi] == pointi)
566 mergeList_[pointi] = nUniqPoints++;
570 mergeList_[pointi] = mergeList_[mergeList_[pointi]];
574 nPoints_ = nUniqPoints;
List< labelList > labelListList
A List of labelList.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual const labelList & faceNeighbour() const
Return face neighbour.
PtrList< block > blockList
A PtrList of blocks.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const cellList & cells() const
SubList< face > subList
Declare type of subList.
virtual const pointField & points() const
Return raw points.
vectorField pointField
pointField is a vectorField.
const polyMesh & topology() const
Return the blockMesh topology as a polyMesh.
virtual const labelList & faceOwner() const
Return face owner.
List< label > labelList
A List of labels.
virtual const faceList & faces() const
Return raw faces.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
void setSize(const label)
Reset size of List.
Ostream & flush(Ostream &os)
Flush stream.
List< labelListList > labelListListList
A List of labelListList.
const pointField & points() const
The points for the entire mesh.
List< cell > cellList
list of cells