advectionDiffusionPatchDistMethod.H
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) 2015-2020 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 Class
25  Foam::patchDistMethods::advectionDiffusion
26 
27 Description
28  Calculation of approximate distance to nearest patch for all cells and
29  boundary by solving the Eikonal equation in advection form with diffusion
30  smoothing.
31 
32  If the diffusion coefficient is set to 0 this method is exact in principle
33  but the numerical schemes used are not rendering the scheme approximate, but
34  more accurate than the Poisson method. Also many models relying on the
35  distance to the wall benefit from this field being smooth and monotonic so
36  the addition of diffusion smoothing improves both the convergence and
37  stability of the solution of the Eikonal equation and the behavior of the
38  models using the distance field generated. However, it is not clear what
39  the optimum value for the diffusion coefficient epsilon should be; a
40  default value of 0.1 is provided but higher values may be preferable under
41  some circumstances.
42 
43  Convergence is accelerated by first generating an approximate solution
44  using one of the simpler methods, e.g. Poisson. The method used for
45  this prediction step is specified in the 'advectionDiffusionCoeffs'
46  sub-dictionary, see below.
47 
48  References:
49  \verbatim
50  P.G. Tucker, C.L. Rumsey, R.E. Bartels, R.T. Biedron,
51  "Transport equation based wall distance computations aimed at flows
52  with time-dependent geometry",
53  NASA/TM-2003-212680, December 2003.
54  \endverbatim
55 
56  Example of the wallDist specification in fvSchemes:
57  \verbatim
58  laplacianSchemes
59  {
60  .
61  .
62  laplacian(yPsi) Gauss linear corrected;
63  laplacian(yWall) Gauss linear corrected;
64  .
65  .
66  }
67 
68  wallDist
69  {
70  method advectionDiffusion;
71 
72  // Optional entry enabling the calculation
73  // of the normal-to-wall field
74  nRequired false;
75 
76  advectionDiffusionCoeffs
77  {
78  method Poisson;
79  epsilon 0.1;
80  tolerance 1e-3;
81  maxIter 10;
82  }
83  }
84  \endverbatim
85  Also the solver specification for yWall is required in fvSolution, e.g.
86  for simple cases:
87  \verbatim
88  yPsi
89  {
90  solver PCG;
91  preconditioner DIC;
92  tolerance 1e-4;
93  relTol 0;
94  }
95 
96  yWall
97  {
98  solver PBiCG;
99  preconditioner DILU;
100  tolerance 1e-4;
101  relTol 0;
102  }
103 
104  relaxationFactors
105  {
106  equations
107  {
108  .
109  .
110  yWall 1;
111  .
112  .
113  }
114  }
115 
116  or for more complex cases:
117 
118  yPsi
119  {
120  solver GAMG;
121  smoother GaussSeidel;
122  cacheAgglomeration true;
123  nCellsInCoarsestLevel 10;
124  agglomerator faceAreaPair;
125  mergeLevels 1;
126  tolerance 1e-4;
127  relTol 0;
128  }
129 
130  yWall
131  {
132  solver GAMG;
133  smoother symGaussSeidel;
134  cacheAgglomeration true;
135  nCellsInCoarsestLevel 10;
136  agglomerator faceAreaPair;
137  mergeLevels 1;
138  tolerance 1e-4;
139  relTol 0;
140  }
141 
142  relaxationFactors
143  {
144  equations
145  {
146  .
147  .
148  yWall 0.7;
149  .
150  .
151  }
152  }
153  \endverbatim
154 
155 See also
156  Foam::patchDistMethod::Poisson
157  Foam::patchDistMethod::meshWave
158  Foam::wallDist
159 
160 SourceFiles
161  advectionDiffusionPatchDistMethod.C
162 
163 \*---------------------------------------------------------------------------*/
164 
165 #ifndef advectionDiffusionPatchDistMethod_H
166 #define advectionDiffusionPatchDistMethod_H
167 
168 #include "patchDistMethod.H"
169 
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 
172 namespace Foam
173 {
174 namespace patchDistMethods
175 {
176 
177 /*---------------------------------------------------------------------------*\
178  Class advectionDiffusion Declaration
179 \*---------------------------------------------------------------------------*/
181 class advectionDiffusion
182 :
183  public patchDistMethod
184 {
185  // Private Member Data
186 
187  //- Sub-dictionary of coefficients
188  dictionary coeffs_;
189 
190  //- Run-time selected method to predict the distance-to-wall field
191  autoPtr<patchDistMethod> pdmPredictor_;
192 
193  //- Diffusion coefficient multiplying y*laplacian(y)
194  scalar epsilon_;
195 
196  //- Convergence tolerance for the iterations of the advection-diffusion
197  // equation to correct the distance-to-patch and normal-to-patch fields
198  scalar tolerance_;
199 
200  //- Maximum number of iterations of the advection-diffusion equation
201  // to correct the distance-to-patch and normal-to-patch fields
202  int maxIter_;
203 
204  //- Flag to indicate the predictor step has been executed
205  bool predicted_;
206 
207 
208 public:
209 
210  //- Runtime type information
211  TypeName("advectionDiffusion");
212 
213 
214  // Constructors
215 
216  //- Construct from coefficients dictionary, mesh
217  // and fixed-value patch set
219  (
220  const dictionary& dict,
221  const fvMesh& mesh,
222  const labelHashSet& patchIDs
223  );
224 
225  //- Disallow default bitwise copy construction
226  advectionDiffusion(const advectionDiffusion&) = delete;
227 
228 
229  // Member Functions
230 
231  //- Correct the given distance-to-patch field
232  virtual bool correct(volScalarField& y);
233 
234  //- Correct the given distance-to-patch and normal-to-patch fields
235  virtual bool correct(volScalarField& y, volVectorField& n);
236 
237 
238  // Member Operators
239 
240  //- Disallow default bitwise assignment
241  void operator=(const advectionDiffusion&) = delete;
242 };
243 
244 
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 
247 } // End namespace patchDistMethods
248 } // End namespace Foam
249 
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
251 
252 #endif
253 
254 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
void operator=(const advectionDiffusion &)=delete
Disallow default bitwise assignment.
fvMesh & mesh
scalar y
advectionDiffusion(const dictionary &dict, const fvMesh &mesh, const labelHashSet &patchIDs)
Construct from coefficients dictionary, mesh.
virtual bool correct(volScalarField &y)
Correct the given distance-to-patch field.
const labelHashSet & patchIDs() const
Return the patchIDs.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:95
label n
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
TypeName("advectionDiffusion")
Runtime type information.
Specialisation of patchDist for wall distance calculation.
Calculation of approximate distance to nearest patch for all cells and boundary by solving the Eikona...
Namespace for OpenFOAM.