cvControls.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation
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 "cvControls.H"
27 #include "conformalVoronoiMesh.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
32 (
33  const dictionary& foamyHexMeshDict
34 )
35 :
36  foamyHexMeshDict_(foamyHexMeshDict)
37 {
38  // Surface conformation controls
39 
40  const dictionary& surfDict
41  (
42  foamyHexMeshDict_.subDict("surfaceConformation")
43  );
44 
45  pointPairDistanceCoeff_ = readScalar
46  (
47  surfDict.lookup("pointPairDistanceCoeff")
48  );
49 
50  mixedFeaturePointPPDistanceCoeff_ = readScalar
51  (
52  surfDict.lookup("mixedFeaturePointPPDistanceCoeff")
53  );
54 
55  featurePointExclusionDistanceCoeff_ = readScalar
56  (
57  surfDict.lookup("featurePointExclusionDistanceCoeff")
58  );
59 
60  featureEdgeExclusionDistanceCoeff_ = readScalar
61  (
62  surfDict.lookup("featureEdgeExclusionDistanceCoeff")
63  );
64 
65 
66  surfaceSearchDistanceCoeff_ = readScalar
67  (
68  surfDict.lookup("surfaceSearchDistanceCoeff")
69  );
70 
71  maxSurfaceProtrusionCoeff_ = readScalar
72  (
73  surfDict.lookup("maxSurfaceProtrusionCoeff")
74  );
75 
76  maxQuadAngle_ = readScalar(surfDict.lookup("maxQuadAngle"));
77 
78  surfaceConformationRebuildFrequency_ = max
79  (
80  1,
81  readLabel(surfDict.lookup("surfaceConformationRebuildFrequency"))
82  );
83 
84 
85  const dictionary& featurePointControlsDict
86  (
87  surfDict.subDict("featurePointControls")
88  );
89 
90  specialiseFeaturePoints_ = Switch
91  (
92  featurePointControlsDict.lookup("specialiseFeaturePoints")
93  );
94 
95  guardFeaturePoints_ = Switch
96  (
97  featurePointControlsDict.lookup("guardFeaturePoints")
98  );
99 
100  edgeAiming_ = Switch
101  (
102  featurePointControlsDict.lookup("edgeAiming")
103  );
104 
105  if (!guardFeaturePoints_)
106  {
107  snapFeaturePoints_ = Switch
108  (
109  featurePointControlsDict.lookup("snapFeaturePoints")
110  );
111  }
112 
113  circulateEdges_ = Switch
114  (
115  featurePointControlsDict.lookup("circulateEdges")
116  );
117 
118  // Controls for coarse surface conformation
119 
120  const dictionary& conformationControlsDict
121  (
122  surfDict.subDict("conformationControls")
123  );
124 
125  surfacePtExclusionDistanceCoeff_ = readScalar
126  (
127  conformationControlsDict.lookup("surfacePtExclusionDistanceCoeff")
128  );
129 
130  edgeSearchDistCoeffSqr_ = sqr
131  (
132  readScalar
133  (
134  conformationControlsDict.lookup("edgeSearchDistCoeff")
135  )
136  );
137 
138  surfacePtReplaceDistCoeffSqr_ = sqr
139  (
140  readScalar
141  (
142  conformationControlsDict.lookup("surfacePtReplaceDistCoeff")
143  )
144  );
145 
146  maxConformationIterations_ = readLabel
147  (
148  conformationControlsDict.lookup("maxIterations")
149  );
150 
151  iterationToInitialHitRatioLimit_ = readScalar
152  (
153  conformationControlsDict.lookup("iterationToInitialHitRatioLimit")
154  );
155 
156 
157  // Motion control controls
158 
159  const dictionary& motionDict(foamyHexMeshDict_.subDict("motionControl"));
160 
161  defaultCellSize_ = readScalar(motionDict.lookup("defaultCellSize"));
162 
163  minimumCellSize_ =
164  readScalar(motionDict.lookup("minimumCellSizeCoeff"))*defaultCellSize_;
165 
166  objOutput_ = Switch(motionDict.lookupOrDefault<Switch>("objOutput", false));
167 
168  timeChecks_ = Switch
169  (
170  motionDict.lookupOrDefault<Switch>("timeChecks", false)
171  );
172 
173  printVertexInfo_ = Switch
174  (
175  motionDict.lookupOrDefault<Switch>("printVertexInfo", false)
176  );
177 
178  if (Pstream::parRun())
179  {
180  maxLoadUnbalance_ = readScalar(motionDict.lookup("maxLoadUnbalance"));
181  }
182  else
183  {
184  maxLoadUnbalance_ = -1;
185  }
186 
187  cosAlignmentAcceptanceAngle_ = cos
188  (
189  degToRad(readScalar(motionDict.lookup("alignmentAcceptanceAngle")))
190  );
191 
192 
193  // Point removal criteria
194 
195  const dictionary& insertionDict
196  (
197  motionDict.subDict("pointInsertionCriteria")
198  );
199 
200  insertionDistCoeff_ = readScalar
201  (
202  insertionDict.lookup("cellCentreDistCoeff")
203  );
204 
205  faceAreaRatioCoeff_ = readScalar
206  (
207  insertionDict.lookup("faceAreaRatioCoeff")
208  );
209 
210  cosInsertionAcceptanceAngle_ = cos
211  (
212  degToRad(readScalar(insertionDict.lookup("acceptanceAngle")))
213  );
214 
215  // Point removal criteria
216 
217  const dictionary& removalDict
218  (
219  motionDict.subDict("pointRemovalCriteria")
220  );
221 
222  removalDistCoeff_ = readScalar
223  (
224  removalDict.lookup("cellCentreDistCoeff")
225  );
226 
227  // polyMesh filtering controls
228 
229  const dictionary& filteringDict
230  (
231  foamyHexMeshDict_.subDict("polyMeshFiltering")
232  );
233 
234  filterEdges_ = Switch
235  (
236  filteringDict.lookupOrDefault<Switch>("filterEdges", true)
237  );
238 
239  filterFaces_ = Switch
240  (
241  filteringDict.lookupOrDefault<Switch>("filterFaces", false)
242  );
243 
244  if (filterFaces_)
245  {
246  filterEdges_ = Switch::switchType::on;
247  }
248 
249  writeTetDualMesh_ = Switch(filteringDict.lookup("writeTetDualMesh"));
250 
251  writeCellShapeControlMesh_ =
252  Switch(filteringDict.lookup("writeCellShapeControlMesh"));
253 
254  if (Pstream::parRun())
255  {
256  writeBackgroundMeshDecomposition_ =
257  Switch(filteringDict.lookup("writeBackgroundMeshDecomposition"));
258  }
259  else
260  {
261  writeBackgroundMeshDecomposition_ = Switch(false);
262  }
263 
264 }
265 
266 
267 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
268 
270 {}
271 
272 
273 // ************************************************************************* //
cvControls(const dictionary &foamyHexMeshDict)
Construct from references to conformalVoronoiMesh and dictionary.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
~cvControls()
Destructor.
dimensionedScalar cos(const dimensionedScalar &ds)
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if successful.
Definition: doubleScalar.H:68
label readLabel(Istream &is)
Definition: label.H:64
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:399