Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / finiteVolume / fields / fvPatchFields / derived / turbulentInlet / turbulentInletFvPatchField.H
blobce384a44022c9d420855569b5bdb8f29bdda4570
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation, either version 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 Class
25     Foam::turbulentInletFvPatchField
27 Description
28     Generate a fluctuating inlet condition by adding a random component
29     to a reference (mean) field.
30     Input:
31         referenceField
32             Mean field.
33         fluctuationScale
34             RMS fluctuation, provided as the fraction of the mean field.
35         alpha
36             temporal correlation factor;
37             the fraction of the new random component added to the previous
38             time-step (defaults to 0.1).
40 SourceFiles
41     turbulentInletFvPatchField.C
43 \*---------------------------------------------------------------------------*/
45 #ifndef turbulentInletFvPatchField_H
46 #define turbulentInletFvPatchField_H
48 #include "Random.H"
49 #include "fixedValueFvPatchFields.H"
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 namespace Foam
56 /*---------------------------------------------------------------------------*\
57                      Class turbulentInletFvPatch Declaration
58 \*---------------------------------------------------------------------------*/
60 template<class Type>
61 class turbulentInletFvPatchField
63     public fixedValueFvPatchField<Type>
65     // Private data
67         Random ranGen_;
68         Type fluctuationScale_;
69         Field<Type> referenceField_;
70         scalar alpha_;
71         label curTimeIndex_;
74 public:
76     //- Runtime type information
77     TypeName("turbulentInlet");
80     // Constructors
82         //- Construct from patch and internal field
83         turbulentInletFvPatchField
84         (
85             const fvPatch&,
86             const DimensionedField<Type, volMesh>&
87         );
89         //- Construct from patch, internal field and dictionary
90         turbulentInletFvPatchField
91         (
92             const fvPatch&,
93             const DimensionedField<Type, volMesh>&,
94             const dictionary&
95         );
97         //- Construct by mapping given turbulentInletFvPatchField
98         //  onto a new patch
99         turbulentInletFvPatchField
100         (
101             const turbulentInletFvPatchField<Type>&,
102             const fvPatch&,
103             const DimensionedField<Type, volMesh>&,
104             const fvPatchFieldMapper&
105         );
107         //- Construct as copy
108         turbulentInletFvPatchField
109         (
110             const turbulentInletFvPatchField<Type>&
111         );
113         //- Construct and return a clone
114         virtual tmp<fvPatchField<Type> > clone() const
115         {
116             return tmp<fvPatchField<Type> >
117             (
118                 new turbulentInletFvPatchField<Type>(*this)
119             );
120         }
122         //- Construct as copy setting internal field reference
123         turbulentInletFvPatchField
124         (
125             const turbulentInletFvPatchField<Type>&,
126             const DimensionedField<Type, volMesh>&
127         );
129         //- Construct and return a clone setting internal field reference
130         virtual tmp<fvPatchField<Type> > clone
131         (
132             const DimensionedField<Type, volMesh>& iF
133         ) const
134         {
135             return tmp<fvPatchField<Type> >
136             (
137                 new turbulentInletFvPatchField<Type>(*this, iF)
138             );
139         }
142     // Member functions
144         // Access
146             //- Return the fluctuation scale
147             const Type& fluctuationScale() const
148             {
149                 return fluctuationScale_;
150             }
152             //- Return reference to the fluctuation scale to allow adjustment
153             Type& fluctuationScale()
154             {
155                 return fluctuationScale_;
156             }
158             //- Return the reference field
159             const Field<Type>& referenceField() const
160             {
161                 return referenceField_;
162             }
164             //- Return reference to the reference field to allow adjustment
165             Field<Type>& referenceField()
166             {
167                 return referenceField_;
168             }
171         // Mapping functions
173             //- Map (and resize as needed) from self given a mapping object
174             virtual void autoMap
175             (
176                 const fvPatchFieldMapper&
177             );
179             //- Reverse map the given fvPatchField onto this fvPatchField
180             virtual void rmap
181             (
182                 const fvPatchField<Type>&,
183                 const labelList&
184             );
187         // Evaluation functions
189             //- Update the coefficients associated with the patch field
190             virtual void updateCoeffs();
193         //- Write
194         virtual void write(Ostream&) const;
198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 } // End namespace Foam
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 #ifdef NoRepository
205 #   include "turbulentInletFvPatchField.C"
206 #endif
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 #endif
212 // ************************************************************************* //