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

outletStabilised.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::outletStabilised
00027 
00028 Description
00029     Outlet-stabilised interpolation scheme which applies upwind differencing
00030     to the faces of the cells adjacent to outlets.
00031 
00032     This is particularly useful to stabilise the velocity at entrainment
00033     boundaries for LES cases using linear or other centred differencing
00034     schemes.
00035 
00036 SourceFiles
00037     outletStabilised.C
00038 
00039 \*---------------------------------------------------------------------------*/
00040 
00041 #ifndef outletStabilised_H
00042 #define outletStabilised_H
00043 
00044 #include "surfaceInterpolationScheme.H"
00045 #include "skewCorrectionVectors.H"
00046 #include "linear.H"
00047 #include "gaussGrad.H"
00048 #include "mixedFvPatchField.H"
00049 #include "directionMixedFvPatchField.H"
00050 
00051 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00052 
00053 namespace Foam
00054 {
00055 
00056 /*---------------------------------------------------------------------------*\
00057                            Class outletStabilised Declaration
00058 \*---------------------------------------------------------------------------*/
00059 
00060 template<class Type>
00061 class outletStabilised
00062 :
00063     public surfaceInterpolationScheme<Type>
00064 {
00065     // Private member data
00066 
00067         const surfaceScalarField& faceFlux_;
00068         tmp<surfaceInterpolationScheme<Type> > tScheme_;
00069 
00070 
00071     // Private Member Functions
00072 
00073         //- Disallow default bitwise copy construct
00074         outletStabilised(const outletStabilised&);
00075 
00076         //- Disallow default bitwise assignment
00077         void operator=(const outletStabilised&);
00078 
00079 
00080 public:
00081 
00082     //- Runtime type information
00083     TypeName("outletStabilised");
00084 
00085 
00086     // Constructors
00087 
00088         //- Construct from mesh and Istream
00089         outletStabilised
00090         (
00091             const fvMesh& mesh,
00092             Istream& is
00093         )
00094         :
00095             surfaceInterpolationScheme<Type>(mesh),
00096             faceFlux_
00097             (
00098                 mesh.lookupObject<surfaceScalarField>
00099                 (
00100                     word(is)
00101                 )
00102             ),
00103             tScheme_
00104             (
00105                 surfaceInterpolationScheme<Type>::New(mesh, faceFlux_, is)
00106             )
00107         {}
00108 
00109 
00110         //- Construct from mesh, faceFlux and Istream
00111         outletStabilised
00112         (
00113             const fvMesh& mesh,
00114             const surfaceScalarField& faceFlux,
00115             Istream& is
00116         )
00117         :
00118             surfaceInterpolationScheme<Type>(mesh),
00119             faceFlux_(faceFlux),
00120             tScheme_
00121             (
00122                 surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
00123             )
00124         {}
00125 
00126 
00127     // Member Functions
00128 
00129         //- Return the interpolation weighting factors
00130         tmp<surfaceScalarField> weights
00131         (
00132             const GeometricField<Type, fvPatchField, volMesh>& vf
00133         ) const
00134         {
00135             tmp<surfaceScalarField> tw = tScheme_().weights(vf);
00136             surfaceScalarField& w = tw();
00137 
00138             const fvMesh& mesh_ = this->mesh();
00139             const cellList& cells = mesh_.cells();
00140 
00141             forAll(vf.boundaryField(), patchi)
00142             {
00143                 if
00144                 (
00145                     isA<zeroGradientFvPatchField<Type> >
00146                         (vf.boundaryField()[patchi])
00147                  || isA<mixedFvPatchField<Type> >(vf.boundaryField()[patchi])
00148                  || isA<directionMixedFvPatchField<Type> >
00149                     (vf.boundaryField()[patchi])
00150                 )
00151                 {
00152                     const labelList& pFaceCells =
00153                         mesh_.boundary()[patchi].faceCells();
00154 
00155                     forAll(pFaceCells, pFacei)
00156                     {
00157                         const cell& pFaceCell = cells[pFaceCells[pFacei]];
00158 
00159                         forAll(pFaceCell, fi)
00160                         {
00161                             label facei = pFaceCell[fi];
00162 
00163                             if (mesh_.isInternalFace(facei))
00164                             {
00165                                 // Apply upwind differencing
00166                                 w[facei] = pos(faceFlux_[facei]);
00167                             }
00168                         }
00169                     }
00170                 }
00171             }
00172 
00173             return tw;
00174         }
00175 
00176         //- Return true if this scheme uses an explicit correction
00177         virtual bool corrected() const
00178         {
00179             return tScheme_().corrected();
00180         }
00181 
00182         //- Return the explicit correction to the face-interpolate
00183         //  set to zero on the near-boundary faces where upwinf is applied
00184         virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
00185         correction
00186         (
00187             const GeometricField<Type, fvPatchField, volMesh>& vf
00188         ) const
00189         {
00190             if (tScheme_().corrected())
00191             {
00192                 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tcorr =
00193                     tScheme_().correction(vf);
00194 
00195                 GeometricField<Type, fvsPatchField, surfaceMesh>& corr = tcorr();
00196 
00197                 const fvMesh& mesh_ = this->mesh();
00198                 const cellList& cells = mesh_.cells();
00199 
00200                 forAll(vf.boundaryField(), patchi)
00201                 {
00202                     if
00203                     (
00204                         isA<zeroGradientFvPatchField<Type> >
00205                             (vf.boundaryField()[patchi])
00206                      || isA<mixedFvPatchField<Type> >
00207                             (vf.boundaryField()[patchi])
00208                     )
00209                     {
00210                         const labelList& pFaceCells =
00211                             mesh_.boundary()[patchi].faceCells();
00212 
00213                         forAll(pFaceCells, pFacei)
00214                         {
00215                             const cell& pFaceCell = cells[pFaceCells[pFacei]];
00216 
00217                             forAll(pFaceCell, fi)
00218                             {
00219                                 label facei = pFaceCell[fi];
00220 
00221                                 if (mesh_.isInternalFace(facei))
00222                                 {
00223                                     // Remove correction
00224                                     corr[facei] = pTraits<Type>::zero;
00225                                 }
00226                             }
00227                         }
00228                     }
00229                 }
00230 
00231                 return tcorr;
00232             }
00233             else
00234             {
00235                 return
00236                     tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >(NULL);
00237             }
00238         }
00239 };
00240 
00241 
00242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00243 
00244 } // End namespace Foam
00245 
00246 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00247 
00248 #endif
00249 
00250 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd