FreeFOAM The Cross-Platform CFD Toolkit
refinementParameters.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "refinementParameters.H"
28 #include <OpenFOAM/polyMesh.H>
29 #include <OpenFOAM/globalIndex.H>
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 // Construct from dictionary
34 Foam::refinementParameters::refinementParameters
35 (
36  const dictionary& dict,
37  const label dummy
38 )
39 :
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_
47  (
49  (
50  "allowFreeStandingZoneFaces",
51  true
52  )
53  ),
54  maxLoadUnbalance_(dict.lookupOrDefault<scalar>("maxLoadUnbalance",0))
55 {}
56 
57 
58 Foam::refinementParameters::refinementParameters(const dictionary& dict)
59 :
60  maxGlobalCells_(readLabel(dict.lookup("maxGlobalCells"))),
61  maxLocalCells_(readLabel(dict.lookup("maxLocalCells"))),
62  minRefineCells_(readLabel(dict.lookup("minRefinementCells"))),
63  nBufferLayers_(readLabel(dict.lookup("nCellsBetweenLevels"))),
64  keepPoints_(pointField(1, dict.lookup("locationInMesh"))),
65  allowFreeStandingZoneFaces_
66  (
67  dict.lookupOrDefault<Switch>
68  (
69  "allowFreeStandingZoneFaces",
70  true
71  )
72  ),
73  maxLoadUnbalance_(dict.lookupOrDefault<scalar>("maxLoadUnbalance",0))
74 {
75  scalar featAngle(readScalar(dict.lookup("resolveFeatureAngle")));
76 
77  if (featAngle < 0 || featAngle > 180)
78  {
79  curvature_ = -GREAT;
80  }
81  else
82  {
83  curvature_ = Foam::cos(featAngle*mathematicalConstant::pi/180.0);
84  }
85 }
86 
87 
88 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
89 
91  const
92 {
93  // Global calculation engine
94  globalIndex globalCells(mesh.nCells());
95 
96  // Cell label per point
97  labelList cellLabels(keepPoints_.size());
98 
99  forAll(keepPoints_, i)
100  {
101  const point& keepPoint = keepPoints_[i];
102 
103  label localCellI = mesh.findCell(keepPoint);
104 
105  label globalCellI = -1;
106 
107  if (localCellI != -1)
108  {
109  Pout<< "Found point " << keepPoint << " in cell " << localCellI
110  << " on processor " << Pstream::myProcNo() << endl;
111  globalCellI = globalCells.toGlobal(localCellI);
112  }
113 
114  reduce(globalCellI, maxOp<label>());
115 
116  if (globalCellI == -1)
117  {
119  (
120  "refinementParameters::findCells(const polyMesh&) const"
121  ) << "Point " << keepPoint
122  << " is not inside the mesh or on a face or edge." << nl
123  << "Bounding box of the mesh:" << mesh.bounds()
124  << exit(FatalError);
125  }
126 
127  if (globalCells.isLocal(globalCellI))
128  {
129  cellLabels[i] = localCellI;
130  }
131  else
132  {
133  cellLabels[i] = -1;
134  }
135  }
136  return cellLabels;
137 }
138 
139 
140 // ************************ vim: set sw=4 sts=4 et: ************************ //