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-2026 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  advectionDiffusion
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  tolerance 1e-4;
123  relTol 0;
124  }
125 
126  yWall
127  {
128  solver GAMG;
129  smoother symGaussSeidel;
130  tolerance 1e-4;
131  relTol 0;
132  }
133 
134  relaxationFactors
135  {
136  equations
137  {
138  .
139  .
140  yWall 0.7;
141  .
142  .
143  }
144  }
145  \endverbatim
146 
147 See also
148  Foam::patchDistMethod::Poisson
149  Foam::patchDistMethod::meshWave
150  Foam::wallDist
151 
152 SourceFiles
153  advectionDiffusionPatchDistMethod.C
154 
155 \*---------------------------------------------------------------------------*/
156 
157 #ifndef advectionDiffusionPatchDistMethod_H
158 #define advectionDiffusionPatchDistMethod_H
159 
160 #include "patchDistMethod.H"
161 
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 
164 namespace Foam
165 {
166 namespace patchDistMethods
167 {
168 
169 /*---------------------------------------------------------------------------*\
170  Class advectionDiffusion Declaration
171 \*---------------------------------------------------------------------------*/
172 
173 class advectionDiffusion
174 :
175  public patchDistMethod
176 {
177  // Private Data
178 
179  //- Sub-dictionary of coefficients
180  dictionary coeffs_;
181 
182  //- Run-time selected method to predict the distance-to-wall field
183  autoPtr<patchDistMethod> pdmPredictor_;
184 
185  //- Diffusion coefficient multiplying y*laplacian(y)
186  scalar epsilon_;
187 
188  //- Convergence tolerance for the iterations of the advection-diffusion
189  // equation to correct the distance-to-patch and normal-to-patch fields
190  scalar tolerance_;
191 
192  //- Maximum number of iterations of the advection-diffusion equation
193  // to correct the distance-to-patch and normal-to-patch fields
194  int maxIter_;
195 
196  //- Flag to indicate the predictor step has been executed
197  bool predicted_;
198 
199 
200 public:
201 
202  //- Runtime type information
203  TypeName("advectionDiffusion");
204 
205 
206  // Constructors
207 
208  //- Construct from coefficients dictionary, mesh
209  // and fixed-value patch set
211  (
212  const dictionary& dict,
213  const fvMesh& mesh,
214  const labelHashSet& patchIDs
215  );
216 
217  //- Disallow default bitwise copy construction
218  advectionDiffusion(const advectionDiffusion&) = delete;
219 
220 
221  // Member Functions
222 
223  //- Correct the given distance-to-patch field
224  virtual bool correct(volScalarField& y);
225 
226  //- Correct the given distance-to-patch and normal-to-patch fields
227  virtual bool correct(volScalarField& y, volVectorField& n);
228 
229 
230  // Member Operators
231 
232  //- Disallow default bitwise assignment
233  void operator=(const advectionDiffusion&) = delete;
234 };
235 
236 
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238 
239 } // End namespace patchDistMethods
240 } // End namespace Foam
241 
242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
243 
244 #endif
245 
246 // ************************************************************************* //
scalar y
label n
Generic GeometricField class.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
Specialisation of patchDist for wall distance calculation.
Calculation of approximate distance to nearest patch for all cells and boundary by solving the Eikona...
void operator=(const advectionDiffusion &)=delete
Disallow default bitwise assignment.
virtual bool correct(volScalarField &y)
Correct the given distance-to-patch field.
TypeName("advectionDiffusion")
Runtime type information.
advectionDiffusion(const dictionary &dict, const fvMesh &mesh, const labelHashSet &patchIDs)
Construct from coefficients dictionary, mesh.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
Namespace for OpenFOAM.
dictionary dict