initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / autoMesh / autoHexMesh / autoHexMeshDriver / refinementParameters / refinementParameters.C
blobd63d527faed069cc437a7fee15cee20c2314bce7
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "refinementParameters.H"
28 #include "mathematicalConstants.H"
29 #include "polyMesh.H"
30 #include "globalIndex.H"
32 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
34 // Construct from dictionary
35 Foam::refinementParameters::refinementParameters
37     const dictionary& dict,
38     const label dummy
41     maxGlobalCells_(readLabel(dict.lookup("cellLimit"))),
42     maxLocalCells_(readLabel(dict.lookup("procCellLimit"))),
43     minRefineCells_(readLabel(dict.lookup("minimumRefine"))),
44     curvature_(readScalar(dict.lookup("curvature"))),
45     nBufferLayers_(readLabel(dict.lookup("nBufferLayers"))),
46     keepPoints_(dict.lookup("keepPoints"))
50 Foam::refinementParameters::refinementParameters(const dictionary& dict)
52     maxGlobalCells_(readLabel(dict.lookup("maxGlobalCells"))),
53     maxLocalCells_(readLabel(dict.lookup("maxLocalCells"))),
54     minRefineCells_(readLabel(dict.lookup("minRefinementCells"))),
55     nBufferLayers_(readLabel(dict.lookup("nCellsBetweenLevels"))),
56     keepPoints_(pointField(1, dict.lookup("locationInMesh")))
58     scalar featAngle(readScalar(dict.lookup("resolveFeatureAngle")));
60     if (featAngle < 0 || featAngle > 180)
61     {
62         curvature_ = -GREAT;
63     }
64     else
65     {
66         curvature_ = Foam::cos(featAngle*mathematicalConstant::pi/180.0);
67     }
71 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
73 Foam::labelList Foam::refinementParameters::findCells(const polyMesh& mesh)
74  const
76     // Global calculation engine
77     globalIndex globalCells(mesh.nCells());
79     // Cell label per point
80     labelList cellLabels(keepPoints_.size());
82     forAll(keepPoints_, i)
83     {
84         const point& keepPoint = keepPoints_[i];
86         label localCellI = mesh.findCell(keepPoint);
88         label globalCellI = -1;
90         if (localCellI != -1)
91         {
92             Pout<< "Found point " << keepPoint << " in cell " << localCellI
93                 << " on processor " << Pstream::myProcNo() << endl;
94             globalCellI = globalCells.toGlobal(localCellI);
95         }
97         reduce(globalCellI, maxOp<label>());
99         if (globalCellI == -1)
100         {
101             FatalErrorIn
102             (
103                 "refinementParameters::findCells(const polyMesh&) const"
104             )   << "Point " << keepPoint
105                 << " is not inside the mesh or on a face or edge." << nl
106                 << "Bounding box of the mesh:" << mesh.bounds()
107                 << exit(FatalError);
108         }
110         if (globalCells.isLocal(globalCellI))
111         {
112             cellLabels[i] = localCellI;
113         }
114         else
115         {
116             cellLabels[i] = -1;
117         }
118     }
119     return cellLabels;
123 // ************************************************************************* //