initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / finiteVolume / finiteVolume / snGradSchemes / correctedSnGrad / correctedSnGrad.C
blob1fcedcfb9b7b645634f8b05126a6f326d5838f2c
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 Description
26     Simple central-difference snGrad scheme with non-orthogonal correction.
28 \*---------------------------------------------------------------------------*/
30 #include "correctedSnGrad.H"
31 #include "volFields.H"
32 #include "surfaceFields.H"
33 #include "linear.H"
34 #include "fvcGrad.H"
35 #include "gaussGrad.H"
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 namespace Foam
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 namespace fv
47 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
49 template<class Type>
50 correctedSnGrad<Type>::~correctedSnGrad()
54 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
56 template<class Type>
57 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
58 correctedSnGrad<Type>::correction
60     const GeometricField<Type, fvPatchField, volMesh>& vf
61 ) const
63     const fvMesh& mesh = this->mesh();
65     // construct GeometricField<Type, fvsPatchField, surfaceMesh>
66     tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tssf
67     (
68         new GeometricField<Type, fvsPatchField, surfaceMesh>
69         (
70             IOobject
71             (
72                 "snGradCorr("+vf.name()+')',
73                 vf.instance(),
74                 mesh,
75                 IOobject::NO_READ,
76                 IOobject::NO_WRITE
77             ),
78             mesh,
79             vf.dimensions()*mesh.deltaCoeffs().dimensions()
80         )
81     );
82     GeometricField<Type, fvsPatchField, surfaceMesh>& ssf = tssf();
84     for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; cmpt++)
85     {
86         ssf.replace
87         (
88             cmpt,
89             mesh.correctionVectors()
90           & linear
91             <
92                 typename 
93                 outerProduct<vector, typename pTraits<Type>::cmptType>::type
94             >(mesh).interpolate
95             (
96                 gradScheme<typename pTraits<Type>::cmptType>::New
97                 (
98                     mesh,
99                     mesh.gradScheme(ssf.name())
100                 )()
101                 //gaussGrad<typename pTraits<Type>::cmptType>(mesh)
102                .grad(vf.component(cmpt))
103             )
104         );
105     }
107     return tssf;
111 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
113 } // End namespace fv
115 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
117 } // End namespace Foam
119 // ************************************************************************* //