turbulentDFSEMInletFvPatchVectorField.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 OpenFOAM Foundation
9 Copyright (C) 2016-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::turbulentDFSEMInletFvPatchVectorField
29
30Group
31 grpInletBoundaryConditions
32
33Description
34 The \c turbulentDFSEMInlet is a synthesised-eddy based velocity inlet
35 boundary condition to generate synthetic turbulence-alike time-series
36 from a given set of turbulence statistics for LES and hybrid RANS-LES
37 computations.
38
39 Reference:
40 \verbatim
41 Standard model (tag:PCR):
42 Poletto, R., Craft, T., & Revell, A. (2013).
43 A new divergence free synthetic eddy method for
44 the reproduction of inlet flow conditions for LES.
45 Flow, turbulence and combustion, 91(3), 519-539.
46 DOI:10.1007/s10494-013-9488-2
47
48 Expression for the average length scale (tag:SST):
49 Shur, M., Strelets, M., Travin, A.,
50 Probst, A., Probst, S., Schwamborn, D., ... & Revell, A. (2018).
51 Improved embedded approaches.
52 In: Mockett C., Haase W., Schwamborn D. (eds)
53 Go4Hybrid: Grey area mitigation for hybrid RANS-LES methods.
54 Notes on Numerical Fluid Mechanics and Multidisciplinary Design.
55 p. 51-87. Springer, Cham.
56 DOI:10.1007/978-3-319-52995-0_3
57 \endverbatim
58
59Usage
60 Example of the boundary condition specification:
61 \verbatim
62 <patchName>
63 {
64 // Mandatory entries
65 type turbulentDFSEMInlet;
66 delta <scalar>;
67 R <PatchFunction1>;
68 U <PatchFunction1>;
69 L <PatchFunction1>;
70
71 // e.g.
72 // R uniform (<Rxx> <Rxy> <Rxz> <Ryy> <Ryz> <Rzz>);
73 // U uniform (<Ux> <Uy> <Uz>);
74 // L uniform <L>;
75
76 // Optional entries
77 d <scalar>;
78 nCellPerEddy <label>;
79 kappa <scalar>;
80 Uref <scalar>;
81 Lref <scalar>;
82 scale <scalar>;
83 m <scalar>;
84 writeEddies <bool>;
85
86 // Inherited entries
87 ...
88 }
89 \endverbatim
90
91 where the entries mean:
92 \table
93 Property | Description | Type | Reqd | Deflt
94 type | Type name: turbulentDFSEMInlet | word | yes | -
95 delta | Characteristic length scale | scalar | yes | -
96 R | Reynolds-stress tensor field <!--
97 --> | PatchFunction1<symmTensor> | yes | -
98 U | Mean velocity field <!--
99 --> | PatchFunction1<vector> | yes | -
100 L | Integral-length scale field <!--
101 --> | PatchFunction1<scalar> | yes | -
102 d | Ratio of sum of eddy volumes to eddy box volume <!--
103 --> i.e. eddy density (fill fraction) | scalar | no | 1.0
104 nCellPerEddy | Minimum eddy length in units of number of cells <!--
105 --> | label | no | 5
106 kappa | von Karman constant | scalar | no | 0.41
107 Uref | Normalisation factor for Reynolds-stress <!--
108 --> tensor and mean velocity | scalar | no | 1.0
109 Lref | Normalisation factor for integral-length scale <!--
110 --> | scalar | no | 1.0
111 scale | Heuristic scaling factor being applied <!--
112 --> on the normalisation factor C1 | scalar | no | 1.0
113 m | The power of V defined in C1 | scalar | no | 0.5
114 writeEddies | Flag to write eddies as OBJ file | bool | no | false
115 \endtable
116
117 The inherited entries are elaborated in:
118 - \link fixedValueFvPatchFields.H \endlink
119 - \link PatchFunction1.H \endlink
120 - \link MappedFile.H \endlink
121
122Note
123 - The \c delta value typically represents the characteristic scale of flow
124 or flow domain, e.g. a channel half height for plane channel flows.
125 - \c nCellPerEddy and \c scale entries are heuristic entries
126 which do not exist in the standard method, yet are necessary
127 to reproduce the results published in the original journal paper.
128 - In the original journal paper, \c C1 in Eq. 11 is not dimensionless.
129 It is not clear whether this dimensionality issue was intentional.
130 To alleviate this matter, users can alter the input entry \c m, which is
131 the power of the eddy-box volume defined in the \c C1, to obtain a
132 dimensionless \c C1 coefficient. The default value of \c m is 0.5,
133 which is the value stated in the original journal paper,
134 and \c m=1/3 leads to a dimensionless \c C1.
135
136SourceFiles
137 turbulentDFSEMInletFvPatchVectorField.C
138
139\*---------------------------------------------------------------------------*/
140
141#ifndef turbulentDFSEMInletFvPatchVectorField_H
142#define turbulentDFSEMInletFvPatchVectorField_H
143
145#include "Random.H"
146#include "eddy.H"
147#include "pointIndexHit.H"
148#include "PatchFunction1.H"
149
150// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151
152namespace Foam
153{
154
155/*---------------------------------------------------------------------------*\
156 Class turbulentDFSEMInletFvPatchVectorField Declaration
157\*---------------------------------------------------------------------------*/
158
159class turbulentDFSEMInletFvPatchVectorField
160:
161 public fixedValueFvPatchVectorField
162{
163 // Private Data
164
165 //- Maximum number of attempts when seeding eddies
166 static label seedIterMax_;
167
168 //- Mean velocity field
169 autoPtr<PatchFunction1<vector>> U_;
170
171 //- Reynolds stress tensor field
172 autoPtr<PatchFunction1<symmTensor>> R_;
173
174 //- Integral-length scale field
175 autoPtr<PatchFunction1<scalar>> L_;
176
177 //- Characteristic length scale
178 const scalar delta_;
179
180 //- Ratio of sum of eddy volumes to eddy box volume, i.e. eddy density
181 const scalar d_;
182
183 //- von Karman constant
184 const scalar kappa_;
185
186 //- Normalisation factor for Reynolds-stress tensor and mean velocity
187 const scalar Uref_;
188
189 //- Normalisation factor for integral-length scale
190 const scalar Lref_;
191
192 //- Heuristic scaling factor being applied on the normalisation factor
193 const scalar scale_;
194
195 //- The power of V defined in C1
196 const scalar m_;
197
198 //- Minimum eddy length in units of number of cells
199 const label nCellPerEddy_;
200
201
202 // Patch information
203
204 //- Patch area - total across all processors
205 scalar patchArea_;
206
207 //- Decomposed patch faces as a list of triangles
208 faceList triFace_;
209
210 //- Addressing from per triangle to patch face
211 labelList triToFace_;
212
213 //- Cumulative triangle area per triangle face
214 scalarList triCumulativeMagSf_;
215
216 //- Cumulative area fractions per processor
217 scalarList sumTriMagSf_;
218
219 //- Patch normal into the domain
220 vector patchNormal_;
221
222 //- Patch bounds (local processor)
223 boundBox patchBounds_;
224
225
226 // Eddy information
227
228 //- List of eddies
229 List<eddy> eddies_;
230
231 //- Eddy box volume
232 scalar v0_;
233
234 //- Random number generator
235 Random rndGen_;
236
237 //- Integral-length scale per patch face
238 scalarField sigmax_;
239
240 //- Maximum integral-length scale (across all processors)
241 scalar maxSigmaX_;
242
243 //- Global number of eddies
244 label nEddy_;
245
246 //- Current time index (used for updating)
247 label curTimeIndex_;
248
249 //- Single processor contains all eddies (flag)
250 bool singleProc_;
251
252 //- Flag to write the eddies to file
253 bool writeEddies_;
254
255
256 // Private Member Functions
257
258 //- Write Lumley coefficients to file
259 void writeLumleyCoeffs() const;
260
261 //- Write eddy info in OBJ format
262 void writeEddyOBJ() const;
263
264 //- Initialise info for patch point search
265 void initialisePatch();
266
267 //- Initialise the eddy box
268 void initialiseEddyBox();
269
270 //- Set a new eddy position
271 pointIndexHit setNewPosition(const bool global);
272
273 //- Initialise eddies
274 void initialiseEddies();
275
276 //- Convect the eddies with the bulk velocity
277 void convectEddies(const vector& UBulk, const scalar deltaT);
278
279 //- Return velocity fluctuation vector at a given point
280 vector uPrimeEddy(const List<eddy>& eddies, const point& globalX) const;
281
282 //- Return eddies from remote processors that interact with local
283 //- processor
284 void calcOverlappingProcEddies
285 (
286 List<List<eddy>>& overlappingEddies
287 ) const;
288
289
290public:
291
292 //- Runtime type information
293 TypeName("turbulentDFSEMInlet");
294
295
296 // Constructors
297
298 //- Construct from patch and internal field
300 (
301 const fvPatch&,
303 );
304
305 //- Construct from patch, internal field and dictionary
307 (
308 const fvPatch&,
310 const dictionary&
311 );
312
313 //- Construct by mapping given turbulentDFSEMInletFvPatchVectorField
314 //- onto a new patch
316 (
318 const fvPatch&,
320 const fvPatchFieldMapper&
321 );
322
323 //- Construct as copy
325 (
327 );
328
329 //- Construct and return a clone
330 virtual tmp<fvPatchVectorField> clone() const
331 {
333 (
335 );
336 }
337
338 //- Construct as copy setting internal field reference
340 (
343 );
344
345 //- Construct and return a clone setting internal field reference
347 (
349 ) const
350 {
352 (
354 );
355 }
356
357
358 //- Destructor
359 virtual ~turbulentDFSEMInletFvPatchVectorField() = default;
360
361
362 // Member Functions
363
364 //- Check if input Reynolds stresses are valid
365 // Realizability conditions (tag:S):
366 // Schumann, U. (1977).
367 // Realizability of Reynolds‐stress turbulence models.
368 // The Physics of Fluids, 20(5), 721-725.
369 // DOI:10.1063/1.861942
370 static void checkStresses(const symmTensorField& R);
371
372 //- Check if input Reynolds stresses are valid
373 static void checkStresses(const scalarField& R);
374
375
376 // Mapping
377
378 //- Map (and resize as needed) from self given a mapping object
379 virtual void autoMap(const fvPatchFieldMapper& m);
380
381 //- Reverse map the given fvPatchField onto this fvPatchField
382 virtual void rmap
383 (
384 const fvPatchVectorField& ptf,
385 const labelList& addr
386 );
387
388
389 // Evaluation
390
391 //- Update the coefficients associated with the patch field
392 virtual void updateCoeffs();
393
394
395 // IO
396
397 //- Write
398 virtual void write(Ostream&) const;
399};
400
401
402// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
403
404} // End namespace Foam
405
406// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
407
408#endif
409
410// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:66
Random number generator.
Definition: Random.H:60
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:64
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A FieldMapper for finite-volume patch fields.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:71
A class for managing temporary objects.
Definition: tmp.H:65
The turbulentDFSEMInlet is a synthesised-eddy based velocity inlet boundary condition to generate syn...
static void checkStresses(const symmTensorField &R)
Check if input Reynolds stresses are valid.
virtual void rmap(const fvPatchVectorField &ptf, const labelList &addr)
Reverse map the given fvPatchField onto this fvPatchField.
virtual tmp< fvPatchVectorField > clone(const DimensionedField< vector, volMesh > &iF) const
Construct and return a clone setting internal field reference.
virtual ~turbulentDFSEMInletFvPatchVectorField()=default
Destructor.
virtual tmp< fvPatchVectorField > clone() const
Construct and return a clone.
virtual void autoMap(const fvPatchFieldMapper &m)
Map (and resize as needed) from self given a mapping object.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
TypeName("turbulentDFSEMInlet")
Runtime type information.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition: List.H:66
List< scalar > scalarList
A List of scalars.
Definition: scalarList.H:64
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Field< symmTensor > symmTensorField
Specialisation of Field<T> for symmTensor.
List< face > faceList
A List of faces.
Definition: faceListFwd.H:47
fvPatchField< vector > fvPatchVectorField
runTime write()
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73