/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2015-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- 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 "meshRefinement.H" #include "volMesh.H" #include "volFields.H" #include "surfaceMesh.H" #include "syncTools.H" #include "Time.H" #include "refinementSurfaces.H" #include "refinementFeatures.H" #include "decompositionMethod.H" #include "regionSplit.H" #include "fvMeshDistribute.H" #include "indirectPrimitivePatch.H" #include "polyTopoChange.H" #include "removeCells.H" #include "mapDistributePolyMesh.H" #include "localPointRegion.H" #include "pointMesh.H" #include "pointFields.H" #include "slipPointPatchFields.H" #include "fixedValuePointPatchFields.H" #include "calculatedPointPatchFields.H" #include "cyclicSlipPointPatchFields.H" #include "processorPointPatch.H" #include "globalIndex.H" #include "meshTools.H" #include "OFstream.H" #include "Random.H" #include "searchableSurfaces.H" #include "treeBoundBox.H" #include "zeroGradientFvPatchFields.H" #include "fvMeshTools.H" #include "motionSmoother.H" #include "faceSet.H" #include "topoDistanceData.H" #include "FaceCellWave.H" // Leak path #include "shortestPathSet.H" #include "meshSearch.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { defineTypeNameAndDebug(meshRefinement, 0); } const Foam::Enum < Foam::meshRefinement::MeshType > Foam::meshRefinement::MeshTypeNames ({ { MeshType::CASTELLATED, "castellated" }, { MeshType::CASTELLATEDBUFFERLAYER, "castellatedBufferLayer" }, { MeshType::CASTELLATEDBUFFERLAYER2, "castellatedBufferLayer2" } }); const Foam::Enum < Foam::meshRefinement::debugType > Foam::meshRefinement::debugTypeNames ({ { debugType::MESH, "mesh" }, { debugType::OBJINTERSECTIONS, "intersections" }, { debugType::FEATURESEEDS, "featureSeeds" }, { debugType::ATTRACTION, "attraction" }, { debugType::LAYERINFO, "layerInfo" }, }); //const Foam::Enum //< // Foam::meshRefinement::outputType //> //Foam::meshRefinement::outputTypeNames //({ // { outputType::OUTPUTLAYERINFO, "layerInfo" } //}); const Foam::Enum < Foam::meshRefinement::writeType > Foam::meshRefinement::writeTypeNames ({ { writeType::WRITEMESH, "mesh" }, { writeType::NOWRITEREFINEMENT, "noRefinement" }, { writeType::WRITELEVELS, "scalarLevels" }, { writeType::WRITELAYERSETS, "layerSets" }, { writeType::WRITELAYERFIELDS, "layerFields" }, }); Foam::meshRefinement::writeType Foam::meshRefinement::writeLevel_; //Foam::meshRefinement::outputType Foam::meshRefinement::outputLevel_; // Inside/outside test for polyMesh:.findCell() // 2.4.x : default = polyMesh::FACE_DIAG_TRIS // 1712 : default = polyMesh::CELL_TETS // // - CELL_TETS is better with concave cells, but much slower. // - use faster method (FACE_DIAG_TRIS) here static const Foam::polyMesh::cellDecomposition findCellMode(Foam::polyMesh::FACE_DIAG_TRIS); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // Foam::label Foam::meshRefinement::globalFaceCount(const labelList& elems) const { //- Check for duplicates const bitSet isElem(mesh_.nFaces(), elems); if (label(isElem.count()) != elems.size()) { FatalErrorInFunction << "Problem Duplicates:" << " isElem:" << isElem.count() << " elems:" << elems.size() << exit(FatalError); } //- Check for same entries on coupled faces { bitSet isElem2(isElem); syncTools::swapFaceList(mesh_, isElem2); for ( label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++ ) { if (isElem2[facei] != isElem[facei]) { FatalErrorInFunction << "at face:" << facei << " at:" << mesh_.faceCentres()[facei] << " patch:" << mesh_.boundaryMesh().whichPatch(facei) << " isElem:" << isElem[facei] << " isElem2:" << isElem2[facei] << exit(FatalError); } } } //- Count number of master elements const bitSet isMaster(syncTools::getMasterFaces(mesh_)); label count = 0; for (const label i : isElem) { if (isMaster[i]) { count++; } } return returnReduce(count, sumOp