Loading...
Searching...
No Matches
advectionDiffusionPatchDistMethod.H
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) 2015-2016 OpenFOAM Foundation
9 Copyright (C) 2020-2023 PCOpt/NTUA
10 Copyright (C) 2020-2023 FOSS GP
11-------------------------------------------------------------------------------
12License
13 This file is part of OpenFOAM.
14
15 OpenFOAM is free software: you can redistribute it and/or modify it
16 under the terms of the GNU General Public License as published by
17 the Free Software Foundation, either version 3 of the License, or
18 (at your option) any later version.
19
20 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
21 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
27
28Class
29 Foam::patchDistMethods::advectionDiffusion
30
31Description
32 Calculation of approximate distance to nearest patch for all cells and
33 boundary by solving the Eikonal equation in advection form with diffusion
34 smoothing.
35
36 If the diffusion coefficient is set to 0 this method is exact in principle
37 but the numerical schemes used are not rendering the scheme approximate, but
38 more accurate than the Poisson method. Also many models relying on the
39 distance to the wall benefit from this field being smooth and monotonic so
40 the addition of diffusion smoothing improves both the convergence and
41 stability of the solution of the Eikonal equation and the behavior of the
42 models using the distance field generated. However, it is not clear what
43 the optimum value for the diffusion coefficient epsilon should be; a
44 default value of 0.1 is provided but higher values may be preferable under
45 some circumstances.
46
47 Convergence is accelerated by first generating an approximate solution
48 using one of the simpler methods, e.g. Poisson. The method used for
49 this prediction step is specified in the 'advectionDiffusionCoeffs'
50 sub-dictionary, see below.
51
52 References:
53 \verbatim
54 P.G. Tucker, C.L. Rumsey, R.E. Bartels, R.T. Biedron,
55 "Transport equation based wall distance computations aimed at flows
56 with time-dependent geometry",
57 NASA/TM-2003-212680, December 2003.
58 \endverbatim
59
60 Example of the wallDist specification in fvSchemes:
61 \verbatim
62 laplacianSchemes
63 {
64 .
65 .
66 laplacian(yPsi) Gauss linear corrected;
67 laplacian(yWall) Gauss linear corrected;
68 .
69 .
70 }
71
72 wallDist
73 {
74 method advectionDiffusion;
75
76 // Optional entry enabling the calculation
77 // of the normal-to-wall field
78 nRequired false;
79
80 advectionDiffusionCoeffs
81 {
82 method Poisson;
83 epsilon 0.1;
84 tolerance 1e-3;
85 maxIter 10;
86 }
87 }
88 \endverbatim
89 Also the solver specification for yWall is required in fvSolution, e.g.
90 for simple cases:
91 \verbatim
92 yPsi
93 {
94 solver PCG;
95 preconditioner DIC;
96 tolerance 1e-4;
97 relTol 0;
98 }
99
100 yWall
101 {
102 solver PBiCG;
103 preconditioner DILU;
104 tolerance 1e-4;
105 relTol 0;
106 }
107
108 relaxationFactors
109 {
110 equations
111 {
112 .
113 .
114 yWall 1;
115 .
116 .
117 }
118 }
119
120 or for more complex cases:
121
122 yPsi
123 {
124 solver GAMG;
125 smoother GaussSeidel;
126 cacheAgglomeration true;
127 nCellsInCoarsestLevel 10;
128 agglomerator faceAreaPair;
129 mergeLevels 1;
130 tolerance 1e-4;
131 relTol 0;
132 }
133
134 yWall
135 {
136 solver GAMG;
137 smoother symGaussSeidel;
138 cacheAgglomeration true;
139 nCellsInCoarsestLevel 10;
140 agglomerator faceAreaPair;
141 mergeLevels 1;
142 tolerance 1e-4;
143 relTol 0;
144 }
145
146 relaxationFactors
147 {
148 equations
149 {
150 .
151 .
152 yWall 0.7;
153 .
154 .
155 }
156 }
157 \endverbatim
158
159See also
160 Foam::patchDistMethod::Poisson
161 Foam::patchDistMethod::meshWave
162 Foam::wallDist
163
164SourceFiles
165 advectionDiffusionPatchDistMethod.C
166
167\*---------------------------------------------------------------------------*/
168
169#ifndef advectionDiffusionPatchDistMethod_H
170#define advectionDiffusionPatchDistMethod_H
171
172#include "patchDistMethod.H"
173
174// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175
176namespace Foam
177{
178namespace patchDistMethods
179{
181/*---------------------------------------------------------------------------*\
182 Class advectionDiffusion Declaration
183\*---------------------------------------------------------------------------*/
184
185class advectionDiffusion
186:
187 public patchDistMethod
188{
189 // Private Member Data
190
191 //- Sub-dictionary of coefficients
192 dictionary coeffs_;
193
194 //- Run-time selected method to predict the distance-to-wall field
195 autoPtr<patchDistMethod> pdmPredictor_;
196
197 //- Diffusion coefficient multiplying y*laplacian(y)
198 scalar epsilon_;
199
200 //- Convergence tolerance for the iterations of the advection-diffusion
201 // equation to correct the distance-to-patch and normal-to-patch fields
202 scalar tolerance_;
203
204 //- Maximum number of iterations of the advection-diffusion equation
205 // to correct the distance-to-patch and normal-to-patch fields
206 int maxIter_;
207
208 //- Flag to indicate the predictor step has been executed
209 bool predicted_;
210
211 //- Check mesh before computing the distance field and write the mesh
212 //- points if at least one check fails.
213 // advectionDiffusion is frequently used within optimisation loops
214 // since it is differentiable. In shape optimisation, the
215 // re-computation of mesh distances is performed at the very beginning
216 // of a new optimisation cycle, due to inheriting from MeshObject. If
217 // the mesh quality is poor enough, the advectionDiffusion PDE might
218 // diverge and crash the run, before the problematic mesh is written
219 // to files for inspection. By setting this flag to true, the mesh is
220 // written to files before the solution of the advectionDiffusion PDE,
221 // if some mesh check fails.
222 bool checkAndWriteMesh_;
223
224 // Private Member Functions
225
226 //- No copy construct
227 advectionDiffusion(const advectionDiffusion&) = delete;
228
229 //- No copy assignment
230 void operator=(const advectionDiffusion&) = delete;
231
232
233public:
234
235 //- Runtime type information
236 TypeName("advectionDiffusion");
237
238
239 // Constructors
240
241 //- Construct from coefficients dictionary, mesh
242 // and fixed-value patch set
243 advectionDiffusion
244 (
245 const dictionary& dict,
246 const fvMesh& mesh,
248 );
249
250
251 // Member Functions
252
253 //- Correct the given distance-to-patch field
254 virtual bool correct(volScalarField& y);
255
256 //- Correct the given distance-to-patch and normal-to-patch fields
257 virtual bool correct(volScalarField& y, volVectorField& n);
258};
259
260
261// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262
263} // End namespace patchDistMethods
264} // End namespace Foam
265
266// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267
268#endif
269
270// ************************************************************************* //
scalar y
label n
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
patchDistMethod(const patchDistMethod &)=delete
No copy construct.
const labelHashSet & patchIDs() const
Return the patchIDs.
TypeName("advectionDiffusion")
Runtime type information.
thermo correct()
dynamicFvMesh & mesh
Namespace for OpenFOAM.
GeometricField< vector, fvPatchField, volMesh > volVectorField
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
Definition HashSet.H:85
GeometricField< scalar, fvPatchField, volMesh > volScalarField
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68