Commit 3aa78f2b authored by Henry Weller's avatar Henry Weller
Browse files

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.
parent fd2ac09c
......@@ -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();
}
......
......@@ -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();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment