diff --git a/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C b/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C index 1bdb4a82d7ddc8af0b99449d6fb1be7a277550bc..f8f148756dd03dbc2e1f134b71068abec59d9b22 100644 --- a/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C +++ b/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C @@ -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(); } diff --git a/src/mesh/blockMesh/blockDescriptor/blockDescriptor.H b/src/mesh/blockMesh/blockDescriptor/blockDescriptor.H index c245eefccc9f601ae1af43031c9415befc0d3f62..37bba39bba9883e54870911d8225daef5d14df2c 100644 --- a/src/mesh/blockMesh/blockDescriptor/blockDescriptor.H +++ b/src/mesh/blockMesh/blockDescriptor/blockDescriptor.H @@ -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();