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)
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  }
198 
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 };
237 
238 
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240 
241 } // End namespace Foam
242 
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
244 
245 #ifdef NoRepository
247 #endif
248 
249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
250 
251 #endif
252 
253 // ************************************************************************* //
Foam::fvPatchField< Type >
Foam::turbulentInletFvPatchField::fluctuationScale
Type & fluctuationScale()
Return reference to the fluctuation scale to allow adjustment.
Definition: turbulentInletFvPatchField.H:237
Foam::Random
Simple random number generator.
Definition: Random.H:49
Foam::turbulentInletFvPatchField::rmap
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: turbulentInletFvPatchField.C:144
Foam::turbulentInletFvPatchField::clone
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
Definition: turbulentInletFvPatchField.H:198
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::turbulentInletFvPatchField::referenceField_
Field< Type > referenceField_
Reference field.
Definition: turbulentInletFvPatchField.H:149
Foam::turbulentInletFvPatchField::turbulentInletFvPatchField
turbulentInletFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: turbulentInletFvPatchField.C:37
Foam::turbulentInletFvPatchField::TypeName
TypeName("turbulentInlet")
Runtime type information.
Foam::turbulentInletFvPatchField::alpha_
scalar alpha_
Fraction of RMS component to apply to last time step values.
Definition: turbulentInletFvPatchField.H:152
Foam::fixedValueFvPatchField
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
Definition: fixedValueFvPatchField.H:79
Foam::turbulentInletFvPatchField::curTimeIndex_
label curTimeIndex_
Current time index (used for updating)
Definition: turbulentInletFvPatchField.H:155
Foam::turbulentInletFvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: turbulentInletFvPatchField.C:201
Foam::label
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::Field< Type >
turbulentInletFvPatchField.C
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::turbulentInletFvPatchField::fluctuationScale
const Type & fluctuationScale() const
Return the fluctuation scale.
Definition: turbulentInletFvPatchField.H:231
Foam::turbulentInletFvPatchField::fluctuationScale_
Type fluctuationScale_
Fluctuation scake.
Definition: turbulentInletFvPatchField.H:146
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Random.H
Foam::turbulentInletFvPatchField::ranGen_
Random ranGen_
Random number generator.
Definition: turbulentInletFvPatchField.H:143
Foam::turbulentInletFvPatchField::autoMap
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: turbulentInletFvPatchField.C:133
Foam::turbulentInletFvPatchField
This boundary condition generates a fluctuating inlet condition by adding a random component to a ref...
Definition: turbulentInletFvPatchField.H:136
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
fixedValueFvPatchFields.H
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:45
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::turbulentInletFvPatchField::referenceField
const Field< Type > & referenceField() const
Return the reference field.
Definition: turbulentInletFvPatchField.H:243
Foam::turbulentInletFvPatchField::referenceField
Field< Type > & referenceField()
Return reference to the reference field to allow adjustment.
Definition: turbulentInletFvPatchField.H:249
Foam::turbulentInletFvPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: turbulentInletFvPatchField.C:159
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:51