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>&,
170  const fvPatchFieldMapper&
171  );
172 
173  //- Construct as copy
175  (
177  );
178 
179  //- Construct and return a clone
180  virtual tmp<fvPatchField<Type>> clone() const
181  {
182  return tmp<fvPatchField<Type>>
183  (
185  );
186  }
187 
188  //- Construct as copy setting internal field reference
190  (
193  );
194 
195  //- Construct and return a clone setting internal field reference
197  (
199  ) const
200  {
201  return tmp<fvPatchField<Type>>
202  (
203  new turbulentInletFvPatchField<Type>(*this, iF)
204  );
205  }
206 
207 
208  // Member Functions
209 
210  // Access
211 
212  //- Return the fluctuation scale
213  const Type& fluctuationScale() const
214  {
215  return fluctuationScale_;
216  }
217 
218  //- Return reference to the fluctuation scale to allow adjustment
219  Type& fluctuationScale()
220  {
221  return fluctuationScale_;
222  }
223 
224  //- Return the reference field
225  const Field<Type>& referenceField() const
226  {
227  return referenceField_;
228  }
229 
230  //- Return reference to the reference field to allow adjustment
231  Field<Type>& referenceField()
232  {
233  return referenceField_;
234  }
235 
236 
237  // Mapping functions
238 
239  //- Map (and resize as needed) from self given a mapping object
240  virtual void autoMap
241  (
242  const fvPatchFieldMapper&
243  );
244 
245  //- Reverse map the given fvPatchField onto this fvPatchField
246  virtual void rmap
247  (
248  const fvPatchField<Type>&,
249  const labelList&
250  );
251 
252 
253  // Evaluation functions
254 
255  //- Update the coefficients associated with the patch field
256  virtual void updateCoeffs();
257 
258 
259  //- Write
260  virtual void write(Ostream&) const;
261 };
262 
263 
264 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
265 
266 } // End namespace Foam
267 
268 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
269 
270 #ifdef NoRepository
272 #endif
273 
274 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
275 
276 #endif
277 
278 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:51
Foam::turbulentInletFvPatchField::fluctuationScale
Type & fluctuationScale()
Return reference to the fluctuation scale to allow adjustment.
Definition: turbulentInletFvPatchField.H:275
Foam::Random
Random number generator.
Definition: Random.H:59
Foam::turbulentInletFvPatchField::rmap
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: turbulentInletFvPatchField.C:141
Foam::turbulentInletFvPatchField::clone
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
Definition: turbulentInletFvPatchField.H:236
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::turbulentInletFvPatchField::turbulentInletFvPatchField
turbulentInletFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: turbulentInletFvPatchField.C:34
Foam::turbulentInletFvPatchField::TypeName
TypeName("turbulentInlet")
Runtime type information.
Foam::fixedValueFvPatchField
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
Definition: fixedValueFvPatchField.H:80
Foam::turbulentInletFvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: turbulentInletFvPatchField.C:198
Foam::Field
Generic templated field type.
Definition: Field.H:63
turbulentInletFvPatchField.C
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::turbulentInletFvPatchField::fluctuationScale
const Type & fluctuationScale() const
Return the fluctuation scale.
Definition: turbulentInletFvPatchField.H:269
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
Random.H
Foam::turbulentInletFvPatchField::autoMap
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: turbulentInletFvPatchField.C:130
Foam::turbulentInletFvPatchField
This boundary condition produces spatiotemporal-variant field by summing a set of pseudo-random numbe...
Definition: turbulentInletFvPatchField.H:174
Foam::List< label >
fixedValueFvPatchFields.H
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::turbulentInletFvPatchField::referenceField
const Field< Type > & referenceField() const
Return the reference field.
Definition: turbulentInletFvPatchField.H:281
Foam::turbulentInletFvPatchField::referenceField
Field< Type > & referenceField()
Return reference to the reference field to allow adjustment.
Definition: turbulentInletFvPatchField.H:287
Foam::turbulentInletFvPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: turbulentInletFvPatchField.C:156
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54