mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user