ENH: snappyHexMesh: parallel consistency. Fixes #2331.

This commit is contained in:
mattijs
2022-01-19 14:23:09 +00:00
parent 2e81c80527
commit 62982ffad6
4 changed files with 80 additions and 7 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd.
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -129,6 +129,57 @@ static const Foam::polyMesh::cellDecomposition
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::label Foam::meshRefinement::globalFaceCount(const labelList& elems) const
{
//- Check for duplicates
const bitSet isElem(mesh_.nFaces(), elems);
if (label(isElem.count()) != elems.size())
{
FatalErrorInFunction << "Problem Duplicates:"
<< " isElem:" << isElem.count()
<< " elems:" << elems.size()
<< exit(FatalError);
}
//- Check for same entries on coupled faces
{
bitSet isElem2(isElem);
syncTools::swapFaceList(mesh_, isElem2);
for
(
label facei = mesh_.nInternalFaces();
facei < mesh_.nFaces();
facei++
)
{
if (isElem2[facei] != isElem[facei])
{
FatalErrorInFunction
<< "at face:" << facei
<< " at:" << mesh_.faceCentres()[facei]
<< " patch:" << mesh_.boundaryMesh().whichPatch(facei)
<< " isElem:" << isElem[facei]
<< " isElem2:" << isElem2[facei]
<< exit(FatalError);
}
}
}
//- Count number of master elements
const bitSet isMaster(syncTools::getMasterFaces(mesh_));
label count = 0;
for (const label i : isElem)
{
if (isMaster[i])
{
count++;
}
}
return returnReduce(count, sumOp<label>());
}
void Foam::meshRefinement::calcNeighbourData
(
labelList& neiLevel,

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd.
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -229,6 +229,10 @@ private:
const labelList& oldCellsToRefine
);
// Debug: count number of master-faces (and do some checking
// for consistency)
label globalFaceCount(const labelList& elems) const;
//- Calculate coupled boundary end vector and refinement level
void calcNeighbourData(labelList& neiLevel, pointField& neiCc) const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd.
Copyright (C) 2015-2020,2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -1423,6 +1423,14 @@ Foam::label Foam::meshRefinement::markInternalGapRefinement
// Spread it
if (spreadGapSize)
{
scalarField boundaryGapSize;
syncTools::swapBoundaryCellList
(
mesh_,
detectedGapSize,
boundaryGapSize
);
// Field on cells and faces
List<transportData> cellData(mesh_.nCells());
List<transportData> faceData(mesh_.nFaces());
@ -1466,7 +1474,13 @@ Foam::label Foam::meshRefinement::markInternalGapRefinement
{
label own = mesh_.faceOwner()[faceI];
if (detectedGapSize[own] < GREAT)
scalar minSize = min
(
detectedGapSize[own],
boundaryGapSize[faceI-mesh_.nInternalFaces()]
);
if (minSize < GREAT)
{
frontFaces.append(faceI);
frontData.append
@ -1474,7 +1488,7 @@ Foam::label Foam::meshRefinement::markInternalGapRefinement
transportData
(
faceCentres[faceI],
detectedGapSize[own],
minSize,
0.0
)
);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd.
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -914,6 +914,9 @@ Foam::labelList Foam::meshRefinement::getRefineCandidateFaces
const labelList& surfIndex = surfaceIndex();
labelList boundaryRefineCell;
syncTools::swapBoundaryCellList(mesh_, refineCell, boundaryRefineCell);
forAll(surfIndex, faceI)
{
if (surfIndex[faceI] != -1)
@ -931,7 +934,8 @@ Foam::labelList Foam::meshRefinement::getRefineCandidateFaces
}
else
{
if (refineCell[own] == -1)
const label bFacei = faceI - mesh_.nInternalFaces();
if (refineCell[own] == -1 || boundaryRefineCell[bFacei] == -1)
{
testFaces[nTest++] = faceI;
}