FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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