1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
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
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
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
36 Although a blending factor of 0 and 1 is permitted, it is more efficient
37 just to use the underlying scheme directly.
42 \*---------------------------------------------------------------------------*/
44 #ifndef fixedBlended_H
45 #define fixedBlended_H
47 #include "surfaceInterpolationScheme.H"
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 /*---------------------------------------------------------------------------*\
55 Class fixedBlended Declaration
56 \*---------------------------------------------------------------------------*/
61 public surfaceInterpolationScheme<Type>
65 const scalar blendingFactor_;
67 // Private Member Functions
70 tmp<surfaceInterpolationScheme<Type> > tScheme1_;
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&);
85 //- Runtime type information
86 TypeName("fixedBlended");
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
100 surfaceInterpolationScheme<Type>(mesh),
101 blendingFactor_(readScalar(is)),
104 surfaceInterpolationScheme<Type>::New(mesh, is)
108 surfaceInterpolationScheme<Type>::New(mesh, is)
111 if (blendingFactor_ < 0 || blendingFactor_ > 1)
113 FatalIOErrorIn("fixedBlended(const fvMesh&, Istream&)", is)
114 << "coefficient = " << blendingFactor_
115 << " should be >= 0 and <= 1"
116 << exit(FatalIOError);
118 if (surfaceInterpolationScheme<Type>::debug)
120 Info<<"fixedBlended: " << blendingFactor_
121 << "*" << tScheme1_().type()
122 << " + (1-" << blendingFactor_ << ")*"
123 << tScheme2_().type()
129 //- Construct from mesh, faceFlux and Istream
133 const surfaceScalarField& faceFlux,
137 surfaceInterpolationScheme<Type>(mesh),
138 blendingFactor_(readScalar(is)),
141 surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
145 surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
148 if (blendingFactor_ < 0 || blendingFactor_ > 1)
150 FatalIOErrorIn("fixedBlended(const fvMesh&, Istream&)", is)
151 << "coefficient = " << blendingFactor_
152 << " should be >= 0 and <= 1"
153 << exit(FatalIOError);
155 if (surfaceInterpolationScheme<Type>::debug)
157 Info<<"fixedBlended: " << blendingFactor_
158 << "*" << tScheme1_().type()
159 << " + (1-" << blendingFactor_ << ")*"
160 << tScheme2_().type()
168 //- Return the interpolation weighting factors
169 tmp<surfaceScalarField>
172 const GeometricField<Type, fvPatchField, volMesh>& vf
176 blendingFactor_*tScheme1_().weights(vf)
177 + (scalar(1.0) - blendingFactor_)*tScheme2_().weights(vf);
181 //- Return the face-interpolate of the given cell field
182 // with explicit correction
183 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
186 const GeometricField<Type, fvPatchField, volMesh>& vf
190 blendingFactor_*tScheme1_().interpolate(vf)
191 + (scalar(1.0) - blendingFactor_)*tScheme2_().interpolate(vf);
195 //- Return true if this scheme uses an explicit correction
196 virtual bool corrected() const
198 return tScheme1_().corrected() || tScheme2_().corrected();
202 //- Return the explicit correction to the face-interpolate
203 // for the given field
204 virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
207 const GeometricField<Type, fvPatchField, volMesh>& vf
210 if (tScheme1_().corrected())
212 if (tScheme2_().corrected())
217 * tScheme1_().correction(vf)
218 + (scalar(1.0) - blendingFactor_)
219 * tScheme2_().correction(vf)
227 * tScheme1_().correction(vf)
231 else if (tScheme2_().corrected())
235 (scalar(1.0) - blendingFactor_)
236 * tScheme2_().correction(vf)
241 return tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253 } // End namespace Foam
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 // ************************************************************************* //