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-2020 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  //- Disallow copy without setting internal field reference
146  (
148  ) = delete;
149 
150  //- Copy constructor setting internal field reference
152  (
155  );
156 
157  //- Construct and return a clone setting internal field reference
159  (
161  ) const
162  {
163  return tmp<fvPatchField<Type>>
164  (
165  new turbulentInletFvPatchField<Type>(*this, iF)
166  );
167  }
168 
169 
170  // Member Functions
171 
172  // Access
173 
174  //- Return the fluctuation scale
175  const Type& fluctuationScale() const
176  {
177  return fluctuationScale_;
178  }
179 
180  //- Return reference to the fluctuation scale to allow adjustment
181  Type& fluctuationScale()
182  {
183  return fluctuationScale_;
184  }
185 
186  //- Return the reference field
187  const Field<Type>& referenceField() const
188  {
189  return referenceField_;
190  }
191 
192  //- Return reference to the reference field to allow adjustment
194  {
195  return referenceField_;
196  }
197 
198 
199  // Mapping functions
200 
201  //- Map (and resize as needed) from self given a mapping object
202  // Used to update fields following mesh topology change
203  virtual void autoMap(const fvPatchFieldMapper&);
204 
205  //- Reverse map the given fvPatchField onto this fvPatchField
206  // Used to reconstruct fields
207  virtual void rmap(const fvPatchField<Type>&, const labelList&);
208 
209 
210  // Evaluation functions
211 
212  //- Update the coefficients associated with the patch field
213  virtual void updateCoeffs();
214 
215 
216  //- Write
217  virtual void write(Ostream&) const;
218 };
219 
220 
221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
222 
223 } // End namespace Foam
225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
226 
227 #ifdef NoRepository
229 #endif
231 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
232 
233 #endif
234 
235 // ************************************************************************* //
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:62
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 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:54
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
tmp< fvPatchField< Type > > clone() const
Disallow clone without setting internal field reference.
Definition: fvPatchField.H:199
Namespace for OpenFOAM.
const Field< Type > & referenceField() const
Return the reference field.