1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
28 Two-scheme fixed-blending differencing scheme.
30 Similar to localBlended but uses a single (global) constant blending
31 factor. The factor applies to the first scheme and 1-factor to the
35 Although a blending factor of 0 and 1 is permitted, it is more efficient
36 just to use the underlying scheme directly.
41 \*---------------------------------------------------------------------------*/
43 #ifndef fixedBlended_H
44 #define fixedBlended_H
46 #include "surfaceInterpolationScheme.H"
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 /*---------------------------------------------------------------------------*\
54 Class fixedBlended Declaration
55 \*---------------------------------------------------------------------------*/
60 public surfaceInterpolationScheme<Type>
64 const scalar blendingFactor_;
66 // Private Member Functions
69 tmp<surfaceInterpolationScheme<Type> > tScheme1_;
72 tmp<surfaceInterpolationScheme<Type> > tScheme2_;
75 //- Disallow default bitwise copy construct
76 fixedBlended(const fixedBlended&);
78 //- Disallow default bitwise assignment
79 void operator=(const fixedBlended&);
84 //- Runtime type information
85 TypeName("fixedBlended");
90 //- Construct from mesh and Istream.
91 // The name of the flux field is read from the Istream and looked-up
92 // from the mesh objectRegistry
99 surfaceInterpolationScheme<Type>(mesh),
100 blendingFactor_(readScalar(is)),
103 surfaceInterpolationScheme<Type>::New(mesh, is)
107 surfaceInterpolationScheme<Type>::New(mesh, is)
110 if (blendingFactor_ < 0 || blendingFactor_ > 1)
112 FatalIOErrorIn("fixedBlended(const fvMesh&, Istream&)", is)
113 << "coefficient = " << blendingFactor_
114 << " should be >= 0 and <= 1"
115 << exit(FatalIOError);
117 if (surfaceInterpolationScheme<Type>::debug)
119 Info<<"fixedBlended: " << blendingFactor_
120 << "*" << tScheme1_().type()
121 << " + (1-" << blendingFactor_ << ")*"
122 << tScheme2_().type()
128 //- Construct from mesh, faceFlux and Istream
132 const surfaceScalarField& faceFlux,
136 surfaceInterpolationScheme<Type>(mesh),
137 blendingFactor_(readScalar(is)),
140 surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
144 surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
147 if (blendingFactor_ < 0 || blendingFactor_ > 1)
149 FatalIOErrorIn("fixedBlended(const fvMesh&, Istream&)", is)
150 << "coefficient = " << blendingFactor_
151 << " should be >= 0 and <= 1"
152 << exit(FatalIOError);
154 if (surfaceInterpolationScheme<Type>::debug)
156 Info<<"fixedBlended: " << blendingFactor_
157 << "*" << tScheme1_().type()
158 << " + (1-" << blendingFactor_ << ")*"
159 << tScheme2_().type()
167 //- Return the interpolation weighting factors
168 tmp<surfaceScalarField>
171 const GeometricField<Type, fvPatchField, volMesh>& vf
175 blendingFactor_*tScheme1_().weights(vf)
176 + (scalar(1.0) - blendingFactor_)*tScheme2_().weights(vf);
180 //- Return the face-interpolate of the given cell field
181 // with explicit correction
182 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
185 const GeometricField<Type, fvPatchField, volMesh>& vf
189 blendingFactor_*tScheme1_().interpolate(vf)
190 + (scalar(1.0) - blendingFactor_)*tScheme2_().interpolate(vf);
194 //- Return true if this scheme uses an explicit correction
195 virtual bool corrected() const
197 return tScheme1_().corrected() || tScheme2_().corrected();
201 //- Return the explicit correction to the face-interpolate
202 // for the given field
203 virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
206 const GeometricField<Type, fvPatchField, volMesh>& vf
209 if (tScheme1_().corrected())
211 if (tScheme2_().corrected())
216 * tScheme1_().correction(vf)
217 + (scalar(1.0) - blendingFactor_)
218 * tScheme2_().correction(vf)
226 * tScheme1_().correction(vf)
230 else if (tScheme2_().corrected())
234 (scalar(1.0) - blendingFactor_)
235 * tScheme2_().correction(vf)
240 return tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252 } // End namespace Foam
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
258 // ************************************************************************* //