ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / mesh / autoMesh / autoHexMesh / autoHexMeshDriver / refinementParameters / refinementParameters.C
blobba8d0f4200e1399963613581f3e82d91c8cc775b
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by
13     the Free Software Foundation, either version 3 of the License, or
14     (at your option) any later version.
16     OpenFOAM 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
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "refinementParameters.H"
27 #include "unitConversion.H"
28 #include "polyMesh.H"
29 #include "globalIndex.H"
31 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
33 // Construct from dictionary
34 Foam::refinementParameters::refinementParameters
36     const dictionary& dict,
37     const label dummy
40     maxGlobalCells_(readLabel(dict.lookup("cellLimit"))),
41     maxLocalCells_(readLabel(dict.lookup("procCellLimit"))),
42     minRefineCells_(readLabel(dict.lookup("minimumRefine"))),
43     curvature_(readScalar(dict.lookup("curvature"))),
44     nBufferLayers_(readLabel(dict.lookup("nBufferLayers"))),
45     keepPoints_(dict.lookup("keepPoints")),
46     allowFreeStandingZoneFaces_(dict.lookup("allowFreeStandingZoneFaces")),
47     maxLoadUnbalance_(dict.lookupOrDefault<scalar>("maxLoadUnbalance",0))
51 Foam::refinementParameters::refinementParameters(const dictionary& dict)
53     maxGlobalCells_(readLabel(dict.lookup("maxGlobalCells"))),
54     maxLocalCells_(readLabel(dict.lookup("maxLocalCells"))),
55     minRefineCells_(readLabel(dict.lookup("minRefinementCells"))),
56     nBufferLayers_(readLabel(dict.lookup("nCellsBetweenLevels"))),
57     keepPoints_(pointField(1, dict.lookup("locationInMesh"))),
58     allowFreeStandingZoneFaces_(dict.lookup("allowFreeStandingZoneFaces")),
59     maxLoadUnbalance_(dict.lookupOrDefault<scalar>("maxLoadUnbalance",0))
61     scalar featAngle(readScalar(dict.lookup("resolveFeatureAngle")));
63     if (featAngle < 0 || featAngle > 180)
64     {
65         curvature_ = -GREAT;
66     }
67     else
68     {
69         curvature_ = Foam::cos(degToRad(featAngle));
70     }
74 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
76 Foam::labelList Foam::refinementParameters::findCells(const polyMesh& mesh)
77  const
79     // Global calculation engine
80     globalIndex globalCells(mesh.nCells());
82     // Cell label per point
83     labelList cellLabels(keepPoints_.size());
85     forAll(keepPoints_, i)
86     {
87         const point& keepPoint = keepPoints_[i];
89         label localCellI = mesh.findCell(keepPoint);
91         label globalCellI = -1;
93         if (localCellI != -1)
94         {
95             Pout<< "Found point " << keepPoint << " in cell " << localCellI
96                 << " on processor " << Pstream::myProcNo() << endl;
97             globalCellI = globalCells.toGlobal(localCellI);
98         }
100         reduce(globalCellI, maxOp<label>());
102         if (globalCellI == -1)
103         {
104             FatalErrorIn
105             (
106                 "refinementParameters::findCells(const polyMesh&) const"
107             )   << "Point " << keepPoint
108                 << " is not inside the mesh or on a face or edge." << nl
109                 << "Bounding box of the mesh:" << mesh.bounds()
110                 << exit(FatalError);
111         }
113         if (globalCells.isLocal(globalCellI))
114         {
115             cellLabels[i] = localCellI;
116         }
117         else
118         {
119             cellLabels[i] = -1;
120         }
121     }
122     return cellLabels;
126 // ************************************************************************* //