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  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 "polyMeshFilterSettings.H"
30 #include "unitConversion.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
35 :
36  dict_(dict),
37  controlMeshQuality_
38  (
39  dict_.getOrDefault<Switch>("controlMeshQuality", false)
40  ),
41  collapseEdgesCoeffDict_(dict_.subDict("collapseEdgesCoeffs")),
42  collapseFacesCoeffDict_(dict_.subOrEmptyDict("collapseFacesCoeffs")),
43  meshQualityCoeffDict_(dict_.subOrEmptyDict("controlMeshQualityCoeffs")),
44  minLen_(collapseEdgesCoeffDict_.get<scalar>("minimumEdgeLength")),
45  maxCos_
46  (
47  ::cos
48  (
49  degToRad
50  (
51  collapseEdgesCoeffDict_.get<scalar>("maximumMergeAngle")
52  )
53  )
54  ),
55  edgeReductionFactor_
56  (
57  meshQualityCoeffDict_.getOrDefault<scalar>("edgeReductionFactor", -1)
58  ),
59  maxIterations_
60  (
61  meshQualityCoeffDict_.getOrAdd<label>("maximumIterations", 1)
62  ),
63  maxSmoothIters_
64  (
65  meshQualityCoeffDict_.getOrAdd<label>("maximumSmoothingIterations", 0)
66  ),
67  initialFaceLengthFactor_
68  (
69  collapseFacesCoeffDict_.getOrAdd<scalar>("initialFaceLengthFactor", -1)
70  ),
71  faceReductionFactor_
72  (
73  meshQualityCoeffDict_.getOrAdd<scalar>("faceReductionFactor", -1)
74  ),
75  maxPointErrorCount_
76  (
77  meshQualityCoeffDict_.getOrAdd<label>("maxPointErrorCount", 0)
78  )
79 {}
80 
81 
82 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
83 
85 {
86  os << "Merging:" << nl
87  << " edges with length less than " << minLen() << " metres" << nl
88  << " edges split by a point with edges in line to within "
89  << radToDeg(::acos(maxCos())) << " degrees" << nl
90  << " Minimum edge length reduction factor = "
91  << edgeReductionFactor() << nl
92  << endl;
93 
94  if (collapseFacesCoeffDict().empty())
95  {
96  os << "Face collapsing is off" << endl;
97  }
98  else
99  {
100  os << "Face collapsing is on" << endl;
101  os << " Initial face length factor = "<< initialFaceLengthFactor()
102  << endl;
103  }
104 
105  os << "Control mesh quality = " << controlMeshQuality().c_str() << endl;
106 
107  if (controlMeshQuality())
108  {
109  os << " Minimum edge length reduction factor = "
110  << edgeReductionFactor() << nl
111  << " Minimum face area reduction factor = "
112  << faceReductionFactor() << endl;
113 
114  os << " Maximum number of collapse iterations = " << maxIterations()
115  << endl;
116 
117  os << " Maximum number of edge/face reduction factor smoothing "
118  << "iterations = " << maxSmoothIters() << endl;
119 
120  os << " Maximum number of times a point can contribute to bad "
121  << "faces across " << nl
122  << " collapse iterations = " << maxPointErrorCount()
123  << endl;
124  }
125 
126  os << "Selectively disabling wanted collapses until resulting quality"
127  << " satisfies constraints in system/meshQualityDict" << nl
128  << endl;
129 }
130 
131 
132 // ************************************************************************* //
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:77
Foam::polyMeshFilterSettings::writeSettings
void writeSettings(Ostream &os) const
Write the settings to a stream.
Definition: polyMeshFilterSettings.C:84
Foam::polyMeshFilterSettings::polyMeshFilterSettings
polyMeshFilterSettings(const dictionary &dict)
Construct from dictionary.
Definition: polyMeshFilterSettings.C:34
unitConversion.H
Unit conversion functions.
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::getOrAdd
static T getOrAdd(dictionary &dict, const char *name, const T deflt)
Definition: debug.C:101
polyMeshFilterSettings.H
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:123
os
OBJstream os(runTime.globalPath()/outputName)
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:404
Foam::acos
dimensionedScalar acos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:268
Foam::PtrListOps::get
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
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