Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / finiteVolume / interpolation / surfaceInterpolation / schemes / PureUpwindFitScheme / PureUpwindFitScheme.H
blobc5bf6235a2942747a7fe7178739882b5e2513767
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::PureUpwindFitScheme
28 Description
29     Upwind biased fit surface interpolation scheme that applies an explicit
30     correction to upwind.
32 \*---------------------------------------------------------------------------*/
34 #ifndef PureUpwindFitScheme_H
35 #define PureUpwindFitScheme_H
37 #include "UpwindFitData.H"
38 #include "upwind.H"
39 #include "Switch.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 namespace Foam
46 /*---------------------------------------------------------------------------*\
47                            Class PureUpwindFitScheme Declaration
48 \*---------------------------------------------------------------------------*/
50 template<class Type, class Polynomial, class Stencil>
51 class PureUpwindFitScheme
53     public upwind<Type>
55     // Private Data
57         //- Factor the fit is allowed to deviate from linear.
58         //  This limits the amount of high-order correction and increases
59         //  stability on bad meshes
60         const scalar linearLimitFactor_;
62         //- Weights for central stencil
63         const scalar centralWeight_;
66     // Private Member Functions
68         //- Disallow default bitwise copy construct
69         PureUpwindFitScheme(const PureUpwindFitScheme&);
71         //- Disallow default bitwise assignment
72         void operator=(const PureUpwindFitScheme&);
75 public:
77     //- Runtime type information
78     TypeName("PureUpwindFitScheme");
81     // Constructors
83         //- Construct from mesh and Istream
84         //  The name of the flux field is read from the Istream and looked-up
85         //  from the mesh objectRegistry
86         PureUpwindFitScheme(const fvMesh& mesh, Istream& is)
87         :
88             upwind<Type>
89             (
90                 mesh,
91                 mesh.lookupObject<surfaceScalarField>(word(is))
92             ),
93             linearLimitFactor_(readScalar(is)),
94             centralWeight_(1000)
95         {}
98         //- Construct from mesh, faceFlux and Istream
99         PureUpwindFitScheme
100         (
101             const fvMesh& mesh,
102             const surfaceScalarField& faceFlux,
103             Istream& is
104         )
105         :
106             upwind<Type>(mesh, faceFlux),
107             linearLimitFactor_(readScalar(is)),
108             centralWeight_(1000)
109         {}
112     // Member Functions
114         //- Return true if this scheme uses an explicit correction
115         virtual bool corrected() const
116         {
117             return true;
118         }
120         //- Return the explicit correction to the face-interpolate
121         virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
122         correction
123         (
124             const GeometricField<Type, fvPatchField, volMesh>& vf
125         ) const
126         {
127             const fvMesh& mesh = this->mesh();
129             // Use the owner/neighbour splitting constructor
130             const extendedUpwindCellToFaceStencil& stencil = Stencil::New(mesh);
132             const UpwindFitData<Polynomial>& ufd =
133             UpwindFitData<Polynomial>::New
134             (
135                 mesh,
136                 stencil,
137                 false,              //offset to upwind
138                 linearLimitFactor_,
139                 centralWeight_
140             );
142             const List<scalarList>& fo = ufd.owncoeffs();
143             const List<scalarList>& fn = ufd.neicoeffs();
145             return stencil.weightedSum(this->faceFlux_, vf, fo, fn);
146         }
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 } // End namespace Foam
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 // Add the patch constructor functions to the hash tables
158 #define makePureUpwindFitSurfaceInterpolationTypeScheme(SS, POLYNOMIAL, STENCIL, TYPE) \
159                                                                               \
160 typedef PureUpwindFitScheme<TYPE, POLYNOMIAL, STENCIL>                            \
161     PureUpwindFitScheme##TYPE##POLYNOMIAL##STENCIL##_;                            \
162 defineTemplateTypeNameAndDebugWithName                                        \
163     (PureUpwindFitScheme##TYPE##POLYNOMIAL##STENCIL##_, #SS, 0);                  \
164                                                                               \
165 surfaceInterpolationScheme<TYPE>::addMeshConstructorToTable                   \
166 <PureUpwindFitScheme<TYPE, POLYNOMIAL, STENCIL> >                                 \
167     add##SS##STENCIL##TYPE##MeshConstructorToTable_;                          \
168                                                                               \
169 surfaceInterpolationScheme<TYPE>::addMeshFluxConstructorToTable               \
170 <PureUpwindFitScheme<TYPE, POLYNOMIAL, STENCIL> >                                 \
171     add##SS##STENCIL##TYPE##MeshFluxConstructorToTable_;
173 #define makePureUpwindFitSurfaceInterpolationScheme(SS, POLYNOMIAL, STENCIL)      \
174                                                                               \
175 makePureUpwindFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,scalar)     \
176 makePureUpwindFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,vector)     \
177 makePureUpwindFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,sphericalTensor) \
178 makePureUpwindFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,symmTensor) \
179 makePureUpwindFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,tensor)
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 #endif
186 // ************************************************************************* //