/*---------------------------------------------------------------------------*\ ========= | \\ / 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 nX = 0; label nY = 0; label nZ = 0; scalar minX = GREAT; scalar maxX = -GREAT; static const vector x(1, 0, 0); scalar minY = GREAT; scalar maxY = -GREAT; static const vector y(0, 1, 0); scalar minZ = GREAT; scalar maxZ = -GREAT; static const vector z(0, 0, 1); scalar minOther = GREAT; scalar maxOther = -GREAT; bitSet isMasterEdge(syncTools::getMasterEdges(mesh)); const edgeList& edges = mesh.edges(); forAll(edges, edgeI) { if (isMasterEdge.test(edgeI)) { const edge& e = edges[edgeI]; vector eVec(e.vec(mesh.points())); scalar eMag = mag(eVec); eVec /= eMag; if (mag(eVec & x) > 1-edgeTol) { minX = min(minX, eMag); maxX = max(maxX, eMag); nX++; } else if (mag(eVec & y) > 1-edgeTol) { minY = min(minY, eMag); maxY = max(maxY, eMag); nY++; } else if (mag(eVec & z) > 1-edgeTol) { minZ = min(minZ, eMag); maxZ = max(maxZ, eMag); nZ++; } else { minOther = min(minOther, eMag); maxOther = max(maxOther, eMag); } } } label nEdges = mesh.nEdges(); reduce(nEdges, sumOp