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

CentredFitScheme.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::CentredFitScheme
00027 
00028 Description
00029     Centred fit surface interpolation scheme which applies an explicit
00030     correction to linear.
00031 
00032 \*---------------------------------------------------------------------------*/
00033 
00034 #ifndef CentredFitScheme_H
00035 #define CentredFitScheme_H
00036 
00037 #include "CentredFitData.H"
00038 #include "linear.H"
00039 
00040 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00041 
00042 namespace Foam
00043 {
00044 
00045 /*---------------------------------------------------------------------------*\
00046                            Class CentredFitScheme Declaration
00047 \*---------------------------------------------------------------------------*/
00048 
00049 template<class Type, class Polynomial, class Stencil>
00050 class CentredFitScheme
00051 :
00052     public linear<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         CentredFitScheme(const CentredFitScheme&);
00069 
00070         //- Disallow default bitwise assignment
00071         void operator=(const CentredFitScheme&);
00072 
00073 
00074 public:
00075 
00076     //- Runtime type information
00077     TypeName("CentredFitScheme");
00078 
00079 
00080     // Constructors
00081 
00082         //- Construct from mesh and Istream
00083         CentredFitScheme(const fvMesh& mesh, Istream& is)
00084         :
00085             linear<Type>(mesh),
00086             linearLimitFactor_(readScalar(is)),
00087             centralWeight_(1000)
00088         {}
00089 
00090 
00091         //- Construct from mesh, faceFlux and Istream
00092         CentredFitScheme
00093         (
00094             const fvMesh& mesh,
00095             const surfaceScalarField& faceFlux,
00096             Istream& is
00097         )
00098         :
00099             linear<Type>(mesh),
00100             linearLimitFactor_(readScalar(is)),
00101             centralWeight_(1000)
00102         {}
00103 
00104 
00105     // Member Functions
00106 
00107         //- Return true if this scheme uses an explicit correction
00108         virtual bool corrected() const
00109         {
00110             return true;
00111         }
00112 
00113         //- Return the explicit correction to the face-interpolate
00114         virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
00115         correction
00116         (
00117             const GeometricField<Type, fvPatchField, volMesh>& vf
00118         ) const
00119         {
00120             const fvMesh& mesh = this->mesh();
00121 
00122             const extendedCentredCellToFaceStencil& stencil = Stencil::New
00123             (
00124                 mesh
00125             );
00126 
00127             const CentredFitData<Polynomial>& cfd =
00128             CentredFitData<Polynomial>::New
00129             (
00130                 mesh,
00131                 stencil,
00132                 linearLimitFactor_,
00133                 centralWeight_
00134             );
00135 
00136             const List<scalarList>& f = cfd.coeffs();
00137 
00138             return stencil.weightedSum(vf, f);
00139         }
00140 };
00141 
00142 
00143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00144 
00145 } // End namespace Foam
00146 
00147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00148 
00149 // Add the patch constructor functions to the hash tables
00150 
00151 #define makeCentredFitSurfaceInterpolationTypeScheme(SS, POLYNOMIAL, STENCIL, TYPE) \
00152                                                                               \
00153 typedef CentredFitScheme<TYPE, POLYNOMIAL, STENCIL>                           \
00154     CentredFitScheme##TYPE##POLYNOMIAL##STENCIL##_;                           \
00155 defineTemplateTypeNameAndDebugWithName                                        \
00156     (CentredFitScheme##TYPE##POLYNOMIAL##STENCIL##_, #SS, 0);                 \
00157                                                                               \
00158 surfaceInterpolationScheme<TYPE>::addMeshConstructorToTable                   \
00159 <CentredFitScheme<TYPE, POLYNOMIAL, STENCIL> >                                \
00160     add##SS##STENCIL##TYPE##MeshConstructorToTable_;                          \
00161                                                                               \
00162 surfaceInterpolationScheme<TYPE>::addMeshFluxConstructorToTable               \
00163 <CentredFitScheme<TYPE, POLYNOMIAL, STENCIL> >                                \
00164     add##SS##STENCIL##TYPE##MeshFluxConstructorToTable_;
00165 
00166 #define makeCentredFitSurfaceInterpolationScheme(SS, POLYNOMIAL, STENCIL)     \
00167                                                                               \
00168 makeCentredFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,scalar)    \
00169 makeCentredFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,vector)    \
00170 makeCentredFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,sphericalTensor) \
00171 makeCentredFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,symmTensor)\
00172 makeCentredFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,tensor)
00173 
00174 
00175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00176 
00177 #endif
00178 
00179 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd