61 for(
int facePi=0; facePi<6; facePi++)
63 for(
int faceNi=0; faceNi<6; faceNi++)
65 for(
int rot=0; rot<4; rot++)
69 for(
int Pp=0; Pp<2; Pp++)
72 int Np = (3 - Pp + rot)%4;
78 if (
mag(map[0]) == 2 && map[0]*map[1] < 0)
98 for(
int rot=0; rot<4; rot++)
100 if (faceN[rot] == faceP[0])
107 <<
"Cannot find point correspondence for faces "
108 << faceP <<
" and " << faceN
123 forAll(topoInternalFaces, topoFacei)
125 label topoPi = topoFaceCell[topoFacei];
126 const labelList& topoPfaces = topoCells[topoPi];
128 bool foundFace =
false;
133 topoPfacei < topoPfaces.
size();
137 if (topoPfaces[topoPfacei] == topoFacei)
147 <<
"Cannot find merge face for block " << topoPi
151 mergeBlock[topoFacei].first() = topoPi;
152 mergeBlock[topoFacei].second() = topoPfacei;
185 return map < 0 ? -i-1 : i;
191 return i >= 0 ? i : ni + i + 1;
291 void Foam::blockMesh::calcMergeInfoFast()
300 Info<<
"Creating block offsets" <<
endl;
303 blockOffsets_.setSize(blocks.size());
310 blockOffsets_[blocki] = nPoints_;
312 nPoints_ += blocks[blocki].nPoints();
313 nCells_ += blocks[blocki].nCells();
318 Info<<
"Creating merge list using the fast topological search"
323 mergeList_.
setSize(nPoints_, -1);
341 List<Pair<label>> mergeBlockP(topoInternalFaces.size());
350 List<Pair<label>> mergeBlockN(topoInternalFaces.size());
364 forAll(topoInternalFaces, topoFacei)
368 Info<<
"Processing face " << topoFacei <<
endl;
371 label blockPi = mergeBlockP[topoFacei].first();
372 label blockPfacei = mergeBlockP[topoFacei].second();
374 label blockNi = mergeBlockN[topoFacei].first();
375 label blockNfacei = mergeBlockN[topoFacei].second();
382 blocks[blockPi].blockShape().
faces()[blockPfacei],
384 blocks[blockNi].blockShape().
faces()[blockNfacei]
390 Info<<
" Face map for faces "
391 << blocks[blockPi].blockShape().faces()[blockPfacei] <<
" "
392 << blocks[blockNi].blockShape().faces()[blockNfacei] <<
": "
396 const pointField& blockPpoints = blocks[blockPi].points();
397 const pointField& blockNpoints = blocks[blockNi].points();
399 Pair<label> Pnij(
faceNij(blockPfacei, blocks[blockPi]));
403 Pair<label> Nnij(
faceNij(blockNfacei, blocks[blockNi]));
405 NPnij[0] = Nnij[
mag(fmap[0]) - 1];
406 NPnij[1] = Nnij[
mag(fmap[1]) - 1];
411 <<
"Sub-division mismatch between face "
412 << blockPfacei <<
" of block " << blockPi << Pnij
414 << blockNfacei <<
" of block " << blockNi << Nnij
422 const boundBox bb(topoCells[blockPi].
points(topoFaces, topoPoints));
423 const scalar testSqrDist =
magSqr(1
e-6*bb.span());
426 scalar maxSqrDist = 0;
428 for (
label j=0; j<Pnij.second(); j++)
430 for (
label i=0; i<Pnij.first(); i++)
433 facePoint(blockPfacei, blocks[blockPi], i, j);
436 facePointN(blockNfacei, fmap, blocks[blockNi], i, j);
442 blockPpoints[blockPpointi]
443 - blockNpoints[blockNpointi]
447 if (sqrDist > testSqrDist)
450 <<
"Point merge failure between face "
451 << blockPfacei <<
" of block " << blockPi
453 << blockNfacei <<
" of block " << blockNi
455 <<
" Points: " << blockPpoints[blockPpointi]
456 <<
" " << blockNpoints[blockNpointi]
458 <<
" This may be due to inconsistent grading."
462 maxSqrDist =
max(maxSqrDist, sqrDist);
464 label Ppointi = blockPpointi + blockOffsets_[blockPi];
465 label Npointi = blockNpointi + blockOffsets_[blockNi];
467 label minPNi =
min(Ppointi, Npointi);
469 if (mergeList_[Ppointi] != -1)
471 minPNi =
min(minPNi, mergeList_[Ppointi]);
474 if (mergeList_[Npointi] != -1)
476 minPNi =
min(minPNi, mergeList_[Npointi]);
479 mergeList_[Ppointi] = mergeList_[Npointi] = minPNi;
485 Info<<
" Max distance between merge points: "
491 bool changedPointMerge =
false;
496 changedPointMerge =
false;
499 forAll(topoInternalFaces, topoFacei)
501 label blockPi = mergeBlockP[topoFacei].first();
502 label blockPfacei = mergeBlockP[topoFacei].second();
504 label blockNi = mergeBlockN[topoFacei].first();
505 label blockNfacei = mergeBlockN[topoFacei].second();
512 blocks[blockPi].blockShape().
faces()[blockPfacei],
514 blocks[blockNi].blockShape().
faces()[blockNfacei]
518 Pair<label> Pnij(
faceNij(blockPfacei, blocks[blockPi]));
520 for (
label j=0; j<Pnij.second(); j++)
522 for (
label i=0; i<Pnij.first(); i++)
525 facePoint(blockPfacei, blocks[blockPi], i, j);
528 facePointN(blockNfacei, fmap, blocks[blockNi], i, j);
531 blockPpointi + blockOffsets_[blockPi];
534 blockNpointi + blockOffsets_[blockNi];
536 if (mergeList_[Ppointi] != mergeList_[Npointi])
538 changedPointMerge =
true;
541 = mergeList_[Npointi]
542 =
min(mergeList_[Ppointi], mergeList_[Npointi]);
556 <<
"Point merging failed after 100 passes."
560 }
while (changedPointMerge);
564 label nUniqPoints = 0;
566 forAll(mergeList_, pointi)
568 if (mergeList_[pointi] > pointi)
571 <<
"Merge list contains point index out of range"
575 if (mergeList_[pointi] == -1 || mergeList_[pointi] == pointi)
577 mergeList_[pointi] = nUniqPoints++;
581 mergeList_[pointi] = mergeList_[mergeList_[pointi]];
586 nPoints_ = nUniqPoints;
#define forAll(list, i)
Loop across all elements in list.
SubList< face > subList
Declare type of subList.
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
An ordered pair of two objects of type <T> with first() and second() elements.
const Type & second() const
Return second.
const Type & first() const
Return first.
A List obtained as a section of another List.
label pointLabel(const label i, const label j, const label k) const
Vertex label offset for a particular i,j,k position.
const Vector< label > & density() const
Return the mesh density (number of cells) in the i,j,k directions.
const polyMesh & topology() const
Return the blockMesh topology as a polyMesh.
const blockFaceList & faces() const
Return the curved faces.
const pointField & points() const
The points for the entire mesh.
Creates a single block of cells from point coordinates, numbers of cells in each direction and an exp...
A face is a list of labels corresponding to mesh vertices.
virtual const faceList & faces() const
Return raw faces.
virtual const labelList & faceOwner() const
Return face owner.
virtual const labelList & faceNeighbour() const
Return face neighbour.
virtual const pointField & points() const
Return raw points.
const cellList & cells() const
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
errorManipArg< error, int > exit(error &err, const int errNo=1)
static const int faceEdgeDirs[6][4]
label mapij(const int map, const label i, const label j)
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
List< cell > cellList
list of cells
Ostream & endl(Ostream &os)
Add newline and flush stream.
label facePointN(const block &block, const label i, const label j, const label k)
void setBlockFaceCorrespondence(const cellList &topoCells, const faceList::subList &topoInternalFaces, const labelList &topoFaceCell, List< Pair< label >> &mergeBlock)
vectorField pointField
pointField is a vectorField.
label facePoint(const int facei, const block &block, const label i, const label j)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
label unsignIndex(const label i, const label ni)
PtrList< block > blockList
A PtrList of blocks.
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< scalar > mag(const dimensioned< Type > &)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
label signIndex(const int map, const label i)
static Pair< int > faceFaceRotMap[6][6][4]
Pair< label > faceNij(const label facei, const block &block)
Ostream & flush(Ostream &os)
Flush stream.
dimensioned< scalar > magSqr(const dimensioned< Type > &)