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-2019 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  Velocity boundary condition including synthesised eddies for use with LES
35  and DES turbulent flows.
36 
37  Reference:
38  \verbatim
39  Poletto, R., Craft, T., & Revell, A. (2013).
40  A new divergence free synthetic eddy method for
41  the reproduction of inlet flow conditions for LES.
42  Flow, turbulence and combustion, 91(3), 519-539.
43  DOI:10.1007/s10494-013-9488-2
44  \endverbatim
45 
46  Reynolds stress, velocity and turbulence length scale values can either
47  be specified directly, or mapped. If mapping, the values should be
48  entered in the same form as the \c timeVaryingMappedFixedValue condition,
49  except that no interpolation in time is supported. These should be
50  located in the directory:
51 
52  \verbatim
53  \$FOAM_CASE/constant/boundaryData/<patchName>/points
54  \$FOAM_CASE/constant/boundaryData/<patchName>/0/\{R|U|L\}
55  \endverbatim
56 
57 Usage
58  \table
59  Property | Description | Required | Default value
60  value | Restart value | yes |
61  delta | Local limiting length scale | yes |
62  R | Reynolds stress field | no |
63  U | Velocity field | no |
64  L | Turbulence length scale field | no |
65  d | Eddy density (fill fraction) | no | 1
66  kappa | Von Karman constant | no | 0.41
67  mapMethod | Method to map reference values | no | nearestCell
68  perturb | Point perturbation for interpolation | no | 1e-5
69  interpolateR | Flag to interpolate the R field | no | false
70  interpolateL | Flag to interpolate the L field | no | false
71  interpolateU | Flag to interpolate the U field | no | false
72  writeEddies | Flag to write eddies as OBJ file | no | no
73  \endtable
74 
75 Note
76  - The \c delta value typically represents the characteristic scale of flow
77  or flow domain, e.g. a channel half-height
78  - For \c R, \c U and \c L specification: if the entry is not user input,
79  it is assumed that the data will be mapped
80 
81 SeeAlso
82  timeVaryingMappedFixedValueFvPatchField
83  turbulentDigitalFilterInlet
84 
85 SourceFiles
86  turbulentDFSEMInletFvPatchVectorField.C
87 
88 \*---------------------------------------------------------------------------*/
89 
90 #ifndef turbulentDFSEMInletFvPatchVectorField_H
91 #define turbulentDFSEMInletFvPatchVectorField_H
92 
94 #include "Random.H"
95 #include "eddy.H"
96 #include "pointIndexHit.H"
97 #include "instantList.H"
98 
99 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
100 
101 namespace Foam
102 {
103 
104 class pointToPointPlanarInterpolation;
105 
106 /*---------------------------------------------------------------------------*\
107  Class turbulentDFSEMInletFvPatchVectorField Declaration
108 \*---------------------------------------------------------------------------*/
109 
110 class turbulentDFSEMInletFvPatchVectorField
111 :
112  public fixedValueFvPatchVectorField
113 {
114  // Private Data
115 
116  //- Maximum number of attempts when seeding eddies
117  static label seedIterMax_;
118 
119  //- Characteristic length scale, e.g. half channel height
120  const scalar delta_;
121 
122  //- Ratio of sum of eddy volumes to eddy box volume; default = 1
123  const scalar d_;
124 
125  //- Von Karman constant
126  const scalar kappa_;
127 
128  //- Global numbering for faces
129  mutable autoPtr<globalIndex> globalFacesPtr_;
130 
131 
132  // Table reading for patch inlet flow properties
133 
134  //- Fraction of perturbation (fraction of bounding box) to add
135  scalar perturb_;
136 
137  //- Interpolation scheme to use (nearestCell | planarInterpolation)
138  word mapMethod_;
139 
140  //- 2D interpolation (for 'planarInterpolation' mapMethod)
141  mutable autoPtr<pointToPointPlanarInterpolation> mapperPtr_;
142 
143  //- Flag to identify to interpolate the R field
144  bool interpolateR_;
145 
146  //- Flag to identify to interpolate the L field
147  bool interpolateL_;
148 
149  //- Flag to identify to interpolate the U field
150  bool interpolateU_;
151 
152  //- Reynolds stress tensor
153  symmTensorField R_;
154 
155  //- Length scale
156  scalarField L_;
157 
158  //- Inlet velocity
159  vectorField U_;
160 
161  //- Mean inlet velocity
162  vector UMean_;
163 
164 
165  // Patch information
166 
167  //- Patch area - total across all processors
168  scalar patchArea_;
169 
170  //- Decomposed patch faces as a list of triangles
171  faceList triFace_;
172 
173  //- Addressing from per triangle to patch face
174  labelList triToFace_;
175 
176  //- Cumulative triangle area per triangle face
177  scalarList triCumulativeMagSf_;
178 
179  //- Cumulative area fractions per processor
180  scalarList sumTriMagSf_;
181 
182 
183  //- List of eddies
184  List<eddy> eddies_;
185 
186  //- Minimum number of cells required to resolve an eddy
187  label nCellPerEddy_;
188 
189  //- Patch normal into the domain
190  vector patchNormal_;
191 
192  //- Eddy box volume
193  scalar v0_;
194 
195  //- Random number generator
196  Random rndGen_;
197 
198  //- Length scale per patch face
199  scalarField sigmax_;
200 
201  //- Maximum length scale (across all processors)
202  scalar maxSigmaX_;
203 
204  //- Global number of eddies
205  label nEddy_;
206 
207  //- Current time index (used for updating)
208  label curTimeIndex_;
209 
210  //- Patch bounds (local processor)
211  boundBox patchBounds_;
212 
213  //- Single processor contains all eddies (flag)
214  bool singleProc_;
215 
216  //- Flag to write the eddies to file
217  bool writeEddies_;
218 
219 
220  // Private Member Functions
221 
222  //- Initialise info for patch point search
223  void initialisePatch();
224 
225  //- Initialise the eddy box
226  void initialiseEddyBox();
227 
228  //- Set a new eddy position
229  pointIndexHit setNewPosition(const bool global);
230 
231  //- Initialise eddies
232  void initialiseEddies();
233 
234  //- Convect the eddies
235  void convectEddies(const scalar deltaT);
236 
237  //- Calculate the velocity fluctuation at a point
238  vector uDashEddy(const List<eddy>& eddies, const point& globalX) const;
239 
240  //- Helper function to interpolate values from the boundary data or
241  //- read from dictionary
242  template<class Type>
243  tmp<Field<Type>> interpolateOrRead
244  (
245  const word& fieldName,
246  const dictionary& dict,
247  bool& interpolateField
248  ) const;
249 
250  //- Helper function to interpolate values from the boundary data
251  template<class Type>
252  tmp<Field<Type>> interpolateBoundaryData
253  (
254  const word& fieldName
255  ) const;
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  //- Return a reference to the patch mapper object
264  const pointToPointPlanarInterpolation& patchMapper() const;
265 
266  //- Return eddies from remote processors that interact with local
267  //- processor
268  void calcOverlappingProcEddies
269  (
270  List<List<eddy>>& overlappingEddies
271  ) const;
272 
273 
274 public:
275 
276  //- Runtime type information
277  TypeName("turbulentDFSEMInlet");
278 
279 
280  // Constructors
281 
282  //- Construct from patch and internal field
284  (
285  const fvPatch&,
287  );
288 
289  //- Construct from patch, internal field and dictionary
291  (
292  const fvPatch&,
294  const dictionary&
295  );
296 
297  //- Construct by mapping given turbulentDFSEMInletFvPatchVectorField
298  //- onto a new patch
300  (
302  const fvPatch&,
304  const fvPatchFieldMapper&
305  );
306 
307  //- Construct as copy
309  (
311  );
312 
313  //- Construct and return a clone
314  virtual tmp<fvPatchVectorField> clone() const
315  {
317  (
319  );
320  }
321 
322  //- Construct as copy setting internal field reference
324  (
327  );
328 
329  //- Construct and return a clone setting internal field reference
331  (
333  ) const
334  {
336  (
338  );
339  }
340 
341 
342  //- Destructor
343  virtual ~turbulentDFSEMInletFvPatchVectorField() = default;
344 
345 
346  // Member Functions
347 
348  //- Helper function to check that Reynold stresses are valid
349  static bool checkStresses(const symmTensorField& Rf);
350 
351 
352  // Mapping functions
353 
354  //- Map (and resize as needed) from self given a mapping object
355  virtual void autoMap(const fvPatchFieldMapper& m);
356 
357  //- Reverse map the given fvPatchField onto this fvPatchField
358  virtual void rmap
359  (
360  const fvPatchVectorField& ptf,
361  const labelList& addr
362  );
363 
364 
365  // Evaluation functions
366 
367  //- Update the coefficients associated with the patch field
368  virtual void updateCoeffs();
369 
370 
371  //- Write
372  virtual void write(Ostream&) const;
373 };
374 
375 
376 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
377 
378 } // End namespace Foam
379 
380 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
381 
382 #ifdef NoRepository
384 #endif
385 
386 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
387 
388 #endif
389 
390 // ************************************************************************* //
Foam::fvPatchField< vector >
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:71
instantList.H
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)
Helper function to check that Reynold stresses are valid.
Definition: turbulentDFSEMInletFvPatchVectorField.C:965
pointIndexHit.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::pointToPointPlanarInterpolation
Interpolates between two sets of unstructured points using 2D Delaunay triangulation....
Definition: pointToPointPlanarInterpolation.H:53
Foam::turbulentDFSEMInletFvPatchVectorField::write
virtual void write(Ostream &) const
Write.
Definition: turbulentDFSEMInletFvPatchVectorField.C:1183
Foam::turbulentDFSEMInletFvPatchVectorField::turbulentDFSEMInletFvPatchVectorField
turbulentDFSEMInletFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
Definition: turbulentDFSEMInletFvPatchVectorField.C:735
Foam::symmTensorField
Field< symmTensor > symmTensorField
Specialisation of Field<T> for symmTensor.
Definition: primitiveFieldsFwd.H:56
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:54
turbulentDFSEMInletFvPatchVectorFieldTemplates.C
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< symmTensor >
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:383
eddy.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
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:1050
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
Velocity boundary condition including synthesised eddies for use with LES and DES turbulent flows.
Definition: turbulentDFSEMInletFvPatchVectorField.H:179
Foam::turbulentDFSEMInletFvPatchVectorField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: turbulentDFSEMInletFvPatchVectorField.C:1071
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:1033
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