polyMeshFilterSettings.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) 2013-2024 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 "polyMeshFilterSettings.H"
27 #include "unitConversion.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
32 :
33  dict_(dict),
34  controlMeshQuality_
35  (
36  dict_.lookupOrDefault<Switch>("controlMeshQuality", false)
37  ),
38  collapseEdgesCoeffDict_(dict_.subDict("collapseEdgesCoeffs")),
39  collapseFacesCoeffDict_(dict_.subOrEmptyDict("collapseFacesCoeffs")),
40  meshQualityCoeffDict_(dict_.subOrEmptyDict("controlMeshQualityCoeffs")),
41  minLen_(collapseEdgesCoeffDict_.lookup<scalar>("minimumEdgeLength")),
42  maxCos_
43  (
44  ::cos
45  (
46  collapseEdgesCoeffDict_.lookup<scalar>
47  (
48  "maximumMergeAngle",
50  )
51  )
52  ),
53  edgeReductionFactor_
54  (
55  meshQualityCoeffDict_.lookupOrDefault<scalar>("edgeReductionFactor", -1)
56  ),
57  maxIterations_
58  (
59  meshQualityCoeffDict_.lookupOrAddDefault<label>("maximumIterations", 1)
60  ),
61  maxSmoothIters_
62  (
63  meshQualityCoeffDict_.lookupOrAddDefault<label>
64  (
65  "maximumSmoothingIterations",
66  0
67  )
68  ),
69  initialFaceLengthFactor_
70  (
71  collapseFacesCoeffDict_.lookupOrAddDefault<scalar>
72  (
73  "initialFaceLengthFactor",
74  -1
75  )
76  ),
77  faceReductionFactor_
78  (
79  meshQualityCoeffDict_.lookupOrAddDefault<scalar>
80  (
81  "faceReductionFactor",
82  -1
83  )
84  ),
85  maxPointErrorCount_
86  (
87  meshQualityCoeffDict_.lookupOrAddDefault<label>("maxPointErrorCount", 0)
88  )
89 {}
90 
91 
92 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
93 
95 {
96  os << "Merging:" << nl
97  << " edges with length less than " << minLen() << " meters" << nl
98  << " edges split by a point with edges in line to within "
99  << radToDeg(::acos(maxCos())) << " degrees" << nl
100  << " Minimum edge length reduction factor = "
101  << edgeReductionFactor() << nl
102  << endl;
103 
104  if (collapseFacesCoeffDict().empty())
105  {
106  os << "Face collapsing is off" << endl;
107  }
108  else
109  {
110  os << "Face collapsing is on" << endl;
111  os << " Initial face length factor = "<< initialFaceLengthFactor()
112  << endl;
113  }
114 
115  os << "Control mesh quality = " << controlMeshQuality().asText() << endl;
116 
117  if (controlMeshQuality())
118  {
119  os << " Minimum edge length reduction factor = "
120  << edgeReductionFactor() << nl
121  << " Minimum face area reduction factor = "
122  << faceReductionFactor() << endl;
123 
124  os << " Maximum number of collapse iterations = " << maxIterations()
125  << endl;
126 
127  os << " Maximum number of edge/face reduction factor smoothing "
128  << "iterations = " << maxSmoothIters() << endl;
129 
130  os << " Maximum number of times a point can contribute to bad "
131  << "faces across " << nl
132  << " collapse iterations = " << maxPointErrorCount()
133  << endl;
134  }
135 
136  os << "Selectively disabling wanted collapses until resulting quality"
137  << " satisfies constraints in system/meshQualityDict" << nl
138  << endl;
139 }
140 
141 
142 // ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:61
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
polyMeshFilterSettings(const dictionary &dict)
Construct from dictionary.
void writeSettings(Ostream &os) const
Write the settings to a stream.
scalar radToDeg(const scalar rad)
Convert radians to degrees.
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
static const char nl
Definition: Ostream.H:266
dimensionedScalar cos(const dimensionedScalar &ds)
const unitConversion unitDegrees
dimensionedScalar acos(const dimensionedScalar &ds)
dictionary dict