turbulentInletFvPatchField.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 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 Description
28  This boundary condition generates a fluctuating inlet condition by adding
29  a random component to a reference (mean) field.
30 
31  \f[
32  x_p = (1 - \alpha) x_p^{n-1} + \alpha (x_{ref} + s C_{RMS} x_{ref})
33  \f]
34 
35  where
36 
37  \vartable
38  x_p | patch values
39  x_{ref} | reference patch values
40  n | time level
41  \alpha | fraction of new random component added to previous time value
42  C_{RMS} | RMS coefficient
43  s | fluctuation scale
44  \endvartable
45 
46 Usage
47  \table
48  Property | Description | Required | Default value
49  fluctuationScale | RMS fluctuation scale (fraction of mean) | yes |
50  referenceField | reference (mean) field | yes |
51  alpha | fraction of new random component added to previous| no| 0.1
52  \endtable
53 
54  Example of the boundary condition specification:
55  \verbatim
56  <patchName>
57  {
58  type turbulentInlet;
59  fluctuationScale 0.1;
60  referenceField uniform 10;
61  alpha 0.1;
62  }
63  \endverbatim
64 
65 See also
66  Foam::fixedValueFvPatchField
67 
68 SourceFiles
69  turbulentInletFvPatchField.C
70 
71 \*---------------------------------------------------------------------------*/
72 
73 #ifndef turbulentInletFvPatchField_H
74 #define turbulentInletFvPatchField_H
75 
76 #include "Random.H"
78 
79 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
80 
81 namespace Foam
82 {
83 
84 /*---------------------------------------------------------------------------*\
85  Class turbulentInletFvPatchField Declaration
86 \*---------------------------------------------------------------------------*/
87 
88 template<class Type>
89 class turbulentInletFvPatchField
90 :
91  public fixedValueFvPatchField<Type>
92 {
93  // Private Data
94 
95  //- Random number generator
96  Random ranGen_;
97 
98  //- Fluctuation scale
99  Type fluctuationScale_;
100 
101  //- Reference field
102  Field<Type> referenceField_;
103 
104  //- Fraction of RMS component to apply to last time step values
105  scalar alpha_;
106 
107  //- Current time index (used for updating)
108  label curTimeIndex_;
109 
110 
111 public:
112 
113  //- Runtime type information
114  TypeName("turbulentInlet");
115 
116 
117  // Constructors
118 
119  //- Construct from patch and internal field
121  (
122  const fvPatch&,
123  const DimensionedField<Type, volMesh>&
124  );
125 
126  //- Construct from patch, internal field and dictionary
128  (
129  const fvPatch&,
130  const DimensionedField<Type, volMesh>&,
131  const dictionary&
132  );
133 
134  //- Construct by mapping given turbulentInletFvPatchField
135  // onto a new patch
137  (
139  const fvPatch&,
141  const fvPatchFieldMapper&
142  );
143 
144  //- Copy constructor
146  (
148  );
149 
150  //- Construct and return a clone
151  virtual tmp<fvPatchField<Type>> clone() const
152  {
153  return tmp<fvPatchField<Type>>
154  (
156  );
157  }
158 
159  //- Copy constructor setting internal field reference
161  (
164  );
165 
166  //- Construct and return a clone setting internal field reference
168  (
170  ) const
171  {
172  return tmp<fvPatchField<Type>>
173  (
174  new turbulentInletFvPatchField<Type>(*this, iF)
175  );
176  }
177 
178 
179  // Member Functions
180 
181  // Access
182 
183  //- Return the fluctuation scale
184  const Type& fluctuationScale() const
185  {
186  return fluctuationScale_;
187  }
188 
189  //- Return reference to the fluctuation scale to allow adjustment
190  Type& fluctuationScale()
191  {
192  return fluctuationScale_;
193  }
195  //- Return the reference field
196  const Field<Type>& referenceField() const
197  {
198  return referenceField_;
199  }
200 
201  //- Return reference to the reference field to allow adjustment
203  {
204  return referenceField_;
205  }
206 
207 
208  // Mapping functions
209 
210  //- Map (and resize as needed) from self given a mapping object
211  // Used to update fields following mesh topology change
212  virtual void autoMap(const fvPatchFieldMapper&);
213 
214  //- Reverse map the given fvPatchField onto this fvPatchField
215  // Used to reconstruct fields
216  virtual void rmap(const fvPatchField<Type>&, const labelList&);
217 
218 
219  // Evaluation functions
220 
221  //- Update the coefficients associated with the patch field
222  virtual void updateCoeffs();
223 
224 
225  //- Write
226  virtual void write(Ostream&) const;
227 };
228 
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 } // End namespace Foam
234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235 
236 #ifdef NoRepository
238 #endif
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 
242 #endif
243 
244 // ************************************************************************* //
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:56
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.