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 -------------------------------------------------------------------------------
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 
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 
152 namespace Foam
153 {
154 
155 /*---------------------------------------------------------------------------*\
156  Class turbulentDFSEMInletFvPatchVectorField Declaration
157 \*---------------------------------------------------------------------------*/
158 
159 class 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 
290 public:
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  //- Return true if input Reynold stresses are valid
365  static bool checkStresses(const symmTensorField& Rf);
366 
367 
368  // Mapping
369 
370  //- Map (and resize as needed) from self given a mapping object
371  virtual void autoMap(const fvPatchFieldMapper& m);
372 
373  //- Reverse map the given fvPatchField onto this fvPatchField
374  virtual void rmap
375  (
376  const fvPatchVectorField& ptf,
377  const labelList& addr
378  );
379 
380 
381  // Evaluation
382 
383  //- Update the coefficients associated with the patch field
384  virtual void updateCoeffs();
385 
386 
387  // IO
388 
389  //- Write
390  virtual void write(Ostream&) const;
391 };
392 
393 
394 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
395 
396 } // End namespace Foam
397 
398 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
399 
400 #endif
401 
402 // ************************************************************************* //
Foam::fvPatchField< vector >
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:67
Foam::Random
Random number generator.
Definition: Random.H:59
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
Foam::scalarList
List< scalar > scalarList
A List of scalars.
Definition: scalarList.H:64
Foam::turbulentDFSEMInletFvPatchVectorField::checkStresses
static bool checkStresses(const symmTensorField &Rf)
Return true if input Reynold stresses are valid.
Definition: turbulentDFSEMInletFvPatchVectorField.C:822
pointIndexHit.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
PatchFunction1.H
Foam::turbulentDFSEMInletFvPatchVectorField::write
virtual void write(Ostream &) const
Write.
Definition: turbulentDFSEMInletFvPatchVectorField.C:1057
Foam::turbulentDFSEMInletFvPatchVectorField::turbulentDFSEMInletFvPatchVectorField
turbulentDFSEMInletFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
Definition: turbulentDFSEMInletFvPatchVectorField.C:612
Foam::symmTensorField
Field< symmTensor > symmTensorField
Specialisation of Field<T> for symmTensor.
Definition: primitiveFieldsFwd.H:56
Foam::PointIndexHit
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:52
Foam::Field< scalar >
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::turbulentDFSEMInletFvPatchVectorField::clone
virtual tmp< fvPatchVectorField > clone() const
Construct and return a clone.
Definition: turbulentDFSEMInletFvPatchVectorField.H:429
eddy.H
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:51
Random.H
Foam::turbulentDFSEMInletFvPatchVectorField::~turbulentDFSEMInletFvPatchVectorField
virtual ~turbulentDFSEMInletFvPatchVectorField()=default
Destructor.
Foam::turbulentDFSEMInletFvPatchVectorField::TypeName
TypeName("turbulentDFSEMInlet")
Runtime type information.
Foam::turbulentDFSEMInletFvPatchVectorField::rmap
virtual void rmap(const fvPatchVectorField &ptf, const labelList &addr)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: turbulentDFSEMInletFvPatchVectorField.C:914
Foam::fvPatchVectorField
fvPatchField< vector > fvPatchVectorField
Definition: fvPatchFieldsFwd.H:43
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::faceList
List< face > faceList
A List of faces.
Definition: faceListFwd.H:47
Foam::Vector< scalar >
Foam::List< face >
fixedValueFvPatchFields.H
Foam::turbulentDFSEMInletFvPatchVectorField
The turbulentDFSEMInlet is a synthesised-eddy based velocity inlet boundary condition to generate syn...
Definition: turbulentDFSEMInletFvPatchVectorField.H:258
Foam::turbulentDFSEMInletFvPatchVectorField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: turbulentDFSEMInletFvPatchVectorField.C:941
Foam::boundBox
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:63
Foam::turbulentDFSEMInletFvPatchVectorField::autoMap
virtual void autoMap(const fvPatchFieldMapper &m)
Map (and resize as needed) from self given a mapping object.
Definition: turbulentDFSEMInletFvPatchVectorField.C:890
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54