/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see .
\*---------------------------------------------------------------------------*/
#include "polyMesh.H"
#include "polyMeshTools.H"
#include "unitConversion.H"
#include "syncTools.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::polyMesh::checkFaceOrthogonality
(
const vectorField& fAreas,
const vectorField& cellCtrs,
const bool report,
const bool detailedReport,
labelHashSet* setPtr
) const
{
if (debug)
{
Info<< "bool polyMesh::checkFaceOrthogonality("
<< "const bool, labelHashSet*) const: "
<< "checking mesh non-orthogonality" << endl;
}
const labelList& own = faceOwner();
const labelList& nei = faceNeighbour();
// Calculate orthogonality for all internal and coupled boundary faces
// (1 for uncoupled boundary faces)
tmp tortho = polyMeshTools::faceOrthogonality
(
*this,
fAreas,
cellCtrs
);
const scalarField& ortho = tortho();
// Severe nonorthogonality threshold
const scalar severeNonorthogonalityThreshold =
::cos(degToRad(primitiveMesh::nonOrthThreshold_));
scalar minDDotS = GREAT;
scalar sumDDotS = 0.0;
label nSummed = 0;
label severeNonOrth = 0;
label errorNonOrth = 0;
// Statistics only for internal and masters of coupled faces
PackedBoolList isMasterFace(syncTools::getInternalOrMasterFaces(*this));
forAll(ortho, faceI)
{
if (ortho[faceI] < severeNonorthogonalityThreshold)
{
if (ortho[faceI] > SMALL)
{
if (setPtr)
{
setPtr->insert(faceI);
}
severeNonOrth++;
}
else
{
// Error : non-ortho too large
if (setPtr)
{
setPtr->insert(faceI);
}
if (detailedReport && errorNonOrth == 0)
{
// Non-orthogonality greater than 90 deg
WarningIn
(
"polyMesh::checkFaceOrthogonality"
"(const pointField&, const bool) const"
) << "Severe non-orthogonality for face "
<< faceI
<< " between cells " << own[faceI]
<< " and " << nei[faceI]
<< ": Angle = " << radToDeg(::acos(ortho[faceI]))
<< " deg." << endl;
}
errorNonOrth++;
}
}
if (isMasterFace[faceI])
{
minDDotS = min(minDDotS, ortho[faceI]);
sumDDotS += ortho[faceI];
nSummed++;
}
}
reduce(minDDotS, minOp());
reduce(sumDDotS, sumOp());
reduce(nSummed, sumOp