mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: ideasUnvToFoam: handle reversed boundary faces.
This commit is contained in:
@ -844,16 +844,16 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
List<faceList> patchFaceVerts;
|
List<faceList> patchFaceVerts;
|
||||||
|
|
||||||
labelList nrFaceCells(boundaryFaces.size(),0);
|
labelList own(boundaryFaces.size(), -1);
|
||||||
HashTable<label,label> faceToCell[2];
|
labelList nei(boundaryFaces.size(), -1);
|
||||||
|
HashTable<label, label> faceToCell[2];
|
||||||
|
|
||||||
{
|
{
|
||||||
HashTable<label, face, Hash<face> > faceToFaceID(boundaryFaces.size());
|
HashTable<label, face, Hash<face> > faceToFaceID(boundaryFaces.size());
|
||||||
forAll(boundaryFaces, faceI)
|
forAll(boundaryFaces, faceI)
|
||||||
{
|
{
|
||||||
SortableList<label> foo(boundaryFaces[faceI]);
|
SortableList<label> sortedVerts(boundaryFaces[faceI]);
|
||||||
face theFace(foo);
|
faceToFaceID.insert(face(sortedVerts), faceI);
|
||||||
faceToFaceID.insert(theFace,faceI);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
forAll(cellVerts, cellI)
|
forAll(cellVerts, cellI)
|
||||||
@ -861,31 +861,57 @@ int main(int argc, char *argv[])
|
|||||||
faceList faces = cellVerts[cellI].faces();
|
faceList faces = cellVerts[cellI].faces();
|
||||||
forAll(faces, i)
|
forAll(faces, i)
|
||||||
{
|
{
|
||||||
SortableList<label> foo(faces[i]);
|
SortableList<label> sortedVerts(faces[i]);
|
||||||
face theFace(foo);
|
HashTable<label, face, Hash<face> >::const_iterator fnd =
|
||||||
if (faceToFaceID.found(theFace))
|
faceToFaceID.find(face(sortedVerts));
|
||||||
|
|
||||||
|
if (fnd != faceToFaceID.end())
|
||||||
{
|
{
|
||||||
label faceI = faceToFaceID[theFace];
|
label faceI = fnd();
|
||||||
if (nrFaceCells[faceI] < 2)
|
int stat = face::compare(faces[i], boundaryFaces[faceI]);
|
||||||
|
|
||||||
|
if (stat == 1)
|
||||||
{
|
{
|
||||||
faceToCell[nrFaceCells[faceI]].insert(faceI,cellI);
|
// Same orientation. Cell is owner.
|
||||||
|
own[faceI] = cellI;
|
||||||
|
}
|
||||||
|
else if (stat == -1)
|
||||||
|
{
|
||||||
|
// Opposite orientation. Cell is neighbour.
|
||||||
|
nei[faceI] = cellI;
|
||||||
}
|
}
|
||||||
nrFaceCells[faceI]++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
label cnt = 0;
|
label nReverse = 0;
|
||||||
forAll(nrFaceCells, faceI)
|
forAll(own, faceI)
|
||||||
{
|
{
|
||||||
assert(nrFaceCells[faceI] == 1 || nrFaceCells[faceI] == 2);
|
if (own[faceI] == -1 && nei[faceI] != -1)
|
||||||
if (nrFaceCells[faceI]>1)
|
{
|
||||||
|
// Boundary face with incorrect orientation
|
||||||
|
boundaryFaces[faceI] = boundaryFaces[faceI].reverseFace();
|
||||||
|
Swap(own[faceI], nei[faceI]);
|
||||||
|
nReverse++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nReverse > 0)
|
||||||
|
{
|
||||||
|
Info << "Found " << nReverse << " reversed boundary faces out of "
|
||||||
|
<< boundaryFaces.size() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
label cnt = 0;
|
||||||
|
forAll(own, faceI)
|
||||||
|
{
|
||||||
|
if (own[faceI] != -1 && nei[faceI] != -1)
|
||||||
{
|
{
|
||||||
cnt++;
|
cnt++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cnt>0)
|
if (cnt > 0)
|
||||||
{
|
{
|
||||||
Info << "Of " << boundaryFaces.size() << " so-called"
|
Info << "Of " << boundaryFaces.size() << " so-called"
|
||||||
<< " boundary faces " << cnt << " belong to two cells "
|
<< " boundary faces " << cnt << " belong to two cells "
|
||||||
@ -994,7 +1020,8 @@ int main(int argc, char *argv[])
|
|||||||
if (boundaryFaceToIndex.found(faceIndices[i]))
|
if (boundaryFaceToIndex.found(faceIndices[i]))
|
||||||
{
|
{
|
||||||
label bFaceI = boundaryFaceToIndex[faceIndices[i]];
|
label bFaceI = boundaryFaceToIndex[faceIndices[i]];
|
||||||
if (nrFaceCells[bFaceI] == 1)
|
|
||||||
|
if (own[bFaceI] != -1 && nei[bFaceI] == -1)
|
||||||
{
|
{
|
||||||
patchFaces[cnt] = boundaryFaces[bFaceI];
|
patchFaces[cnt] = boundaryFaces[bFaceI];
|
||||||
cnt++;
|
cnt++;
|
||||||
|
|||||||
Reference in New Issue
Block a user