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<scalarField> 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(min(1.0, max(-1.0, ortho[faceI])))) << " deg." << endl; } errorNonOrth++; } } if (isMasterFace[faceI]) { minDDotS = min(minDDotS, ortho[faceI]); sumDDotS += ortho[faceI]; nSummed++; } } reduce(minDDotS, minOp<scalar>()); reduce(sumDDotS, sumOp<scalar>()); reduce(nSummed, sumOp<label>()); reduce(severeNonOrth, sumOp<label>()); reduce(errorNonOrth, sumOp<label>()); if (debug || report) { if (nSummed > 0) { if (debug || report) { Info<< " Mesh non-orthogonality Max: " << radToDeg(::acos(min(1.0, max(-1.0, minDDotS)))) << " average: " << radToDeg(::acos(min(1.0, max(-1.0, sumDDotS/nSummed)))) << endl; } } if (severeNonOrth > 0) { Info<< " *Number of severely non-orthogonal (> " << primitiveMesh::nonOrthThreshold_ << " degrees) faces: " << severeNonOrth << "." << endl; } } if (errorNonOrth > 0) { if (debug || report) { Info<< " ***Number of non-orthogonality errors: " << errorNonOrth << "." << endl; } return true; } else { if (debug || report) { Info<< " Non-orthogonality check OK." << endl; } return false; } }
int main(int argc, char *argv[]) { /*#include "setRootCase.H" #include "createTime.H" #include "createMesh.H" #include "createFields.H" #include "createFvOptions.H"*/ timeSelector::addOptions(); #include "addRegionOption.H" //argList::validArgs.append("fieldName"); #include "setRootCase.H" #include "createTime.H" instantList timeDirs = timeSelector::select0(runTime, args); #include "createNamedMesh.H" #include "createFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // forAll(timeDirs, timeI) { runTime.setTime(timeDirs[timeI], timeI); Info<< "Time = " << runTime.timeName() << endl; mesh.readUpdate(); const vectorField& fAreas = mesh.faceAreas(); const vectorField& fCentres = mesh.faceCentres(); const vectorField& cCentres = mesh.cellCentres(); const primitiveMesh& meshh = mesh; const pointField& points = mesh.points(); // Start of non orthogonality calculation tmp<scalarField> tortho = primitiveMeshTools::faceOrthogonality ( meshh, fAreas, cCentres ); scalarField ortho = tortho(); scalarField orthogonality = ortho; forAll(ortho, faceI) { if (ortho[faceI] > 1) { ortho[faceI] = 1; } else if (ortho[faceI] < -1) { ortho[faceI] = -1; } orthogonality[faceI] = radToDeg(::acos(ortho[faceI])); } //Face set for highly non-orth faces faceSet nonOrthFaces(mesh, "nonOrthFaces", mesh.nFaces()/100); forAll(orthogonality, faceI) { label cellI = mesh.faceOwner()[faceI]; if (orthogonality[faceI] > nonOrth[cellI]) { nonOrth[cellI] = orthogonality[faceI]; } if(orthogonality[faceI] > 60) { nonOrthFaces.insert(faceI); } }