Fix tutorials: coupled/conjugateHeatFoam/conjugateCavity: fix Allrun file
[OpenFOAM-1.6-ext.git] / src / finiteVolume / fields / fvPatchFields / derived / advective / advectiveFvPatchField.H
blob698d5a9d3bc5c77e70e08e94636bca5bbeec6c8c
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::advectiveFvPatchField
28 Description
29     Advective outflow boundary condition based on solving DDt(psi, U) = 0
30     at the boundary.
32     The standard (Euler, backward, CrankNicholson) time schemes are
33     supported.  Additionally an optional mechanism to relax the value at
34     the boundary to a specified far-field value is provided which is
35     switched on by specifying the relaxation length-scale lInf and the
36     far-field value fieldInf.
38     The flow/wave speed at the outlet is provided by the virtual function
39     advectionSpeed() the default implementation of which requires the name of
40     flux field a the outlet (phi) and optionally the density (rho) if the
41     mass-flux rather than the volumetric-flux is given.
42     @verbatim
43         outlet
44         {
45             type                    advective;
46             phi                     phi;
47             // rho                  rho; // Not needed, phi volumetric
48             // fieldInf             1e5; // Optional
49             // lInf                 0.1; // Optional
51             inletOutlet             true; // Correct for back-flow
52             correctSupercritical    true;
53         }
54     @endverbatim
56     The flow/wave speed at the outlet can be changed by deriving a specialised
57     BC from this class and overriding advectionSpeed() e.g. in
58     waveTransmissiveFvPatchField the advectionSpeed() calculates and returns
59     the flow-speed plus the acoustic wave speed creating an acoustic wave
60     transmissive boundary condition.
62     Steady-state handling has been added by Hrvoje Jasak.
63     Supercritical outlet handling has been added by Hrvoje Jasak.
64     HJ, 27/Oct/2009
66 Author
67     Hrvoje Jasak, Wikki Ltd.  All rights reserved.
69 SourceFiles
70     advectiveFvPatchField.C
72 \*---------------------------------------------------------------------------*/
74 #ifndef advectiveFvPatchField_H
75 #define advectiveFvPatchField_H
77 #include "mixedFvPatchFields.H"
78 #include "Switch.H"
80 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
82 namespace Foam
85 /*---------------------------------------------------------------------------*\
86                       Class advectiveFvPatch Declaration
87 \*---------------------------------------------------------------------------*/
89 template<class Type>
90 class advectiveFvPatchField
92     public mixedFvPatchField<Type>
94 protected:
96     // Private data
98         //- Name of the flux transporting the field
99         word phiName_;
101         //- Name of the density field used to normalise the mass flux
102         //  if neccessary
103         word rhoName_;
105         //- Field value of the far-field
106         Type fieldInf_;
108         //- Relaxation length-scale
109         scalar lInf_;
111         //- Inlet-outlet treatment
112         Switch inletOutlet_;
114         //- Supercritical correction treatment
115         Switch correctSupercritical_;
118 public:
120     //- Runtime type information
121     TypeName("advective");
124     // Constructors
126         //- Construct from patch and internal field
127         advectiveFvPatchField
128         (
129             const fvPatch&,
130             const DimensionedField<Type, volMesh>&
131         );
133         //- Construct from patch, internal field and dictionary
134         advectiveFvPatchField
135         (
136             const fvPatch&,
137             const DimensionedField<Type, volMesh>&,
138             const dictionary&
139         );
141         //- Construct by mapping given advectiveFvPatchField
142         //  onto a new patch
143         advectiveFvPatchField
144         (
145             const advectiveFvPatchField<Type>&,
146             const fvPatch&,
147             const DimensionedField<Type, volMesh>&,
148             const fvPatchFieldMapper&
149         );
151         //- Construct as copy
152         advectiveFvPatchField
153         (
154             const advectiveFvPatchField&
155         );
157         //- Construct and return a clone
158         virtual tmp<fvPatchField<Type> > clone() const
159         {
160             return tmp<fvPatchField<Type> >
161             (
162                 new advectiveFvPatchField<Type>(*this)
163             );
164         }
166         //- Construct as copy setting internal field reference
167         advectiveFvPatchField
168         (
169             const advectiveFvPatchField&,
170             const DimensionedField<Type, volMesh>&
171         );
173         //- Construct and return a clone setting internal field reference
174         virtual tmp<fvPatchField<Type> > clone
175         (
176             const DimensionedField<Type, volMesh>& iF
177         ) const
178         {
179             return tmp<fvPatchField<Type> >
180             (
181                 new advectiveFvPatchField<Type>(*this, iF)
182             );
183         }
186     // Member functions
188         // Access
190             //- Return the field at infinity
191             const Type& fieldInf() const
192             {
193                 return fieldInf_;
194             }
196             //- Return reference to the field at infinity to allow adjustment
197             Type& fieldInf()
198             {
199                 return fieldInf_;
200             }
202             //- Return the relaxation length-scale
203             scalar lInf() const
204             {
205                 return lInf_;
206             }
208             //- Return reference to the relaxation length-scale
209             //  to allow adjustment
210             scalar& lInf()
211             {
212                 return lInf_;
213             }
215             //- Return inlet-outlet treatment switch
216             bool inletOutlet() const
217             {
218                 return inletOutlet_;
219             }
221             //- Return reference to inlet-outlet treatment switch
222             //  to allow adjustment
223             bool& inletOutlet()
224             {
225                 return inletOutlet_;
226             }
228             //- Return supercritical outlet treatment switch
229             bool correctSupercritical() const
230             {
231                 return correctSupercritical_;
232             }
234             //- Return reference to supercritical treatment switch
235             //  to allow adjustment
236             bool& correctSupercritical()
237             {
238                 return correctSupercritical_;
239             }
242         // Evaluation functions
244             //- Calculate and return the advection speed at the boundary
245             virtual tmp<scalarField> advectionSpeed() const;
247             //- Calculate and return the supercritical switch at the boundary
248             //  Supercritical = 1 converts the outlet to zeroGradient
249             //  Supercritical = 0 no correction
250             virtual tmp<scalarField> supercritical() const;
252             //- Update the coefficients associated with the patch field
253             virtual void updateCoeffs();
256         //- Write
257         virtual void write(Ostream&) const;
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 } // End namespace Foam
265 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267 #ifdef NoRepository
268 #   include "advectiveFvPatchField.C"
269 #endif
271 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
273 #endif
275 // ************************************************************************* //