initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / finiteVolume / interpolation / surfaceInterpolation / schemes / cubic / cubic.H
blobb5a809e0dbfff1b7f044c15ac78fddd3945c79e9
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 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 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::cubic
28 Description
29     Cubic interpolation scheme class derived from linear and returns
30     linear weighting factors but also applies an explicit correction.
32 SourceFiles
33     cubic.C
35 \*---------------------------------------------------------------------------*/
37 #ifndef cubic_H
38 #define cubic_H
40 #include "linear.H"
41 #include "gaussGrad.H"
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 namespace Foam
48 /*---------------------------------------------------------------------------*\
49                            Class cubic Declaration
50 \*---------------------------------------------------------------------------*/
52 template<class Type>
53 class cubic
55     public linear<Type>
57     // Private Member Functions
59         //- Disallow default bitwise copy construct
60         cubic(const cubic&);
62         //- Disallow default bitwise assignment
63         void operator=(const cubic&);
66 public:
68     //- Runtime type information
69     TypeName("cubic");
72     // Constructors
74         //- Construct from mesh
75         cubic(const fvMesh& mesh)
76         :
77             linear<Type>(mesh)
78         {}
80         //- Construct from mesh and Istream
81         cubic
82         (
83             const fvMesh& mesh,
84             Istream&
85         )
86         :
87             linear<Type>(mesh)
88         {}
90         //- Construct from mesh, faceFlux and Istream
91         cubic
92         (
93             const fvMesh& mesh,
94             const surfaceScalarField&,
95             Istream&
96         )
97         :
98             linear<Type>(mesh)
99         {}
102     // Member Functions
104         //- Return true if this scheme uses an explicit correction
105         virtual bool corrected() const
106         {
107             return true;
108         }
110         //- Return the explicit correction to the face-interpolate
111         virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
112         correction
113         (
114             const GeometricField<Type, fvPatchField, volMesh>& vf
115         ) const
116         {
117             const fvMesh& mesh = this->mesh();
119             // calculate the appropriate interpolation factors
120             const surfaceScalarField& lambda = mesh.weights();
122             surfaceScalarField kSc = 
123                 lambda*(scalar(1) - lambda*(scalar(3) - scalar(2)*lambda));
125             surfaceScalarField kVecP = sqr(scalar(1) - lambda)*lambda;
126             surfaceScalarField kVecN = sqr(lambda)*(lambda - scalar(1));
128             tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsfCorr
129             (
130                 new GeometricField<Type, fvsPatchField, surfaceMesh>
131                 (
132                     IOobject
133                     (
134                         vf.name(),
135                         mesh.time().timeName(),
136                         mesh
137                     ),
138                     surfaceInterpolationScheme<Type>::interpolate(vf, kSc, -kSc)
139                 )
140             );
142             GeometricField<Type, fvsPatchField, surfaceMesh>& sfCorr = tsfCorr();
144             for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
145             {
146                 sfCorr.replace
147                 (
148                     cmpt,
149                     sfCorr.component(cmpt)
150                   + (
151                         surfaceInterpolationScheme
152                         <
153                             typename outerProduct
154                             <
155                                 vector,
156                                 typename pTraits<Type>::cmptType
157                             >::type
158                         >::interpolate
159                         (
160                             fv::gaussGrad
161                             <typename pTraits<Type>::cmptType>(mesh)
162                            .grad(vf.component(cmpt)),
163                             kVecP,
164                             kVecN
165                         ) & mesh.Sf()
166                     )/mesh.magSf()/mesh.surfaceInterpolation::deltaCoeffs()
167                 );
168             }
170             forAll (sfCorr.boundaryField(), pi)
171             {
172                 if (!sfCorr.boundaryField()[pi].coupled())
173                 {
174                     sfCorr.boundaryField()[pi] = pTraits<Type>::zero;
175                 }
176             }
178             return tsfCorr;
179         }
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 } // End namespace Foam
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 #endif
191 // ************************************************************************* //