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