fixedBlended.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::fixedBlended
28
29Group
30 grpFvSurfaceInterpolationSchemes
31
32Description
33 Two-scheme fixed-blending differencing scheme.
34
35 Similar to localBlended but uses a single (global) constant blending
36 factor. The factor applies to the first scheme and 1-factor to the
37 second scheme.
38
39Note
40 Although a blending factor of 0 and 1 is permitted, it is more efficient
41 just to use the underlying scheme directly.
42
43SourceFiles
44 fixedBlended.C
45
46\*---------------------------------------------------------------------------*/
47
48#ifndef fixedBlended_H
49#define fixedBlended_H
50
52
53// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54
55namespace Foam
56{
57
58/*---------------------------------------------------------------------------*\
59 Class fixedBlended Declaration
60\*---------------------------------------------------------------------------*/
61
62template<class Type>
63class fixedBlended
64:
66{
67 // Private data
68
69 const scalar blendingFactor_;
70
71 // Private Member Functions
72
73 //- Scheme 1
75
76 //- Scheme 2
78
79
80 //- No copy construct
81 fixedBlended(const fixedBlended&) = delete;
82
83 //- No copy assignment
84 void operator=(const fixedBlended&) = delete;
85
86
87public:
88
89 //- Runtime type information
90 TypeName("fixedBlended");
91
92
93 // Constructors
94
95 //- Construct from mesh and Istream.
96 // The name of the flux field is read from the Istream and looked-up
97 // from the mesh objectRegistry
99 (
100 const fvMesh& mesh,
101 Istream& is
102 )
103 :
105 blendingFactor_(readScalar(is)),
106 tScheme1_
107 (
109 ),
110 tScheme2_
111 (
113 )
114 {
115 if (blendingFactor_ < 0 || blendingFactor_ > 1)
116 {
118 << "coefficient = " << blendingFactor_
119 << " should be >= 0 and <= 1"
120 << exit(FatalIOError);
121 }
123 {
124 Info<<"fixedBlended: " << blendingFactor_
125 << "*" << tScheme1_().type()
126 << " + (1-" << blendingFactor_ << ")*"
127 << tScheme2_().type()
128 <<endl;
129 }
130 }
131
132
133 //- Construct from mesh, faceFlux and Istream
135 (
136 const fvMesh& mesh,
137 const surfaceScalarField& faceFlux,
138 Istream& is
139 )
140 :
142 blendingFactor_(readScalar(is)),
143 tScheme1_
144 (
145 surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
146 ),
147 tScheme2_
148 (
149 surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
150 )
151 {
152 if (blendingFactor_ < 0 || blendingFactor_ > 1)
153 {
155 << "coefficient = " << blendingFactor_
156 << " should be >= 0 and <= 1"
157 << exit(FatalIOError);
158 }
160 {
161 Info<<"fixedBlended: " << blendingFactor_
162 << "*" << tScheme1_().type()
163 << " + (1-" << blendingFactor_ << ")*"
164 << tScheme2_().type()
165 <<endl;
166 }
167 }
168
169
170 // Member Functions
171
172 //- Return the interpolation weighting factors
174 weights
175 (
177 ) const
178 {
179 return
180 blendingFactor_*tScheme1_().weights(vf)
181 + (scalar(1) - blendingFactor_)*tScheme2_().weights(vf);
182 }
183
184
185 //- Return the face-interpolate of the given cell field
186 // with explicit correction
189 (
191 ) const
192 {
193 return
194 blendingFactor_*tScheme1_().interpolate(vf)
195 + (scalar(1) - blendingFactor_)*tScheme2_().interpolate(vf);
196 }
197
198
199 //- Return true if this scheme uses an explicit correction
200 virtual bool corrected() const
201 {
202 return tScheme1_().corrected() || tScheme2_().corrected();
203 }
204
205
206 //- Return the explicit correction to the face-interpolate
207 // for the given field
210 (
212 ) const
213 {
214 if (tScheme1_().corrected())
215 {
216 if (tScheme2_().corrected())
217 {
218 return
219 (
220 blendingFactor_
221 * tScheme1_().correction(vf)
222 + (scalar(1) - blendingFactor_)
223 * tScheme2_().correction(vf)
224 );
225 }
226 else
227 {
228 return
229 (
230 blendingFactor_
231 * tScheme1_().correction(vf)
232 );
233 }
234 }
235 else if (tScheme2_().corrected())
236 {
237 return
238 (
239 (scalar(1) - blendingFactor_)
240 * tScheme2_().correction(vf)
241 );
242 }
243 else
244 {
246 (
247 nullptr
248 );
249 }
250 }
251
252};
253
254
255// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256
257} // End namespace Foam
258
259// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260
261#endif
262
263// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
Two-scheme fixed-blending differencing scheme.
Definition: fixedBlended.H:65
virtual bool corrected() const
Return true if this scheme uses an explicit correction.
Definition: fixedBlended.H:199
TypeName("fixedBlended")
Runtime type information.
tmp< surfaceScalarField > weights(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the interpolation weighting factors.
Definition: fixedBlended.H:174
virtual tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > correction(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the explicit correction to the face-interpolate.
Definition: fixedBlended.H:209
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the face-interpolate of the given cell field.
Definition: fixedBlended.H:188
fixedBlended(const fvMesh &mesh, const surfaceScalarField &faceFlux, Istream &is)
Construct from mesh, faceFlux and Istream.
Definition: fixedBlended.H:134
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Abstract base class for surface interpolation schemes.
const fvMesh & mesh() const
Return mesh reference.
static tmp< surfaceInterpolationScheme< Type > > New(const fvMesh &mesh, Istream &schemeData)
Return new tmp interpolation scheme.
A class for managing temporary objects.
Definition: tmp.H:65
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
IOerror FatalIOError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73