OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

advectiveFvPatchField.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::advectiveFvPatchField
00027 
00028 Description
00029     Advective outflow boundary condition based on solving DDt(psi, U) = 0
00030     at the boundary.
00031 
00032     The standard (Euler, backward, CrankNicholson) time schemes are
00033     supported.  Additionally an optional mechanism to relax the value at
00034     the boundary to a specified far-field value is provided which is
00035     switched on by specifying the relaxation length-scale lInf and the
00036     far-field value fieldInf.
00037 
00038     The flow/wave speed at the outlet is provided by the virtual function
00039     advectionSpeed() the default implementation of which requires the name of
00040     flux field a the outlet (phi) and optionally the density (rho) if the
00041     mass-flux rather than the volumetric-flux is given.
00042     @verbatim
00043         outlet
00044         {
00045             type            advective;
00046             phi             phi;
00047             // rho          rho; // Not needed, phi volumetric
00048             // fieldInf     1e5; // Optional
00049             // lInf         0.1; // Optional
00050         }
00051     @endverbatim
00052 
00053     The flow/wave speed at the outlet can be changed by deriving a specialised
00054     BC fron this class and overriding advectionSpeed() e.g. in
00055     waveTransmissiveFvPatchField the advectionSpeed() calculates and returns
00056     the flow-speed plus the acoustic wave speed creating an acoustic wave
00057     transmissive boundary condition.
00058 
00059 SourceFiles
00060     advectiveFvPatchField.C
00061 
00062 \*---------------------------------------------------------------------------*/
00063 
00064 #ifndef advectiveFvPatchField_H
00065 #define advectiveFvPatchField_H
00066 
00067 #include "mixedFvPatchFields.H"
00068 
00069 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00070 
00071 namespace Foam
00072 {
00073 
00074 /*---------------------------------------------------------------------------*\
00075                  Class advectiveFvPatch Declaration
00076 \*---------------------------------------------------------------------------*/
00077 
00078 template<class Type>
00079 class advectiveFvPatchField
00080 :
00081     public mixedFvPatchField<Type>
00082 {
00083 protected:
00084 
00085     // Private data
00086 
00087         //- Name of the flux transporting the field
00088         word phiName_;
00089 
00090         //- Name of the density field used to normalise the mass flux
00091         //  if neccessary
00092         word rhoName_;
00093 
00094         //- Field value of the far-field
00095         Type fieldInf_;
00096 
00097         //- Relaxation length-scale
00098         scalar lInf_;
00099 
00100 
00101 public:
00102 
00103     //- Runtime type information
00104     TypeName("advective");
00105 
00106 
00107     // Constructors
00108 
00109         //- Construct from patch and internal field
00110         advectiveFvPatchField
00111         (
00112             const fvPatch&,
00113             const DimensionedField<Type, volMesh>&
00114         );
00115 
00116         //- Construct from patch, internal field and dictionary
00117         advectiveFvPatchField
00118         (
00119             const fvPatch&,
00120             const DimensionedField<Type, volMesh>&,
00121             const dictionary&
00122         );
00123 
00124         //- Construct by mapping given advectiveFvPatchField
00125         //  onto a new patch
00126         advectiveFvPatchField
00127         (
00128             const advectiveFvPatchField<Type>&,
00129             const fvPatch&,
00130             const DimensionedField<Type, volMesh>&,
00131             const fvPatchFieldMapper&
00132         );
00133 
00134         //- Construct as copy
00135         advectiveFvPatchField
00136         (
00137             const advectiveFvPatchField&
00138         );
00139 
00140         //- Construct and return a clone
00141         virtual tmp<fvPatchField<Type> > clone() const
00142         {
00143             return tmp<fvPatchField<Type> >
00144             (
00145                 new advectiveFvPatchField<Type>(*this)
00146             );
00147         }
00148 
00149         //- Construct as copy setting internal field reference
00150         advectiveFvPatchField
00151         (
00152             const advectiveFvPatchField&,
00153             const DimensionedField<Type, volMesh>&
00154         );
00155 
00156         //- Construct and return a clone setting internal field reference
00157         virtual tmp<fvPatchField<Type> > clone
00158         (
00159             const DimensionedField<Type, volMesh>& iF
00160         ) const
00161         {
00162             return tmp<fvPatchField<Type> >
00163             (
00164                 new advectiveFvPatchField<Type>(*this, iF)
00165             );
00166         }
00167 
00168 
00169     // Member functions
00170 
00171         // Access
00172 
00173             //- Return the field at infinity
00174             const Type& fieldInf() const
00175             {
00176                 return fieldInf_;
00177             }
00178 
00179             //- Return reference to the field at infinity to allow adjustment
00180             Type& fieldInf()
00181             {
00182                 return fieldInf_;
00183             }
00184 
00185             //- Return the relaxation length-scale
00186             scalar lInf() const
00187             {
00188                 return lInf_;
00189             }
00190 
00191             //- Return reference to the relaxation length-scale
00192             //  to allow adjustment
00193             scalar& lInf()
00194             {
00195                 return lInf_;
00196             }
00197 
00198 
00199         // Evaluation functions
00200 
00201             //- Calculate and return the advection speed at the boundary
00202             virtual tmp<scalarField> advectionSpeed() const;
00203 
00204             //- Update the coefficients associated with the patch field
00205             virtual void updateCoeffs();
00206 
00207 
00208         //- Write
00209         virtual void write(Ostream&) const;
00210 };
00211 
00212 
00213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00214 
00215 } // End namespace Foam
00216 
00217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00218 
00219 #ifdef NoRepository
00220 #   include "advectiveFvPatchField.C"
00221 #endif
00222 
00223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00224 
00225 #endif
00226 
00227 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd