From a242a3787b474dccbe8f8c1b030e189cd56e6285 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 24 Aug 2011 08:58:48 +0100 Subject: [PATCH] ENH: checkMesh: added check for coupled point synchronisation --- .../manipulation/checkMesh/checkGeometry.C | 139 +++++++++++++++++- .../manipulation/checkMesh/checkGeometry.H | 4 + .../basic/coupled/coupledPolyPatch.H | 19 +-- 3 files changed, 152 insertions(+), 10 deletions(-) diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C index 82e0dedd82..9004ddade9 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C @@ -262,6 +262,125 @@ bool Foam::checkWedges } +bool Foam::checkCoupledPoints +( + const polyMesh& mesh, + const bool report, + labelHashSet* setPtr +) +{ + const pointField& p = mesh.points(); + const faceList& fcs = mesh.faces(); + const polyBoundaryMesh& patches = mesh.boundaryMesh(); + + // Zero'th point on coupled faces + pointField nbrZeroPoint(fcs.size()-mesh.nInternalFaces(), vector::max); + + // Exchange zero point + forAll(patches, patchI) + { + if (patches[patchI].coupled()) + { + const coupledPolyPatch& cpp = refCast + ( + patches[patchI] + ); + + forAll(cpp, i) + { + label bFaceI = cpp.start()+i-mesh.nInternalFaces(); + const point& p0 = p[cpp[i][0]]; + nbrZeroPoint[bFaceI] = p0; + } + } + } + syncTools::swapBoundaryFacePositions(mesh, nbrZeroPoint); + + // Compare to local ones. Use same tolerance as for matching + label nErrorFaces = 0; + scalar avgMismatch = 0; + label nCoupledFaces = 0; + + forAll(patches, patchI) + { + if (patches[patchI].coupled()) + { + const coupledPolyPatch& cpp = refCast + ( + patches[patchI] + ); + + if (cpp.owner()) + { + scalarField smallDist + ( + cpp.calcFaceTol + ( + cpp.matchTolerance(), + cpp, + cpp.points(), + cpp.faceCentres() + ) + ); + + forAll(cpp, i) + { + label bFaceI = cpp.start()+i-mesh.nInternalFaces(); + const point& p0 = p[cpp[i][0]]; + + scalar d = mag(p0 - nbrZeroPoint[bFaceI]); + + if (d > smallDist[i]) + { + if (setPtr) + { + setPtr->insert(cpp.start()+i); + } + nErrorFaces++; + } + avgMismatch += d; + nCoupledFaces++; + } + } + } + } + + reduce(nErrorFaces, sumOp