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-2024 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 "randomGenerator.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  randomGenerator 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, internal field and dictionary
121  (
122  const fvPatch&,
123  const DimensionedField<Type, volMesh>&,
124  const dictionary&
125  );
126 
127  //- Construct by mapping given turbulentInletFvPatchField
128  // onto a new patch
130  (
131  const turbulentInletFvPatchField<Type>&,
132  const fvPatch&,
134  const fieldMapper&
135  );
136 
137  //- Disallow copy without setting internal field reference
139  (
141  ) = delete;
142 
143  //- Copy constructor setting internal field reference
145  (
148  );
149 
150  //- Construct and return a clone setting internal field reference
152  (
154  ) const
155  {
156  return tmp<fvPatchField<Type>>
157  (
158  new turbulentInletFvPatchField<Type>(*this, iF)
159  );
160  }
161 
162 
163  // Member Functions
164 
165  // Access
166 
167  //- Return the fluctuation scale
168  const Type& fluctuationScale() const
169  {
170  return fluctuationScale_;
171  }
172 
173  //- Return reference to the fluctuation scale to allow adjustment
174  Type& fluctuationScale()
175  {
176  return fluctuationScale_;
177  }
178 
179  //- Return the reference field
180  const Field<Type>& referenceField() const
181  {
182  return referenceField_;
183  }
184 
185  //- Return reference to the reference field to allow adjustment
187  {
188  return referenceField_;
189  }
190 
191 
192  // Mapping functions
193 
194  //- Map the given fvPatchField onto this fvPatchField
195  virtual void map(const fvPatchField<Type>&, const fieldMapper&);
196 
197  //- Reset the fvPatchField to the given fvPatchField
198  // Used for mesh to mesh mapping
199  virtual void reset(const fvPatchField<Type>&);
200 
201 
202  // Evaluation functions
203 
204  //- Update the coefficients associated with the patch field
205  virtual void updateCoeffs();
206 
207 
208  //- Write
209  virtual void write(Ostream&) const;
210 };
211 
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 } // End namespace Foam
216 
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 
219 #ifdef NoRepository
221 #endif
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 #endif
226 
227 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Pre-declare SubField and related Field type.
Definition: Field.H:83
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Abstract base class for field mapping.
Definition: fieldMapper.H:48
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:88
tmp< fvPatchField< Type > > clone() const
Disallow clone without setting internal field reference.
Definition: fvPatchField.H:204
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
A class for managing temporary objects.
Definition: tmp.H:55
This boundary condition generates a fluctuating inlet condition by adding a random component to a ref...
const Type & fluctuationScale() const
Return the fluctuation scale.
virtual void write(Ostream &) const
Write.
turbulentInletFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual void reset(const fvPatchField< Type > &)
Reset the fvPatchField to the given fvPatchField.
const Field< Type > & referenceField() const
Return the reference field.
virtual void map(const fvPatchField< Type > &, const fieldMapper &)
Map the given fvPatchField onto this fvPatchField.
TypeName("turbulentInlet")
Runtime type information.
Namespace for OpenFOAM.
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