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-2013 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  \heading Patch usage
50 
51  \table
52  Property | Description | Required | Default value
53  fluctuationScale | RMS fluctuation scale (fraction of mean) | yes |
54  referenceField | reference (mean) field | yes |
55  alpha | fraction of new random component added to previous| no| 0.1
56  \endtable
57 
58  Example of the boundary condition specification:
59  \verbatim
60  myPatch
61  {
62  type turbulentInlet;
63  fluctuationScale 0.1;
64  referenceField uniform 10;
65  alpha 0.1;
66  }
67  \endverbatim
68 
69 SeeAlso
70  Foam::fixedValueFvPatchField
71 
72 SourceFiles
73  turbulentInletFvPatchField.C
74 
75 \*---------------------------------------------------------------------------*/
76 
77 #ifndef turbulentInletFvPatchField_H
78 #define turbulentInletFvPatchField_H
79 
80 #include "Random.H"
82 
83 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
84 
85 namespace Foam
86 {
87 
88 /*---------------------------------------------------------------------------*\
89  Class turbulentInletFvPatchField Declaration
90 \*---------------------------------------------------------------------------*/
91 
92 template<class Type>
93 class turbulentInletFvPatchField
94 :
95  public fixedValueFvPatchField<Type>
96 {
97  // Private data
98 
99  //- Random number generator
100  Random ranGen_;
101 
102  //- Fluctuation scake
103  Type fluctuationScale_;
104 
105  //- Reference field
106  Field<Type> referenceField_;
107 
108  //- Fraction of RMS component to apply to last time step values
109  scalar alpha_;
110 
111  //- Current time index (used for updating)
112  label curTimeIndex_;
113 
114 
115 public:
116 
117  //- Runtime type information
118  TypeName("turbulentInlet");
119 
120 
121  // Constructors
122 
123  //- Construct from patch and internal field
125  (
126  const fvPatch&,
127  const DimensionedField<Type, volMesh>&
128  );
129 
130  //- Construct from patch, internal field and dictionary
132  (
133  const fvPatch&,
134  const DimensionedField<Type, volMesh>&,
135  const dictionary&
136  );
137 
138  //- Construct by mapping given turbulentInletFvPatchField
139  // onto a new patch
141  (
143  const fvPatch&,
145  const fvPatchFieldMapper&
146  );
147 
148  //- Construct as copy
150  (
152  );
153 
154  //- Construct and return a clone
155  virtual tmp<fvPatchField<Type> > clone() const
156  {
157  return tmp<fvPatchField<Type> >
158  (
160  );
161  }
162 
163  //- Construct as copy setting internal field reference
165  (
168  );
169 
170  //- Construct and return a clone setting internal field reference
171  virtual tmp<fvPatchField<Type> > clone
172  (
174  ) const
175  {
176  return tmp<fvPatchField<Type> >
177  (
178  new turbulentInletFvPatchField<Type>(*this, iF)
179  );
180  }
181 
182 
183  // Member functions
184 
185  // Access
186 
187  //- Return the fluctuation scale
188  const Type& fluctuationScale() const
189  {
190  return fluctuationScale_;
191  }
192 
193  //- Return reference to the fluctuation scale to allow adjustment
194  Type& fluctuationScale()
195  {
196  return fluctuationScale_;
197  }
199  //- Return the reference field
200  const Field<Type>& referenceField() const
201  {
202  return referenceField_;
203  }
204 
205  //- Return reference to the reference field to allow adjustment
207  {
208  return referenceField_;
209  }
210 
211 
212  // Mapping functions
213 
214  //- Map (and resize as needed) from self given a mapping object
215  virtual void autoMap
216  (
217  const fvPatchFieldMapper&
218  );
219 
220  //- Reverse map the given fvPatchField onto this fvPatchField
221  virtual void rmap
222  (
223  const fvPatchField<Type>&,
224  const labelList&
225  );
226 
227 
228  // Evaluation functions
229 
230  //- Update the coefficients associated with the patch field
231  virtual void updateCoeffs();
232 
233 
234  //- Write
235  virtual void write(Ostream&) const;
236 };
238 
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240 
241 } // End namespace Foam
242 
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
244 
245 #ifdef NoRepository
247 #endif
248 
249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
250 
251 #endif
252 
253 // ************************************************************************* //
turbulentInletFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
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
Foam::fvPatchFieldMapper.
Namespace for OpenFOAM.
const Type & fluctuationScale() const
Return the fluctuation scale.
const Field< Type > & referenceField() const
Return the reference field.
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
virtual void write(Ostream &) const
Write.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
Pre-declare SubField and related Field type.
Definition: Field.H:57
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
TypeName("turbulentInlet")
Runtime type information.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
A class for managing temporary objects.
Definition: PtrList.H:118
This boundary condition generates a fluctuating inlet condition by adding a random component to a ref...