1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
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
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
26 Foam::advectiveFvPatchField
29 Advective outflow boundary condition based on solving DDt(psi, U) = 0
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.
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;
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.
67 Hrvoje Jasak, Wikki Ltd. All rights reserved.
70 advectiveFvPatchField.C
72 \*---------------------------------------------------------------------------*/
74 #ifndef advectiveFvPatchField_H
75 #define advectiveFvPatchField_H
77 #include "mixedFvPatchFields.H"
80 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
85 /*---------------------------------------------------------------------------*\
86 Class advectiveFvPatch Declaration
87 \*---------------------------------------------------------------------------*/
90 class advectiveFvPatchField
92 public mixedFvPatchField<Type>
98 //- Name of the flux transporting the field
101 //- Name of the density field used to normalise the mass flux
105 //- Field value of the far-field
108 //- Relaxation length-scale
111 //- Inlet-outlet treatment
114 //- Supercritical correction treatment
115 Switch correctSupercritical_;
120 //- Runtime type information
121 TypeName("advective");
126 //- Construct from patch and internal field
127 advectiveFvPatchField
130 const DimensionedField<Type, volMesh>&
133 //- Construct from patch, internal field and dictionary
134 advectiveFvPatchField
137 const DimensionedField<Type, volMesh>&,
141 //- Construct by mapping given advectiveFvPatchField
143 advectiveFvPatchField
145 const advectiveFvPatchField<Type>&,
147 const DimensionedField<Type, volMesh>&,
148 const fvPatchFieldMapper&
151 //- Construct as copy
152 advectiveFvPatchField
154 const advectiveFvPatchField&
157 //- Construct and return a clone
158 virtual tmp<fvPatchField<Type> > clone() const
160 return tmp<fvPatchField<Type> >
162 new advectiveFvPatchField<Type>(*this)
166 //- Construct as copy setting internal field reference
167 advectiveFvPatchField
169 const advectiveFvPatchField&,
170 const DimensionedField<Type, volMesh>&
173 //- Construct and return a clone setting internal field reference
174 virtual tmp<fvPatchField<Type> > clone
176 const DimensionedField<Type, volMesh>& iF
179 return tmp<fvPatchField<Type> >
181 new advectiveFvPatchField<Type>(*this, iF)
190 //- Return the field at infinity
191 const Type& fieldInf() const
196 //- Return reference to the field at infinity to allow adjustment
202 //- Return the relaxation length-scale
208 //- Return reference to the relaxation length-scale
209 // to allow adjustment
215 //- Return inlet-outlet treatment switch
216 bool inletOutlet() const
221 //- Return reference to inlet-outlet treatment switch
222 // to allow adjustment
228 //- Return supercritical outlet treatment switch
229 bool correctSupercritical() const
231 return correctSupercritical_;
234 //- Return reference to supercritical treatment switch
235 // to allow adjustment
236 bool& correctSupercritical()
238 return correctSupercritical_;
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();
257 virtual void write(Ostream&) const;
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 } // End namespace Foam
265 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268 # include "advectiveFvPatchField.C"
271 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
275 // ************************************************************************* //