1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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"
30 #include "globalIndex.H"
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 // Construct from dictionary
35 Foam::refinementParameters::refinementParameters
37 const dictionary& dict,
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)
66 curvature_ = Foam::cos(featAngle*mathematicalConstant::pi/180.0);
71 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
73 Foam::labelList Foam::refinementParameters::findCells(const polyMesh& mesh)
76 // Global calculation engine
77 globalIndex globalCells(mesh.nCells());
79 // Cell label per point
80 labelList cellLabels(keepPoints_.size());
82 forAll(keepPoints_, i)
84 const point& keepPoint = keepPoints_[i];
86 label localCellI = mesh.findCell(keepPoint);
88 label globalCellI = -1;
92 Pout<< "Found point " << keepPoint << " in cell " << localCellI
93 << " on processor " << Pstream::myProcNo() << endl;
94 globalCellI = globalCells.toGlobal(localCellI);
97 reduce(globalCellI, maxOp<label>());
99 if (globalCellI == -1)
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()
110 if (globalCells.isLocal(globalCellI))
112 cellLabels[i] = localCellI;
123 // ************************************************************************* //