blockMesh: Added block face orientation checks to aid debugging

Individual inward-pointing faces are checked and if all faces are
inward-pointing the block is inside-out.  These errors are fatal and the
message indicates which block the error occurs in and where in the
blockMeshDict the block is defined.
This commit is contained in:
Henry Weller
2016-09-19 07:52:42 +01:00
parent fd2ac09c4e
commit 3aa78f2bf3
2 changed files with 65 additions and 3 deletions

View File

@ -23,9 +23,66 @@ License
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "blockDescriptor.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::blockDescriptor::check(const Istream& is)
{
const point blockCentre(blockShape_.centre(blockPointField_));
const faceList faces(blockShape_.faces());
// Check each face is outward-pointing with respect to the block centre
label outwardFaceCount = 0;
boolList correctFaces(faces.size(), true);
forAll(faces, i)
{
point faceCentre(faces[i].centre(blockPointField_));
vector faceNormal(faces[i].normal(blockPointField_));
if (mag(faceNormal) > SMALL)
{
if (((faceCentre - blockCentre) & faceNormal) > 0)
{
outwardFaceCount++;
}
else
{
correctFaces[i] = false;
}
}
else
{
outwardFaceCount++;
}
}
// If all faces are inward-pointing the block is inside-out
if (outwardFaceCount == 0)
{
FatalIOErrorInFunction(is)
<< "Block " << *this << " is inside-out"
<< exit(FatalIOError);
}
else if (outwardFaceCount != faces.size())
{
FatalIOErrorInFunction(is)
<< "Block " << *this << " has inward-pointing faces"
<< nl << " ";
forAll(correctFaces, i)
{
if (!correctFaces[i])
{
FatalIOError<< faces[i] << token::SPACE;
}
}
FatalIOError << exit(FatalIOError);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::blockDescriptor::blockDescriptor
@ -156,11 +213,13 @@ Foam::blockDescriptor::blockDescriptor
}
else
{
FatalErrorInFunction
FatalIOErrorInFunction(is)
<< "Unknown definition of expansion ratios: " << expRatios
<< exit(FatalError);
<< exit(FatalIOError);
}
check(is);
// Create a list of edges
makeBlockEdges();
}

View File

@ -90,6 +90,9 @@ class blockDescriptor
// Private Member Functions
//- Check block has outward-pointing faces
void check(const Istream& is);
//- Set the points/weights for all edges
void makeBlockEdges();