Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / finiteVolume / interpolation / surfaceInterpolation / schemes / linearUpwind / linearUpwind.H
blob13b98512df680f03e1d89f12f104f58af6a6257c
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2011 OpenCFD Ltd.
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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 Class
25     Foam::linearUpwind
27 Description
28     linearUpwind interpolation scheme class derived from upwind and returns
29     upwind weighting factors and also applies a gradient-based explicit
30     correction.
32 SourceFiles
33     linearUpwind.C
35 \*---------------------------------------------------------------------------*/
37 #ifndef linearUpwind_H
38 #define linearUpwind_H
40 #include "upwind.H"
41 #include "gaussGrad.H"
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 namespace Foam
48 /*---------------------------------------------------------------------------*\
49                            Class linearUpwind Declaration
50 \*---------------------------------------------------------------------------*/
52 template<class Type>
53 class linearUpwind
55     public upwind<Type>
57     // Private Data
59         word gradSchemeName_;
60         tmp<fv::gradScheme<Type> > gradScheme_;
63     // Private Member Functions
65         //- Disallow default bitwise copy construct
66         linearUpwind(const linearUpwind&);
68         //- Disallow default bitwise assignment
69         void operator=(const linearUpwind&);
72 public:
74     //- Runtime type information
75     TypeName("linearUpwind");
78     // Constructors
80         //- Construct from faceFlux
81         linearUpwind
82         (
83             const fvMesh& mesh,
84             const surfaceScalarField& faceFlux
85         )
86         :
87             upwind<Type>(mesh, faceFlux),
88             gradSchemeName_("grad"),
89             gradScheme_
90             (
91                 new fv::gaussGrad<Type>(mesh)
92             )
93         {}
95         //- Construct from Istream.
96         //  The name of the flux field is read from the Istream and looked-up
97         //  from the mesh objectRegistry
98         linearUpwind
99         (
100             const fvMesh& mesh,
101             Istream& schemeData
102         )
103         :
104             upwind<Type>(mesh, schemeData),
105             gradSchemeName_(schemeData),
106             gradScheme_
107             (
108                 fv::gradScheme<Type>::New
109                 (
110                     mesh,
111                     mesh.gradScheme(gradSchemeName_)
112                 )
113             )
114         {
115             if (!schemeData.eof())
116             {
117                 IOWarningIn("linearUpwind(const fvMesh&, Istream&)", schemeData)
118                     << "unexpected additional entries in stream." << nl
119                     << "    Only the name of the gradient scheme in the"
120                        " 'gradSchemes' dictionary should be specified."
121                     << endl;
122             }
123         }
125         //- Construct from faceFlux and Istream
126         linearUpwind
127         (
128             const fvMesh& mesh,
129             const surfaceScalarField& faceFlux,
130             Istream& schemeData
131         )
132         :
133             upwind<Type>(mesh, faceFlux, schemeData),
134             gradSchemeName_(schemeData),
135             gradScheme_
136             (
137                 fv::gradScheme<Type>::New
138                 (
139                     mesh,
140                     mesh.gradScheme(gradSchemeName_)
141                 )
142             )
143         {
144             if (!schemeData.eof())
145             {
146                 IOWarningIn("linearUpwind(const fvMesh&, Istream&)", schemeData)
147                     << "unexpected additional entries in stream." << nl
148                     << "    Only the name of the gradient scheme in the"
149                        " 'gradSchemes' dictionary should be specified."
150                     << endl;
151             }
152         }
155     // Member Functions
157         //- Return true if this scheme uses an explicit correction
158         virtual bool corrected() const
159         {
160             return true;
161         }
163         //- Return the explicit correction to the face-interpolate
164         virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
165         correction
166         (
167             const GeometricField<Type, fvPatchField, volMesh>&
168         ) const;
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 } // End namespace Foam
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 #endif
181 // ************************************************************************* //