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-2019 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_ =
46  surfDict.lookup<scalar>("pointPairDistanceCoeff");
47 
48  mixedFeaturePointPPDistanceCoeff_ =
49  surfDict.lookup<scalar>("mixedFeaturePointPPDistanceCoeff");
50 
51  featurePointExclusionDistanceCoeff_ =
52  surfDict.lookup<scalar>("featurePointExclusionDistanceCoeff");
53 
54  featureEdgeExclusionDistanceCoeff_ =
55  surfDict.lookup<scalar>("featureEdgeExclusionDistanceCoeff");
56 
57  surfaceSearchDistanceCoeff_ =
58  surfDict.lookup<scalar>("surfaceSearchDistanceCoeff");
59 
60  maxSurfaceProtrusionCoeff_ =
61  surfDict.lookup<scalar>("maxSurfaceProtrusionCoeff");
62 
63  maxQuadAngle_ = surfDict.lookup<scalar>("maxQuadAngle");
64 
65  surfaceConformationRebuildFrequency_ = max
66  (
67  1,
68  surfDict.lookup<label>("surfaceConformationRebuildFrequency")
69  );
70 
71 
72  const dictionary& featurePointControlsDict
73  (
74  surfDict.subDict("featurePointControls")
75  );
76 
77  specialiseFeaturePoints_ = Switch
78  (
79  featurePointControlsDict.lookup("specialiseFeaturePoints")
80  );
81 
82  guardFeaturePoints_ = Switch
83  (
84  featurePointControlsDict.lookup("guardFeaturePoints")
85  );
86 
87  edgeAiming_ = Switch
88  (
89  featurePointControlsDict.lookup("edgeAiming")
90  );
91 
92  if (!guardFeaturePoints_)
93  {
94  snapFeaturePoints_ = Switch
95  (
96  featurePointControlsDict.lookup("snapFeaturePoints")
97  );
98  }
99 
100  circulateEdges_ = Switch
101  (
102  featurePointControlsDict.lookup("circulateEdges")
103  );
104 
105  // Controls for coarse surface conformation
106 
107  const dictionary& conformationControlsDict
108  (
109  surfDict.subDict("conformationControls")
110  );
111 
112  surfacePtExclusionDistanceCoeff_ =
113  conformationControlsDict.lookup<scalar>
114  (
115  "surfacePtExclusionDistanceCoeff"
116  );
117 
118  edgeSearchDistCoeffSqr_ = sqr
119  (
120  conformationControlsDict.lookup<scalar>("edgeSearchDistCoeff")
121  );
122 
123  surfacePtReplaceDistCoeffSqr_ = sqr
124  (
125  conformationControlsDict.lookup<scalar>("surfacePtReplaceDistCoeff")
126  );
127 
128  maxConformationIterations_ =
129  conformationControlsDict.lookup<label>("maxIterations");
130 
131  iterationToInitialHitRatioLimit_ =
132  conformationControlsDict.lookup<scalar>
133  (
134  "iterationToInitialHitRatioLimit"
135  );
136 
137 
138  // Motion control controls
139 
140  const dictionary& motionDict(foamyHexMeshDict_.subDict("motionControl"));
141 
142  defaultCellSize_ = motionDict.lookup<scalar>("defaultCellSize");
143 
144  minimumCellSize_ =
145  motionDict.lookup<scalar>("minimumCellSizeCoeff")*defaultCellSize_;
146 
147  objOutput_ = Switch(motionDict.lookupOrDefault<Switch>("objOutput", false));
148 
149  timeChecks_ = Switch
150  (
151  motionDict.lookupOrDefault<Switch>("timeChecks", false)
152  );
153 
154  printVertexInfo_ = Switch
155  (
156  motionDict.lookupOrDefault<Switch>("printVertexInfo", false)
157  );
158 
159  if (Pstream::parRun())
160  {
161  maxLoadUnbalance_ = motionDict.lookup<scalar>("maxLoadUnbalance");
162  }
163  else
164  {
165  maxLoadUnbalance_ = -1;
166  }
167 
168  cosAlignmentAcceptanceAngle_ = cos
169  (
170  degToRad(motionDict.lookup<scalar>("alignmentAcceptanceAngle"))
171  );
172 
173 
174  // Point removal criteria
175 
176  const dictionary& insertionDict
177  (
178  motionDict.subDict("pointInsertionCriteria")
179  );
180 
181  insertionDistCoeff_ =
182  insertionDict.lookup<scalar>("cellCentreDistCoeff");
183 
184  faceAreaRatioCoeff_ =
185  insertionDict.lookup<scalar>("faceAreaRatioCoeff");
186 
187  cosInsertionAcceptanceAngle_ = cos
188  (
189  degToRad(insertionDict.lookup<scalar>("acceptanceAngle"))
190  );
191 
192  // Point removal criteria
193 
194  const dictionary& removalDict
195  (
196  motionDict.subDict("pointRemovalCriteria")
197  );
198 
199  removalDistCoeff_ =
200  removalDict.lookup<scalar>("cellCentreDistCoeff");
201 
202  // polyMesh filtering controls
203 
204  const dictionary& filteringDict
205  (
206  foamyHexMeshDict_.subDict("polyMeshFiltering")
207  );
208 
209  filterEdges_ = Switch
210  (
211  filteringDict.lookupOrDefault<Switch>("filterEdges", true)
212  );
213 
214  filterFaces_ = Switch
215  (
216  filteringDict.lookupOrDefault<Switch>("filterFaces", false)
217  );
218 
219  if (filterFaces_)
220  {
221  filterEdges_ = Switch::switchType::on;
222  }
223 
224  writeTetDualMesh_ = Switch(filteringDict.lookup("writeTetDualMesh"));
225 
226  writeCellShapeControlMesh_ =
227  Switch(filteringDict.lookup("writeCellShapeControlMesh"));
228 
229  if (Pstream::parRun())
230  {
231  writeBackgroundMeshDecomposition_ =
232  Switch(filteringDict.lookup("writeBackgroundMeshDecomposition"));
233  }
234  else
235  {
236  writeBackgroundMeshDecomposition_ = Switch(false);
237  }
238 }
239 
240 
241 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
242 
244 {}
245 
246 
247 // ************************************************************************* //
cvControls(const dictionary &foamyHexMeshDict)
Construct from references to conformalVoronoiMesh and dictionary.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
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)
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:399