initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / finiteVolume / interpolation / surfaceInterpolation / schemes / reverseLinear / reverseLinear.H
blob2d5bc309e97cfcf539631c179ba2bb91234cd648
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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::reverseLinear
28 Description
29     Inversed weight central-differencing interpolation scheme class.
31     Useful for inverse weighted and harmonic interpolations.
33 SourceFiles
34     reverseLinear.C
36 \*---------------------------------------------------------------------------*/
38 #ifndef reverseLinear_H
39 #define reverseLinear_H
41 #include "surfaceInterpolationScheme.H"
42 #include "volFields.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 namespace Foam
49 /*---------------------------------------------------------------------------*\
50                            Class reverseLinear Declaration
51 \*---------------------------------------------------------------------------*/
53 template<class Type>
54 class reverseLinear
56     public surfaceInterpolationScheme<Type>
58     // Private Member Functions
60         //- Disallow default bitwise assignment
61         void operator=(const reverseLinear&);
64 public:
66     //- Runtime type information
67     TypeName("reverseLinear");
70     // Constructors
72         //- Construct from mesh
73         reverseLinear(const fvMesh& mesh)
74         :
75             surfaceInterpolationScheme<Type>(mesh)
76         {}
78         //- Construct from Istream
79         reverseLinear(const fvMesh& mesh, Istream&)
80         :
81             surfaceInterpolationScheme<Type>(mesh)
82         {}
84         //- Construct from faceFlux and Istream
85         reverseLinear
86         (
87             const fvMesh& mesh,
88             const surfaceScalarField&,
89             Istream&
90         )
91         :
92             surfaceInterpolationScheme<Type>(mesh)
93         {}
96     // Member Functions
98         //- Return the interpolation weighting factors
99         tmp<surfaceScalarField> weights
100         (
101             const GeometricField<Type, fvPatchField, volMesh>&
102         ) const
103         {
104             const fvMesh& mesh = this->mesh();
106             tmp<surfaceScalarField> tcdWeights
107             (
108                 mesh.surfaceInterpolation::weights()
109             );
110             const surfaceScalarField& cdWeights = tcdWeights();
112             tmp<surfaceScalarField> treverseLinearWeights
113             (
114                 new surfaceScalarField
115                 (
116                     IOobject
117                     (
118                         "reverseLinearWeights",
119                         mesh.time().timeName(),
120                         mesh
121                     ),
122                     mesh,
123                     dimless
124                 )
125             );
126             surfaceScalarField& reverseLinearWeights = treverseLinearWeights();
128             reverseLinearWeights.internalField() =
129                 1.0 - cdWeights.internalField();
131             forAll (mesh.boundary(), patchI)
132             {
133                 if (mesh.boundary()[patchI].coupled())
134                 {
135                     reverseLinearWeights.boundaryField()[patchI] =
136                         1.0 - cdWeights.boundaryField()[patchI];
137                 }
138                 else
139                 {
140                     reverseLinearWeights.boundaryField()[patchI] =
141                         cdWeights.boundaryField()[patchI];
142                 }
143             }
145             return treverseLinearWeights;
146         }
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 } // End namespace Foam
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 #endif
158 // ************************************************************************* //