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 | Copyright (C) 2011-2016 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::turbulentInletFvPatchField
26 
27 Group
28  grpInletBoundaryConditions
29 
30 Description
31  This boundary condition generates a fluctuating inlet condition by adding
32  a random component to a reference (mean) field.
33 
34  \f[
35  x_p = (1 - \alpha) x_p^{n-1} + \alpha (x_{ref} + s C_{RMS} x_{ref})
36  \f]
37 
38  where
39 
40  \vartable
41  x_p | patch values
42  x_{ref} | reference patch values
43  n | time level
44  \alpha | fraction of new random component added to previous time value
45  C_{RMS} | RMS coefficient
46  s | fluctuation scale
47  \endvartable
48 
49 Usage
50  \table
51  Property | Description | Required | Default value
52  fluctuationScale | RMS fluctuation scale (fraction of mean) | yes |
53  referenceField | reference (mean) field | yes |
54  alpha | fraction of new random component added to previous| no| 0.1
55  \endtable
56 
57  Example of the boundary condition specification:
58  \verbatim
59  <patchName>
60  {
61  type turbulentInlet;
62  fluctuationScale 0.1;
63  referenceField uniform 10;
64  alpha 0.1;
65  }
66  \endverbatim
67 
68 See also
69  Foam::fixedValueFvPatchField
70 
71 SourceFiles
72  turbulentInletFvPatchField.C
73 
74 \*---------------------------------------------------------------------------*/
75 
76 #ifndef turbulentInletFvPatchField_H
77 #define turbulentInletFvPatchField_H
78 
79 #include "Random.H"
81 
82 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
83 
84 namespace Foam
85 {
86 
87 /*---------------------------------------------------------------------------*\
88  Class turbulentInletFvPatchField Declaration
89 \*---------------------------------------------------------------------------*/
90 
91 template<class Type>
92 class turbulentInletFvPatchField
93 :
94  public fixedValueFvPatchField<Type>
95 {
96  // Private data
97 
98  //- Random number generator
99  Random ranGen_;
100 
101  //- Fluctuation scale
102  Type fluctuationScale_;
103 
104  //- Reference field
105  Field<Type> referenceField_;
106 
107  //- Fraction of RMS component to apply to last time step values
108  scalar alpha_;
109 
110  //- Current time index (used for updating)
111  label curTimeIndex_;
112 
113 
114 public:
115 
116  //- Runtime type information
117  TypeName("turbulentInlet");
118 
119 
120  // Constructors
121 
122  //- Construct from patch and internal field
124  (
125  const fvPatch&,
126  const DimensionedField<Type, volMesh>&
127  );
128 
129  //- Construct from patch, internal field and dictionary
131  (
132  const fvPatch&,
133  const DimensionedField<Type, volMesh>&,
134  const dictionary&
135  );
136 
137  //- Construct by mapping given turbulentInletFvPatchField
138  // onto a new patch
140  (
142  const fvPatch&,
144  const fvPatchFieldMapper&
145  );
146 
147  //- Construct as copy
149  (
151  );
152 
153  //- Construct and return a clone
154  virtual tmp<fvPatchField<Type>> clone() const
155  {
156  return tmp<fvPatchField<Type>>
157  (
159  );
160  }
161 
162  //- Construct as copy setting internal field reference
164  (
167  );
168 
169  //- Construct and return a clone setting internal field reference
171  (
173  ) const
174  {
175  return tmp<fvPatchField<Type>>
176  (
177  new turbulentInletFvPatchField<Type>(*this, iF)
178  );
179  }
180 
181 
182  // Member functions
183 
184  // Access
185 
186  //- Return the fluctuation scale
187  const Type& fluctuationScale() const
188  {
189  return fluctuationScale_;
190  }
191 
192  //- Return reference to the fluctuation scale to allow adjustment
193  Type& fluctuationScale()
194  {
195  return fluctuationScale_;
196  }
198  //- Return the reference field
199  const Field<Type>& referenceField() const
200  {
201  return referenceField_;
202  }
203 
204  //- Return reference to the reference field to allow adjustment
206  {
207  return referenceField_;
208  }
209 
210 
211  // Mapping functions
212 
213  //- Map (and resize as needed) from self given a mapping object
214  virtual void autoMap
215  (
216  const fvPatchFieldMapper&
217  );
218 
219  //- Reverse map the given fvPatchField onto this fvPatchField
220  virtual void rmap
221  (
222  const fvPatchField<Type>&,
223  const labelList&
224  );
225 
226 
227  // Evaluation functions
228 
229  //- Update the coefficients associated with the patch field
230  virtual void updateCoeffs();
231 
232 
233  //- Write
234  virtual void write(Ostream&) const;
235 };
237 
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 
240 } // End namespace Foam
241 
242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
243 
244 #ifdef NoRepository
246 #endif
247 
248 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
249 
250 #endif
251 
252 // ************************************************************************* //
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
virtual void write(Ostream &) const
Write.
Pre-declare SubField and related Field type.
Definition: Field.H:57
turbulentInletFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
TypeName("turbulentInlet")
Runtime type information.
This boundary condition generates a fluctuating inlet condition by adding a random component to a ref...
Foam::fvPatchFieldMapper.
const Type & fluctuationScale() const
Return the fluctuation scale.
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
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...
A class for managing temporary objects.
Definition: PtrList.H:53
Namespace for OpenFOAM.
const Field< Type > & referenceField() const
Return the reference field.