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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2013 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "polyMeshFilterSettings.H"
29 #include "unitConversion.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
34 :
35  dict_(dict),
36  controlMeshQuality_
37  (
38  dict_.lookupOrDefault<Switch>("controlMeshQuality", false)
39  ),
40  collapseEdgesCoeffDict_(dict_.subDict("collapseEdgesCoeffs")),
41  collapseFacesCoeffDict_(dict_.subOrEmptyDict("collapseFacesCoeffs")),
42  meshQualityCoeffDict_(dict_.subOrEmptyDict("controlMeshQualityCoeffs")),
43  minLen_(collapseEdgesCoeffDict_.get<scalar>("minimumEdgeLength")),
44  maxCos_
45  (
46  ::cos
47  (
48  degToRad
49  (
50  collapseEdgesCoeffDict_.get<scalar>("maximumMergeAngle")
51  )
52  )
53  ),
54  edgeReductionFactor_
55  (
56  meshQualityCoeffDict_.lookupOrDefault<scalar>("edgeReductionFactor", -1)
57  ),
58  maxIterations_
59  (
60  meshQualityCoeffDict_.lookupOrAddDefault<label>("maximumIterations", 1)
61  ),
62  maxSmoothIters_
63  (
64  meshQualityCoeffDict_.lookupOrAddDefault<label>
65  (
66  "maximumSmoothingIterations",
67  0
68  )
69  ),
70  initialFaceLengthFactor_
71  (
72  collapseFacesCoeffDict_.lookupOrAddDefault<scalar>
73  (
74  "initialFaceLengthFactor",
75  -1
76  )
77  ),
78  faceReductionFactor_
79  (
80  meshQualityCoeffDict_.lookupOrAddDefault<scalar>
81  (
82  "faceReductionFactor",
83  -1
84  )
85  ),
86  maxPointErrorCount_
87  (
88  meshQualityCoeffDict_.lookupOrAddDefault<label>("maxPointErrorCount", 0)
89  )
90 {}
91 
92 
93 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
94 
96 {
97  os << "Merging:" << nl
98  << " edges with length less than " << minLen() << " metres" << nl
99  << " edges split by a point with edges in line to within "
100  << radToDeg(::acos(maxCos())) << " degrees" << nl
101  << " Minimum edge length reduction factor = "
102  << edgeReductionFactor() << nl
103  << endl;
104 
105  if (collapseFacesCoeffDict().empty())
106  {
107  os << "Face collapsing is off" << endl;
108  }
109  else
110  {
111  os << "Face collapsing is on" << endl;
112  os << " Initial face length factor = "<< initialFaceLengthFactor()
113  << endl;
114  }
115 
116  os << "Control mesh quality = " << controlMeshQuality().c_str() << endl;
117 
118  if (controlMeshQuality())
119  {
120  os << " Minimum edge length reduction factor = "
121  << edgeReductionFactor() << nl
122  << " Minimum face area reduction factor = "
123  << faceReductionFactor() << endl;
124 
125  os << " Maximum number of collapse iterations = " << maxIterations()
126  << endl;
127 
128  os << " Maximum number of edge/face reduction factor smoothing "
129  << "iterations = " << maxSmoothIters() << endl;
130 
131  os << " Maximum number of times a point can contribute to bad "
132  << "faces across " << nl
133  << " collapse iterations = " << maxPointErrorCount()
134  << endl;
135  }
136 
137  os << "Selectively disabling wanted collapses until resulting quality"
138  << " satisfies constraints in system/meshQualityDict" << nl
139  << endl;
140 }
141 
142 
143 // ************************************************************************* //
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:70
Foam::polyMeshFilterSettings::writeSettings
void writeSettings(Ostream &os) const
Write the settings to a stream.
Definition: polyMeshFilterSettings.C:95
Foam::polyMeshFilterSettings::polyMeshFilterSettings
polyMeshFilterSettings(const dictionary &dict)
Construct from dictionary.
Definition: polyMeshFilterSettings.C:33
unitConversion.H
Unit conversion functions.
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
polyMeshFilterSettings.H
Foam::label
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:62
Foam::radToDeg
constexpr scalar radToDeg(const scalar rad) noexcept
Conversion from radians to degrees.
Definition: unitConversion.H:54
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::degToRad
constexpr scalar degToRad(const scalar deg) noexcept
Conversion from degrees to radians.
Definition: unitConversion.H:48
Foam::nl
constexpr char nl
Definition: Ostream.H:372
Foam::acos
dimensionedScalar acos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:268
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::cos
dimensionedScalar cos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:265