1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
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
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"
29 #include "globalIndex.H"
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 // Construct from dictionary
34 Foam::refinementParameters::refinementParameters
36 const dictionary& dict,
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)
69 curvature_ = Foam::cos(degToRad(featAngle));
74 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
76 Foam::labelList Foam::refinementParameters::findCells(const polyMesh& mesh)
79 // Global calculation engine
80 globalIndex globalCells(mesh.nCells());
82 // Cell label per point
83 labelList cellLabels(keepPoints_.size());
85 forAll(keepPoints_, i)
87 const point& keepPoint = keepPoints_[i];
89 label localCellI = mesh.findCell(keepPoint);
91 label globalCellI = -1;
95 Pout<< "Found point " << keepPoint << " in cell " << localCellI
96 << " on processor " << Pstream::myProcNo() << endl;
97 globalCellI = globalCells.toGlobal(localCellI);
100 reduce(globalCellI, maxOp<label>());
102 if (globalCellI == -1)
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()
113 if (globalCells.isLocal(globalCellI))
115 cellLabels[i] = localCellI;
126 // ************************************************************************* //