Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / finiteVolume / interpolation / surfaceInterpolation / schemes / fixedBlended / fixedBlended.H
blob2843ec24da6b3c312c7ab252c21dd7e83ded5e6f
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::fixedBlended
28 Description
29     Two-scheme fixed-blending differencing scheme.
31     Similar to localBlended but uses a single (global) constant blending
32     factor. The factor applies to the first scheme and 1-factor to the
33     second scheme.
35 Note
36     Although a blending factor of 0 and 1 is permitted, it is more efficient
37     just to use the underlying scheme directly.
39 SourceFiles
40     fixedBlended.C
42 \*---------------------------------------------------------------------------*/
44 #ifndef fixedBlended_H
45 #define fixedBlended_H
47 #include "surfaceInterpolationScheme.H"
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 namespace Foam
54 /*---------------------------------------------------------------------------*\
55                         Class fixedBlended Declaration
56 \*---------------------------------------------------------------------------*/
58 template<class Type>
59 class fixedBlended
61     public surfaceInterpolationScheme<Type>
63     // Private data
65         const scalar blendingFactor_;
67     // Private Member Functions
69         //- Scheme 1
70         tmp<surfaceInterpolationScheme<Type> > tScheme1_;
72         //- Scheme 2
73         tmp<surfaceInterpolationScheme<Type> > tScheme2_;
76         //- Disallow default bitwise copy construct
77         fixedBlended(const fixedBlended&);
79         //- Disallow default bitwise assignment
80         void operator=(const fixedBlended&);
83 public:
85     //- Runtime type information
86     TypeName("fixedBlended");
89     // Constructors
91         //- Construct from mesh and Istream.
92         //  The name of the flux field is read from the Istream and looked-up
93         //  from the mesh objectRegistry
94         fixedBlended
95         (
96             const fvMesh& mesh,
97             Istream& is
98         )
99         :
100             surfaceInterpolationScheme<Type>(mesh),
101             blendingFactor_(readScalar(is)),
102             tScheme1_
103             (
104                 surfaceInterpolationScheme<Type>::New(mesh, is)
105             ),
106             tScheme2_
107             (
108                 surfaceInterpolationScheme<Type>::New(mesh, is)
109             )
110         {
111             if (blendingFactor_ < 0 || blendingFactor_ > 1)
112             {
113                 FatalIOErrorIn("fixedBlended(const fvMesh&, Istream&)", is)
114                     << "coefficient = " << blendingFactor_
115                     << " should be >= 0 and <= 1"
116                     << exit(FatalIOError);
117             }
118             if (surfaceInterpolationScheme<Type>::debug)
119             {
120                 Info<<"fixedBlended: " << blendingFactor_
121                     << "*" << tScheme1_().type()
122                     << " + (1-" << blendingFactor_ << ")*"
123                     << tScheme2_().type()
124                     <<endl;
125             }
126         }
129         //- Construct from mesh, faceFlux and Istream
130         fixedBlended
131         (
132             const fvMesh& mesh,
133             const surfaceScalarField& faceFlux,
134             Istream& is
135         )
136         :
137             surfaceInterpolationScheme<Type>(mesh),
138             blendingFactor_(readScalar(is)),
139             tScheme1_
140             (
141                 surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
142             ),
143             tScheme2_
144             (
145                 surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
146             )
147         {
148             if (blendingFactor_ < 0 || blendingFactor_ > 1)
149             {
150                 FatalIOErrorIn("fixedBlended(const fvMesh&, Istream&)", is)
151                     << "coefficient = " << blendingFactor_
152                     << " should be >= 0 and <= 1"
153                     << exit(FatalIOError);
154             }
155             if (surfaceInterpolationScheme<Type>::debug)
156             {
157                 Info<<"fixedBlended: " << blendingFactor_
158                     << "*" << tScheme1_().type()
159                     << " + (1-" << blendingFactor_ << ")*"
160                     << tScheme2_().type()
161                     <<endl;
162             }
163         }
166     // Member Functions
168         //- Return the interpolation weighting factors
169         tmp<surfaceScalarField>
170         weights
171         (
172             const GeometricField<Type, fvPatchField, volMesh>& vf
173         ) const
174         {
175             return
176                 blendingFactor_*tScheme1_().weights(vf)
177               + (scalar(1.0) - blendingFactor_)*tScheme2_().weights(vf);
178         }
181         //- Return the face-interpolate of the given cell field
182         //  with explicit correction
183         tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
184         interpolate
185         (
186             const GeometricField<Type, fvPatchField, volMesh>& vf
187         ) const
188         {
189             return
190                 blendingFactor_*tScheme1_().interpolate(vf)
191               + (scalar(1.0) - blendingFactor_)*tScheme2_().interpolate(vf);
192         }
195         //- Return true if this scheme uses an explicit correction
196         virtual bool corrected() const
197         {
198             return tScheme1_().corrected() || tScheme2_().corrected();
199         }
202         //- Return the explicit correction to the face-interpolate
203         //  for the given field
204         virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
205         correction
206         (
207             const GeometricField<Type, fvPatchField, volMesh>& vf
208         ) const
209         {
210             if (tScheme1_().corrected())
211             {
212                 if (tScheme2_().corrected())
213                 {
214                     return
215                     (
216                         blendingFactor_
217                       * tScheme1_().correction(vf)
218                       + (scalar(1.0) - blendingFactor_)
219                       * tScheme2_().correction(vf)
220                     );
221                 }
222                 else
223                 {
224                     return
225                     (
226                         blendingFactor_
227                       * tScheme1_().correction(vf)
228                     );
229                 }
230             }
231             else if (tScheme2_().corrected())
232             {
233                 return
234                 (
235                     (scalar(1.0) - blendingFactor_)
236                   * tScheme2_().correction(vf)
237                 );
238             }
239             else
240             {
241                 return tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
242                 (
243                     NULL
244                 );
245             }
246         }
251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253 } // End namespace Foam
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257 #endif
259 // ************************************************************************* //