1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | cfMesh: A library for mesh generation
5 \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6 \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of cfMesh.
11 cfMesh is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 3 of the License, or (at your
14 option) any later version.
16 cfMesh is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
25 Generates boundary layers in the existing mesh, based on the settings
26 given in meshDict. It also performs necessary quality optimisation.
28 \*---------------------------------------------------------------------------*/
31 #include "objectRegistry.H"
33 #include "polyMeshGenModifier.H"
34 #include "meshOptimizer.H"
35 #include "boundaryLayers.H"
36 #include "refineBoundaryLayers.H"
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 const dictionary& meshDict,
49 boundaryLayers bl(mesh);
54 if( meshDict.found("boundaryLayers") )
56 const dictionary& bndLayers = meshDict.subDict("boundaryLayers");
58 if( bndLayers.found("nLayers") )
60 const label nLayers = readLabel(bndLayers.lookup("nLayers"));
63 bl.addLayerForAllPatches();
65 else if( bndLayers.found("patchBoundaryLayers") )
67 const dictionary& patchLayers =
68 bndLayers.subDict("patchBoundaryLayers");
69 const wordList createLayers = patchLayers.toc();
71 forAll(createLayers, patchI)
72 bl.addLayerForPatch(createLayers[patchI]);
77 bl.addLayerForAllPatches();
81 void meshOptimisation(polyMeshGen& mesh)
83 meshOptimizer mOpt(mesh);
85 mOpt.optimizeMeshFV();
86 mOpt.optimizeLowQualityFaces();
87 mOpt.untangleMeshFV();
88 mOpt.optimizeBoundaryLayer();
89 mOpt.untangleMeshFV();
92 void layerRefinement(polyMeshGen& mesh, const dictionary& meshDict)
94 if( meshDict.isDict("boundaryLayers") )
96 refineBoundaryLayers refLayers(mesh);
98 refineBoundaryLayers::readSettings(meshDict, refLayers);
100 refLayers.refineLayers();
102 meshOptimizer(mesh).untangleBoundaryLayer();
106 int main(int argc, char *argv[])
108 argList::validOptions.insert("2DLayers", "bool");
110 # include "setRootCase.H"
111 # include "createTime.H"
113 IOdictionary meshDict
125 //- load the mesh from disk
126 polyMeshGen pmg(runTime);
129 bool is2DLayer(false);
130 if( args.options().found("2DLayers") )
133 //- generate the initial boundary layer
134 generateLayer(pmg, meshDict, is2DLayer);
136 //- optimisation of mesh quality
137 meshOptimisation(pmg);
139 //- perform layer refinement
140 layerRefinement(pmg, meshDict);
142 Info << "Writing mesh" << endl;
145 Info << "End\n" << endl;
149 // ************************************************************************* //