/*---------------------------------------------------------------------------*\ ========= | \\ / 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) 2018-2020 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 . Application refineMesh Group grpMeshManipulationUtilities Description Utility to refine cells in multiple directions. Command-line option handling: - If -all specified or no refineMeshDict exists or, refine all cells - If -dict \ specified refine according to \ - If refineMeshDict exists refine according to refineMeshDict When the refinement or all cells is selected apply 3D refinement for 3D cases and 2D refinement for 2D cases. \*---------------------------------------------------------------------------*/ #include "argList.H" #include "polyMesh.H" #include "Time.H" #include "cellSet.H" #include "multiDirRefinement.H" #include "labelIOList.H" #include "IOdictionary.H" #include "syncTools.H" using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Max cos angle for edges to be considered aligned with axis. static const scalar edgeTol = 1e-3; // Print edge statistics on mesh. void printEdgeStats(const polyMesh& mesh) { label nAny(0); label nX(0); label nY(0); label nZ(0); scalarMinMax limitsAny(GREAT, -GREAT); scalarMinMax limitsX(limitsAny); scalarMinMax limitsY(limitsAny); scalarMinMax limitsZ(limitsAny); bitSet isMasterEdge(syncTools::getMasterEdges(mesh)); const edgeList& edges = mesh.edges(); for (const label edgei : isMasterEdge) { const edge& e = edges[edgei]; vector eVec(e.vec(mesh.points())); scalar eMag = mag(eVec); eVec /= eMag; if (mag(eVec.x()) > 1-edgeTol) { limitsX.add(eMag); nX++; } else if (mag(eVec.y()) > 1-edgeTol) { limitsY.add(eMag); nY++; } else if (mag(eVec.z()) > 1-edgeTol) { limitsZ.add(eMag); nZ++; } else { limitsAny.add(eMag); nAny++; } } reduce(nX, sumOp