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-2024 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 Class
28  Foam::turbulentDFSEMInletFvPatchVectorField
29 
30 Group
31  grpInletBoundaryConditions
32 
33 Description
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 
59 Usage
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 
122 Note
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 
136 SourceFiles
137  turbulentDFSEMInletFvPatchVectorField.C
138 
139 \*---------------------------------------------------------------------------*/
140 
141 #ifndef turbulentDFSEMInletFvPatchVectorField_H
142 #define turbulentDFSEMInletFvPatchVectorField_H
143 
144 #include "fixedValueFvPatchFields.H"
145 #include "Random.H"
146 #include "eddy.H"
147 #include "pointIndexHit.H"
148 #include "PatchFunction1.H"
149 #include "labelledTri.H"
150 
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 
153 namespace Foam
154 {
155 
156 /*---------------------------------------------------------------------------*\
157  Class turbulentDFSEMInletFvPatchVectorField Declaration
158 \*---------------------------------------------------------------------------*/
159 
160 class turbulentDFSEMInletFvPatchVectorField
161 :
162  public fixedValueFvPatchVectorField
163 {
164  // Private Data
165 
166  //- Maximum number of attempts when seeding eddies
167  static label seedIterMax_;
168 
169  //- Mean velocity field
170  autoPtr<PatchFunction1<vector>> U_;
171 
172  //- Reynolds stress tensor field
173  autoPtr<PatchFunction1<symmTensor>> R_;
174 
175  //- Integral-length scale field
176  autoPtr<PatchFunction1<scalar>> L_;
177 
178  //- Characteristic length scale
179  const scalar delta_;
180 
181  //- Ratio of sum of eddy volumes to eddy box volume, i.e. eddy density
182  const scalar d_;
183 
184  //- von Karman constant
185  const scalar kappa_;
186 
187  //- Normalisation factor for Reynolds-stress tensor and mean velocity
188  const scalar Uref_;
189 
190  //- Normalisation factor for integral-length scale
191  const scalar Lref_;
192 
193  //- Heuristic scaling factor being applied on the normalisation factor
194  const scalar scale_;
195 
196  //- The power of V defined in C1
197  const scalar m_;
198 
199  //- Minimum eddy length in units of number of cells
200  const label nCellPerEddy_;
201 
202 
203  // Patch information
204 
205  //- Patch area - total across all processors
206  scalar patchArea_;
207 
208  //- The polyPatch faces as triangles, the index of each corresponds
209  //- to the undecomposed patch face index.
210  List<labelledTri> triFace_;
211 
212  //- Cumulative triangle area per triangle face (processor-local)
213  scalarList triCumulativeMagSf_;
214 
215  //- Cumulative area fractions per processor
216  scalarList sumTriMagSf_;
217 
218  //- Patch normal into the domain
219  vector patchNormal_;
220 
221  //- Patch bounds (local processor)
222  boundBox patchBounds_;
223 
224 
225  // Eddy information
226 
227  //- List of eddies
228  List<eddy> eddies_;
229 
230  //- Eddy box volume
231  scalar v0_;
232 
233  //- Random number generator
234  Random rndGen_;
235 
236  //- Integral-length scale per patch face
237  scalarField sigmax_;
238 
239  //- Maximum integral-length scale (across all processors)
240  scalar maxSigmaX_;
241 
242  //- Global number of eddies
243  label nEddy_;
244 
245  //- Current time index (used for updating)
246  label curTimeIndex_;
247 
248  //- Single processor contains all eddies (flag)
249  bool singleProc_;
250 
251  //- Flag to write the eddies to file
252  bool writeEddies_;
253 
254 
255  // Private Member Functions
256 
257  //- Write Lumley coefficients to file
258  void writeLumleyCoeffs() const;
259 
260  //- Write eddy info in OBJ format
261  void writeEddyOBJ() const;
262 
263  //- Initialise info for patch point search
264  void initialisePatch();
265 
266  //- Initialise the eddy box
267  void initialiseEddyBox();
268 
269  //- Set a new eddy position
270  pointIndexHit setNewPosition(const bool global);
271 
272  //- Initialise eddies
273  void initialiseEddies();
274 
275  //- Convect the eddies with the bulk velocity
276  void convectEddies(const vector& UBulk, const scalar deltaT);
277 
278  //- Return velocity fluctuation vector at a given point
279  vector uPrimeEddy(const List<eddy>& eddies, const point& globalX) const;
280 
281  //- Return eddies from remote processors that interact with local
282  //- processor
283  void calcOverlappingProcEddies
284  (
285  List<List<eddy>>& overlappingEddies
286  ) const;
287 
288 
289 public:
290 
291  //- Runtime type information
292  TypeName("turbulentDFSEMInlet");
293 
294 
295  // Constructors
296 
297  //- Construct from patch and internal field
299  (
300  const fvPatch&,
302  );
303 
304  //- Construct from patch, internal field and dictionary
306  (
307  const fvPatch&,
309  const dictionary&
310  );
311 
312  //- Construct by mapping given turbulentDFSEMInletFvPatchVectorField
313  //- onto a new patch
315  (
317  const fvPatch&,
319  const fvPatchFieldMapper&
320  );
321 
322  //- Construct as copy
324  (
326  );
327 
328  //- Construct as copy setting internal field reference
330  (
333  );
334 
335  //- Return a clone
336  virtual tmp<fvPatchField<vector>> clone() const
337  {
338  return fvPatchField<vector>::Clone(*this);
339  }
340 
341  //- Clone with an internal field reference
343  (
345  ) const
346  {
347  return fvPatchField<vector>::Clone(*this, iF);
348  }
349 
350 
351  //- Destructor
352  virtual ~turbulentDFSEMInletFvPatchVectorField() = default;
353 
354 
355  // Member Functions
356 
357  //- Check if input Reynolds stresses are valid
358  // Realizability conditions (tag:S):
359  // Schumann, U. (1977).
360  // Realizability of Reynolds‐stress turbulence models.
361  // The Physics of Fluids, 20(5), 721-725.
362  // DOI:10.1063/1.861942
363  static void checkStresses(const symmTensorField& R);
364 
365  //- Check if input Reynolds stresses are valid
366  static void checkStresses(const scalarField& R);
367 
368 
369  // Mapping
370 
371  //- Map (and resize as needed) from self given a mapping object
372  virtual void autoMap(const fvPatchFieldMapper& m);
373 
374  //- Reverse map the given fvPatchField onto this fvPatchField
375  virtual void rmap
376  (
377  const fvPatchVectorField& ptf,
378  const labelList& addr
379  );
380 
381 
382  // Evaluation
383 
384  //- Update the coefficients associated with the patch field
385  virtual void updateCoeffs();
386 
387 
388  // IO
389 
390  //- Write
391  virtual void write(Ostream&) const;
392 };
393 
394 
395 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
396 
397 } // End namespace Foam
398 
399 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
400 
401 #endif
402 
403 // ************************************************************************* //
List< scalar > scalarList
List of scalar.
Definition: scalarList.H:32
Field< symmTensor > symmTensorField
Specialisation of Field<T> for symmTensor.
fvPatchField< vector > fvPatchVectorField
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
TypeName("turbulentDFSEMInlet")
Runtime type information.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
This class describes the interaction of an object (often a face) and a point. It carries the info of ...
Definition: pointIndexHit.H:44
virtual void rmap(const fvPatchVectorField &ptf, const labelList &addr)
Reverse map the given fvPatchField onto this fvPatchField.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
static tmp< fvPatchField< Type > > Clone(const DerivedPatchField &pf, Args &&... args)
Clone a patch field, optionally with internal field reference etc.
Definition: fvPatchField.H:597
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
A FieldMapper for finite-volume patch fields.
Vector< scalar > vector
Definition: vector.H:57
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
virtual void autoMap(const fvPatchFieldMapper &m)
Map (and resize as needed) from self given a mapping object.
The turbulentDFSEMInlet is a synthesised-eddy based velocity inlet boundary condition to generate syn...
turbulentDFSEMInletFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
virtual tmp< fvPatchField< vector > > clone() const
Return a clone.
#define R(A, B, C, D, E, F, K, M)
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
List< label > labelList
A List of labels.
Definition: List.H:62
A class for managing temporary objects.
Definition: HashPtrTable.H:50
static void checkStresses(const symmTensorField &R)
Check if input Reynolds stresses are valid.
virtual ~turbulentDFSEMInletFvPatchVectorField()=default
Destructor.
Namespace for OpenFOAM.