cvControls.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2012-2015 OpenFOAM Foundation
9  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "cvControls.H"
30 #include "conformalVoronoiMesh.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
34 Foam::cvControls::cvControls
35 (
36  const dictionary& foamyHexMeshDict
37 )
38 :
39  foamyHexMeshDict_(foamyHexMeshDict)
40 {
41  // Surface conformation controls
42 
43  const dictionary& surfDict
44  (
45  foamyHexMeshDict_.subDict("surfaceConformation")
46  );
47 
48  pointPairDistanceCoeff_ =
49  surfDict.get<scalar>("pointPairDistanceCoeff");
50 
51  mixedFeaturePointPPDistanceCoeff_ =
52  surfDict.get<scalar>("mixedFeaturePointPPDistanceCoeff");
53 
54  featurePointExclusionDistanceCoeff_ =
55  surfDict.get<scalar>("featurePointExclusionDistanceCoeff");
56 
57  featureEdgeExclusionDistanceCoeff_ =
58  surfDict.get<scalar>("featureEdgeExclusionDistanceCoeff");
59 
60  surfaceSearchDistanceCoeff_ =
61  surfDict.get<scalar>("surfaceSearchDistanceCoeff");
62 
63  maxSurfaceProtrusionCoeff_ =
64  surfDict.get<scalar>("maxSurfaceProtrusionCoeff");
65 
66  maxQuadAngle_ = surfDict.get<scalar>("maxQuadAngle");
67 
68  surfaceConformationRebuildFrequency_ = max
69  (
70  1,
71  surfDict.get<label>("surfaceConformationRebuildFrequency")
72  );
73 
74 
75  const dictionary& featurePointControlsDict
76  (
77  surfDict.subDict("featurePointControls")
78  );
79 
80  specialiseFeaturePoints_ =
81  featurePointControlsDict.get<Switch>("specialiseFeaturePoints");
82 
83  guardFeaturePoints_ =
84  featurePointControlsDict.get<Switch>("guardFeaturePoints");
85 
86  edgeAiming_ =
87  featurePointControlsDict.get<Switch>("edgeAiming");
88 
89  if (!guardFeaturePoints_)
90  {
91  snapFeaturePoints_ =
92  featurePointControlsDict.get<Switch>("snapFeaturePoints");
93  }
94 
95  circulateEdges_ =
96  featurePointControlsDict.get<Switch>("circulateEdges");
97 
98  // Controls for coarse surface conformation
99 
100  const dictionary& conformationControlsDict
101  (
102  surfDict.subDict("conformationControls")
103  );
104 
105  surfacePtExclusionDistanceCoeff_ =
106  conformationControlsDict.get<scalar>("surfacePtExclusionDistanceCoeff");
107 
108  edgeSearchDistCoeffSqr_ = sqr
109  (
110  conformationControlsDict.get<scalar>("edgeSearchDistCoeff")
111  );
112 
113  surfacePtReplaceDistCoeffSqr_ = sqr
114  (
115  conformationControlsDict.get<scalar>("surfacePtReplaceDistCoeff")
116  );
117 
118  maxConformationIterations_ =
119  conformationControlsDict.get<label>("maxIterations");
120 
121  iterationToInitialHitRatioLimit_ =
122  conformationControlsDict.get<scalar>("iterationToInitialHitRatioLimit");
123 
124 
125  // Motion control controls
126 
127  const dictionary& motionDict(foamyHexMeshDict_.subDict("motionControl"));
128 
129  defaultCellSize_ = motionDict.get<scalar>("defaultCellSize");
130 
131  minimumCellSize_ =
132  motionDict.get<scalar>("minimumCellSizeCoeff")*defaultCellSize_;
133 
134  objOutput_ =
135  motionDict.getOrDefault<Switch>("objOutput", false);
136 
137  timeChecks_ =
138  motionDict.getOrDefault<Switch>("timeChecks", false);
139 
140  printVertexInfo_ =
141  motionDict.getOrDefault<Switch>("printVertexInfo", false);
142 
143  if (Pstream::parRun())
144  {
145  maxLoadUnbalance_ = motionDict.get<scalar>("maxLoadUnbalance");
146  }
147  else
148  {
149  maxLoadUnbalance_ = -1;
150  }
151 
152  cosAlignmentAcceptanceAngle_ = cos
153  (
154  degToRad(motionDict.get<scalar>("alignmentAcceptanceAngle"))
155  );
156 
157 
158  // Point removal criteria
159 
160  const dictionary& insertionDict
161  (
162  motionDict.subDict("pointInsertionCriteria")
163  );
164 
165  insertionDistCoeff_ =
166  insertionDict.get<scalar>("cellCentreDistCoeff");
167 
168  faceAreaRatioCoeff_ =
169  insertionDict.get<scalar>("faceAreaRatioCoeff");
170 
171  cosInsertionAcceptanceAngle_ = cos
172  (
173  degToRad(insertionDict.get<scalar>("acceptanceAngle"))
174  );
175 
176  // Point removal criteria
177 
178  const dictionary& removalDict
179  (
180  motionDict.subDict("pointRemovalCriteria")
181  );
182 
183  removalDistCoeff_ =
184  removalDict.get<scalar>("cellCentreDistCoeff");
185 
186  // polyMesh filtering controls
187 
188  const dictionary& filteringDict
189  (
190  foamyHexMeshDict_.subDict("polyMeshFiltering")
191  );
192 
193  filterEdges_ =
194  filteringDict.getOrDefault<Switch>("filterEdges", true);
195 
196  filterFaces_ =
197  filteringDict.getOrDefault<Switch>("filterFaces", false);
198 
199  if (filterFaces_)
200  {
201  filterEdges_ = filterFaces_;
202  }
203 
204  writeTetDualMesh_ =
205  filteringDict.get<Switch>("writeTetDualMesh");
206 
207  writeCellShapeControlMesh_ =
208  filteringDict.get<Switch>("writeCellShapeControlMesh");
209 
210  if (Pstream::parRun())
211  {
212  writeBackgroundMeshDecomposition_ =
213  filteringDict.get<Switch>("writeBackgroundMeshDecomposition");
214  }
215  else
216  {
217  writeBackgroundMeshDecomposition_ = Switch::FALSE;
218  }
219 
220 }
221 
222 
223 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
224 
226 {}
227 
228 
229 // ************************************************************************* //
Foam::cvControls::~cvControls
~cvControls()
Destructor.
Foam::Switch::FALSE
Definition: Switch.H:90
cvControls.H
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Foam::degToRad
constexpr scalar degToRad(const scalar deg) noexcept
Conversion from degrees to radians.
Definition: unitConversion.H:48
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
Foam::UPstream::parRun
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:433
conformalVoronoiMesh.H
Foam::cos
dimensionedScalar cos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:265