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

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