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

PureUpwindFitScheme.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::PureUpwindFitScheme
00027 
00028 Description
00029     Upwind biased fit surface interpolation scheme that applies an explicit
00030     correction to upwind.
00031 
00032 \*---------------------------------------------------------------------------*/
00033 
00034 #ifndef PureUpwindFitScheme_H
00035 #define PureUpwindFitScheme_H
00036 
00037 #include "UpwindFitData.H"
00038 #include "upwind.H"
00039 #include "Switch.H"
00040 
00041 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00042 
00043 namespace Foam
00044 {
00045 
00046 /*---------------------------------------------------------------------------*\
00047                            Class PureUpwindFitScheme Declaration
00048 \*---------------------------------------------------------------------------*/
00049 
00050 template<class Type, class Polynomial, class Stencil>
00051 class PureUpwindFitScheme
00052 :
00053     public upwind<Type>
00054 {
00055     // Private Data
00056 
00057         //- Factor the fit is allowed to deviate from linear.
00058         //  This limits the amount of high-order correction and increases
00059         //  stability on bad meshes
00060         const scalar linearLimitFactor_;
00061 
00062         //- Weights for central stencil
00063         const scalar centralWeight_;
00064 
00065 
00066     // Private Member Functions
00067 
00068         //- Disallow default bitwise copy construct
00069         PureUpwindFitScheme(const PureUpwindFitScheme&);
00070 
00071         //- Disallow default bitwise assignment
00072         void operator=(const PureUpwindFitScheme&);
00073 
00074 
00075 public:
00076 
00077     //- Runtime type information
00078     TypeName("PureUpwindFitScheme");
00079 
00080 
00081     // Constructors
00082 
00083         //- Construct from mesh and Istream
00084         //  The name of the flux field is read from the Istream and looked-up
00085         //  from the mesh objectRegistry
00086         PureUpwindFitScheme(const fvMesh& mesh, Istream& is)
00087         :
00088             upwind<Type>
00089             (
00090                 mesh,
00091                 mesh.lookupObject<surfaceScalarField>(word(is))
00092             ),
00093             linearLimitFactor_(readScalar(is)),
00094             centralWeight_(1000)
00095         {}
00096 
00097 
00098         //- Construct from mesh, faceFlux and Istream
00099         PureUpwindFitScheme
00100         (
00101             const fvMesh& mesh,
00102             const surfaceScalarField& faceFlux,
00103             Istream& is
00104         )
00105         :
00106             upwind<Type>(mesh, faceFlux),
00107             linearLimitFactor_(readScalar(is)),
00108             centralWeight_(1000)
00109         {}
00110 
00111 
00112     // Member Functions
00113 
00114         //- Return true if this scheme uses an explicit correction
00115         virtual bool corrected() const
00116         {
00117             return true;
00118         }
00119 
00120         //- Return the explicit correction to the face-interpolate
00121         virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
00122         correction
00123         (
00124             const GeometricField<Type, fvPatchField, volMesh>& vf
00125         ) const
00126         {
00127             const fvMesh& mesh = this->mesh();
00128 
00129             // Use the owner/neighbour splitting constructor
00130             const extendedUpwindCellToFaceStencil& stencil = Stencil::New(mesh);
00131 
00132             const UpwindFitData<Polynomial>& ufd =
00133             UpwindFitData<Polynomial>::New
00134             (
00135                 mesh,
00136                 stencil,
00137                 false,              //offset to upwind
00138                 linearLimitFactor_,
00139                 centralWeight_
00140             );
00141 
00142             const List<scalarList>& fo = ufd.owncoeffs();
00143             const List<scalarList>& fn = ufd.neicoeffs();
00144 
00145             return stencil.weightedSum(this->faceFlux_, vf, fo, fn);
00146         }
00147 };
00148 
00149 
00150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00151 
00152 } // End namespace Foam
00153 
00154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00155 
00156 // Add the patch constructor functions to the hash tables
00157 
00158 #define makePureUpwindFitSurfaceInterpolationTypeScheme(SS, POLYNOMIAL, STENCIL, TYPE) \
00159                                                                               \
00160 typedef PureUpwindFitScheme<TYPE, POLYNOMIAL, STENCIL>                            \
00161     PureUpwindFitScheme##TYPE##POLYNOMIAL##STENCIL##_;                            \
00162 defineTemplateTypeNameAndDebugWithName                                        \
00163     (PureUpwindFitScheme##TYPE##POLYNOMIAL##STENCIL##_, #SS, 0);                  \
00164                                                                               \
00165 surfaceInterpolationScheme<TYPE>::addMeshConstructorToTable                   \
00166 <PureUpwindFitScheme<TYPE, POLYNOMIAL, STENCIL> >                                 \
00167     add##SS##STENCIL##TYPE##MeshConstructorToTable_;                          \
00168                                                                               \
00169 surfaceInterpolationScheme<TYPE>::addMeshFluxConstructorToTable               \
00170 <PureUpwindFitScheme<TYPE, POLYNOMIAL, STENCIL> >                                 \
00171     add##SS##STENCIL##TYPE##MeshFluxConstructorToTable_;
00172 
00173 #define makePureUpwindFitSurfaceInterpolationScheme(SS, POLYNOMIAL, STENCIL)      \
00174                                                                               \
00175 makePureUpwindFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,scalar)     \
00176 makePureUpwindFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,vector)     \
00177 makePureUpwindFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,sphericalTensor) \
00178 makePureUpwindFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,symmTensor) \
00179 makePureUpwindFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,tensor)
00180 
00181 
00182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00183 
00184 #endif
00185 
00186 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd