45 static const int faceEdgeDirs[6][4] =
61 for(
int facePi=0; facePi<6; facePi++)
63 for(
int faceNi=0; faceNi<6; faceNi++)
65 for(
int rot=0; rot<4; rot++)
67 Pair<int>& map = faceFaceRotMap[facePi][faceNi][rot];
69 for(
int Pp=0; Pp<2; Pp++)
71 int Pdir = faceEdgeDirs[facePi][Pp];
72 int Np = (3 - Pp + rot)%4;
73 int Ndir = faceEdgeDirs[faceNi][Np];
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])
102 return faceFaceRotMap[facePi][faceNi][rot];
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);
326 const pointField& topoPoints = topology().points();
327 const cellList& topoCells = topology().cells();
328 const faceList& topoFaces = topology().faces();
329 const labelList& topoFaceOwn = topology().faceOwner();
330 const labelList& topoFaceNei = topology().faceNeighbour();
338 topology().nInternalFaces()
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();
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));
426 scalar maxSqrDist = 0;
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]
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.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
label facePointN(const block &block, const label i, const label j, const label k)
errorManipArg< error, int > exit(error &err, const int errNo=1)
A face is a list of labels corresponding to mesh vertices.
const Vector< label > & density() const
Return the mesh density (number of cells) in the i,j,k directions.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void size(const label)
Override size to be inconsistent with allocated storage.
label unsignIndex(const label i, const label ni)
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Holds information (coordinate and normal) regarding nearest wall point.
A bounding box defined in terms of the points at its extremities.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
A List obtained as a section of another List.
An ordered pair of two objects of type <T> with first() and second() elements.
label signIndex(const int map, const label i)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
Pair< label > faceNij(const label facei, const block &block)
label mapij(const int map, const label i, const label j)
dimensioned< scalar > magSqr(const dimensioned< Type > &)
label facePoint(const int facei, const block &block, const label i, const label j)
const Type & second() const
Return second.
label size() const
Return the number of elements in the UPtrList.
Ostream & flush(Ostream &os)
Flush stream.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
vector span() const
The bounding box span (from minimum to maximum)
label pointLabel(const label i, const label j, const label k) const
Vertex label offset for a particular i,j,k position.
dimensioned< scalar > mag(const dimensioned< Type > &)
const doubleScalar e
Elementary charge.
label size() const
Return the number of elements in the UList.
const Type & first() const
Return first.
void setBlockFaceCorrespondence(const cellList &topoCells, const faceList::subList &topoInternalFaces, const labelList &topoFaceCell, List< Pair< label >> &mergeBlock)