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