diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C index 91a92da072..030f4a89fd 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C @@ -1,3 +1,28 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2022 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 "PatchTools.H" #include "checkGeometry.H" #include "polyMesh.H" @@ -11,12 +36,14 @@ #include "vtkSurfaceWriter.H" #include "setWriter.H" +#include "writeFile.H" +#include "nonConformalCyclicPolyPatch.H" #include "checkTools.H" #include "Time.H" -// Find wedge with opposite orientation. Note: does not actually check that -// it is opposite, only that it has opposite normal and same axis +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + Foam::label Foam::findOppositeWedge ( const polyMesh& mesh, @@ -942,5 +969,124 @@ Foam::label Foam::checkGeometry } } + if (allGeometry) + { + const fileName outputPath = + mesh.time().globalPath() + /functionObjects::writeFile::outputPrefix + /(mesh.name() != polyMesh::defaultRegion ? mesh.name() : word()) + /"checkMesh" + /mesh.time().timeName(); + + const polyBoundaryMesh& patches = mesh.boundaryMesh(); + + // Compute coverage for all orig patches + PtrList patchCoverage(patches.size()); + forAll(patches, nccPatchi) + { + if (isA(patches[nccPatchi])) + { + const nonConformalCyclicPolyPatch& nccPp = + refCast + (patches[nccPatchi]); + + if (nccPp.owner()) + { + const polyPatch& origPp = nccPp.origPatch(); + const polyPatch& nbrOrigPp = nccPp.nbrPatch().origPatch(); + + const patchToPatches::intersection& intersection = + nccPp.intersection(); + + if (!patchCoverage.set(origPp.index())) + { + patchCoverage.set + ( + origPp.index(), + scalarField(origPp.size(), 0) + ); + } + + patchCoverage[origPp.index()] += + intersection.srcCoverage(); + + if (!patchCoverage.set(nbrOrigPp.index())) + { + patchCoverage.set + ( + nbrOrigPp.index(), + scalarField(nbrOrigPp.size(), 0) + ); + } + + patchCoverage[nbrOrigPp.index()] += + intersection.tgtCoverage(); + } + } + } + + // Write out to surface files + forAll(patches, patchi) + { + if (patchCoverage.set(patchi)) + { + const polyPatch& patch = patches[patchi]; + + // Collect the patch geometry + labelList pointToGlobal; + labelList uniqueMeshPointLabels; + autoPtr globalPoints; + autoPtr globalFaces; + faceList mergedFaces; + pointField mergedPoints; + Foam::PatchTools::gatherAndMerge + ( + mesh, + patch.localFaces(), + patch.meshPoints(), + patch.meshPointMap(), + pointToGlobal, + uniqueMeshPointLabels, + globalPoints, + globalFaces, + mergedFaces, + mergedPoints + ); + + // Collect the patch coverage + scalarField mergedCoverage; + globalFaces().gather + ( + UPstream::worldComm, + labelList(UPstream::procID(UPstream::worldComm)), + patchCoverage[patchi], + mergedCoverage + ); + + // Write the surface + if (Pstream::master()) + { + vtkSurfaceWriter + ( + mesh.time().writeFormat(), + mesh.time().writeCompression() + ).write + ( + outputPath, + patch.name() + "_coverage", + mergedPoints, + mergedFaces, + false, + "coverage", + mergedCoverage + ); + } + } + } + } + return noFailedChecks; } + + +// ************************************************************************* // diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.H b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.H index d9b75fb389..76f2f06e12 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.H +++ b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.H @@ -1,14 +1,52 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2022 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 . + +Description + Routines for checking mesh geometry + +SourceFiles + checkGeometry.C + +\*---------------------------------------------------------------------------*/ + +#ifndef checkGeometry_H +#define checkGeometry_H + #include "label.H" #include "HashSet.H" #include "labelVector.H" #include "setWriter.H" +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + namespace Foam { class polyMesh; class wedgePolyPatch; class surfaceWriter; + //- Find wedge with opposite orientation. Note: does not actually check + // that it is opposite, only that it has opposite normal and same axis. label findOppositeWedge(const polyMesh&, const wedgePolyPatch&); //- Check wedge orientation @@ -23,6 +61,7 @@ namespace Foam //- Check 0th vertex on coupled faces bool checkCoupledPoints(const polyMesh&, const bool report, labelHashSet*); + //- Check the geometry label checkGeometry ( const polyMesh& mesh, @@ -31,3 +70,9 @@ namespace Foam const autoPtr& ); } + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C b/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C index a6a01c7336..cb7205c1da 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C @@ -1,3 +1,28 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2022 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 "checkMeshQuality.H" #include "polyMesh.H" #include "cellSet.H" @@ -6,6 +31,8 @@ #include "surfaceWriter.H" #include "checkTools.H" +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + Foam::label Foam::checkMeshQuality ( const polyMesh& mesh, @@ -38,3 +65,6 @@ Foam::label Foam::checkMeshQuality return noFailedChecks; } + + +// ************************************************************************* // diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.H b/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.H index 52507986bf..8e2784b426 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.H +++ b/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.H @@ -1,7 +1,44 @@ -#include "polyMesh.H" +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2022 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 . + +Description + Routines for checking mesh quality + +SourceFiles + checkMeshQuality.C + +\*---------------------------------------------------------------------------*/ + +#ifndef checkMeshQuality_H +#define checkMeshQuality_H + +#include "dictionary.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { + class polyMesh; class surfaceWriter; label checkMeshQuality @@ -11,3 +48,9 @@ namespace Foam const autoPtr& ); } + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTools.C b/applications/utilities/mesh/manipulation/checkMesh/checkTools.C index 6c37d71fa4..19b461e51a 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkTools.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkTools.C @@ -44,6 +44,7 @@ License #include "writeFile.H" #include "coordSet.H" +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology) { diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTools.H b/applications/utilities/mesh/manipulation/checkMesh/checkTools.H index 12b94d3545..2b83d746a0 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkTools.H +++ b/applications/utilities/mesh/manipulation/checkMesh/checkTools.H @@ -1,17 +1,54 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2015-2022 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 . + +Description + Tools for checking the mesh + +SourceFiles + checkTools.C + +\*---------------------------------------------------------------------------*/ + +#ifndef checkTools_H +#define checkTools_H + #include "scalar.H" #include "indirectPrimitivePatch.H" -#include "setWriter.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { class polyMesh; class surfaceWriter; + class setWriter; class pointSet; class faceSet; class cellSet; class fileName; class polyMesh; + //- Print mesh statistics void printMeshStats(const polyMesh& mesh, const bool allTopology); //- Generate merged surface on master and write. Needs input patch @@ -38,5 +75,8 @@ namespace Foam void mergeAndWrite(const setWriter&, const pointSet&); } +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif // ************************************************************************* // diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C index d121bd0964..9315b01e5a 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.H b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.H index ffad9fee69..17b4e0a960 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.H +++ b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.H @@ -1,18 +1,60 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2022 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 . + +Description + Tools for checking the mesh + +SourceFiles + checkTopology.C + +\*---------------------------------------------------------------------------*/ + +#ifndef checkTopology_H +#define checkTopology_H + #include "label.H" #include "autoPtr.H" -#include "setWriter.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { class polyMesh; class surfaceWriter; + class setWriter; label checkTopology ( - const polyMesh&, - const bool, - const bool, - const autoPtr&, - const autoPtr& + const polyMesh& mesh, + const bool allTopology, + const bool allGeometry, + const autoPtr& surfWriter, + const autoPtr& setWriter ); } + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/utilities/mesh/manipulation/checkMesh/printMeshStats.C b/applications/utilities/mesh/manipulation/checkMesh/printMeshStats.C deleted file mode 100644 index 0db4379218..0000000000 --- a/applications/utilities/mesh/manipulation/checkMesh/printMeshStats.C +++ /dev/null @@ -1,170 +0,0 @@ -#include "printMeshStats.H" -#include "polyMesh.H" -#include "globalMeshData.H" - -#include "hexMatcher.H" -#include "wedgeMatcher.H" -#include "prismMatcher.H" -#include "pyrMatcher.H" -#include "tetWedgeMatcher.H" -#include "tetMatcher.H" -#include "IOmanip.H" - - -void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology) -{ - Info<< "Mesh stats" << nl - << " points: " - << returnReduce(mesh.points().size(), sumOp