turbulentInletFvPatchField.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) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::turbulentInletFvPatchField
28 
29 Group
30  grpInletBoundaryConditions
31 
32 Description
33  This boundary condition produces spatiotemporal-variant field by summing
34  a set of pseudo-random numbers and a given spatiotemporal-invariant mean
35  field. The field can be any type, e.g. scalarField. At a single point and
36  time, all components are summed by the same random number, e.g. velocity
37  components (u, v, w) are summed by the same random number, p; thus, output
38  is (u+p, v+p, w+p).
39 
40  The pseudo-random number generator obeys the probability density function
41  of the uniform distribution constrained by the range [0:1]. The seed for
42  the random number generator is hard-coded; therefore, it will produce the
43  same sequence of random numbers at every execution.
44 
45  \f[
46  x_p = (1 - \alpha) x_p^{n - 1} + \alpha (x_{ref} + c s R |x_{ref}|)
47  \f]
48  where
49 
50  \vartable
51  x_p | patch field
52  x_{ref} | spatiotemporal-invariant patch scalar
53  n | time level
54  \alpha | a scalar attempting to build two-temporal-point correlations
55  by heuristically adding a fraction of the new random component
56  to the previous time patch field
57  c | a heuristic automatically calculated correction term
58  to compensate energy level losses due to the alpha scalar
59  R | pseudo-random number [HARD-CODED seed]
60  s | fluctuation scale (proportional to the xRef)
61  \endvartable
62 
63 Usage
64  \table
65  Property | Description | Required | Default value
66  fluctuationScale | RMS fluctuation scale (fraction of mean) | yes |
67  referenceField | reference (mean) field | yes |
68  alpha | fraction of new random component added to previous | no | 0.1
69  \endtable
70 
71  Example of the boundary condition specification:
72  \verbatim
73  <patchName>
74  {
75  // Mandatory entries
76  type turbulentInlet;
77  fluctuationScale 0.1; // the term `s` above
78  referenceField uniform 10; // the term `xRef` above
79 
80  // Optional entries
81  alpha 0.1; // the term `alpha` above
82  }
83  \endverbatim
84 
85 Note
86  This boundary condition should not be used for DES or LES computations as a
87  turbulent velocity inflow condition, because the BC will not produce
88  turbulence-alike time-series, and will decay almost immediately downstream
89  of the inlet boundary although its historical name suggests the opposite.
90 
91  Nevertheless, the BC may be still used for other applications, e.g. as a
92  uniform-random noise source in aeroacoustics.
93 
94 SeeAlso
95  Foam::fixedValueFvPatchField
96 
97 SourceFiles
98  turbulentInletFvPatchField.C
99 
100 \*---------------------------------------------------------------------------*/
101 
102 #ifndef turbulentInletFvPatchField_H
103 #define turbulentInletFvPatchField_H
104 
105 #include "Random.H"
106 #include "fixedValueFvPatchFields.H"
107 
108 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
109 
110 namespace Foam
111 {
112 
113 /*---------------------------------------------------------------------------*\
114  Class turbulentInletFvPatchField Declaration
115 \*---------------------------------------------------------------------------*/
116 
117 template<class Type>
118 class turbulentInletFvPatchField
119 :
120  public fixedValueFvPatchField<Type>
121 {
122  // Private Data
123 
124  //- Random number generator
125  Random ranGen_;
126 
127  //- Fluctuation scale
128  Type fluctuationScale_;
129 
130  //- Reference field
131  Field<Type> referenceField_;
132 
133  //- Fraction of RMS component to apply to last time step values
134  scalar alpha_;
135 
136  //- Current time index (used for updating)
137  label curTimeIndex_;
138 
139 
140 public:
141 
142  //- Runtime type information
143  TypeName("turbulentInlet");
144 
145 
146  // Constructors
147 
148  //- Construct from patch and internal field
150  (
151  const fvPatch&,
152  const DimensionedField<Type, volMesh>&
153  );
154 
155  //- Construct from patch, internal field and dictionary
157  (
158  const fvPatch&,
159  const DimensionedField<Type, volMesh>&,
160  const dictionary&
161  );
162 
163  //- Construct by mapping given turbulentInletFvPatchField
164  //- onto a new patch
166  (
167  const turbulentInletFvPatchField<Type>&,
168  const fvPatch&,
169  const DimensionedField<Type, volMesh>&,
171  );
172 
173  //- Construct as copy
175  (
177  );
178 
179  //- Construct as copy setting internal field reference
181  (
184  );
185 
186  //- Return a clone
187  virtual tmp<fvPatchField<Type>> clone() const
188  {
189  return fvPatchField<Type>::Clone(*this);
190  }
191 
192  //- Clone with an internal field reference
194  (
196  ) const
197  {
198  return fvPatchField<Type>::Clone(*this, iF);
199  }
200 
201 
202  // Member Functions
203 
204  // Access
205 
206  //- Return the fluctuation scale
207  const Type& fluctuationScale() const
208  {
209  return fluctuationScale_;
210  }
211 
212  //- Return reference to the fluctuation scale to allow adjustment
213  Type& fluctuationScale()
214  {
215  return fluctuationScale_;
216  }
217 
218  //- Return the reference field
219  const Field<Type>& referenceField() const
220  {
221  return referenceField_;
222  }
223 
224  //- Return reference to the reference field to allow adjustment
225  Field<Type>& referenceField()
226  {
227  return referenceField_;
228  }
229 
230 
231  // Mapping functions
232 
233  //- Map (and resize as needed) from self given a mapping object
234  virtual void autoMap
235  (
236  const fvPatchFieldMapper&
237  );
238 
239  //- Reverse map the given fvPatchField onto this fvPatchField
240  virtual void rmap
241  (
242  const fvPatchField<Type>&,
243  const labelList&
244  );
245 
246 
247  // Evaluation functions
248 
249  //- Update the coefficients associated with the patch field
250  virtual void updateCoeffs();
251 
252 
253  //- Write
254  virtual void write(Ostream&) const;
255 };
256 
257 
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 
260 } // End namespace Foam
261 
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
264 #ifdef NoRepository
266 #endif
267 
268 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
269 
270 #endif
271 
272 // ************************************************************************* //
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual tmp< fvPatchField< Type > > clone() const
Return a clone.
virtual void write(Ostream &) const
Write.
static tmp< fvPatchField< Type > > Clone(const DerivedPatchField &pf, Args &&... args)
Clone a patch field, optionally with internal field reference etc.
Definition: fvPatchField.H:597
turbulentInletFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
TypeName("turbulentInlet")
Runtime type information.
This boundary condition produces spatiotemporal-variant field by summing a set of pseudo-random numbe...
A FieldMapper for finite-volume patch fields.
const Type & fluctuationScale() const
Return the fluctuation scale.
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
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
Namespace for OpenFOAM.
const Field< Type > & referenceField() const
Return the reference field.