fixedBlended.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 Class
25  Foam::fixedBlended
26 
27 Description
28  Two-scheme fixed-blending differencing scheme.
29 
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
32  second scheme.
33 
34 Note
35  Although a blending factor of 0 and 1 is permitted, it is more efficient
36  just to use the underlying scheme directly.
37 
38 SourceFiles
39  fixedBlended.C
40 
41 \*---------------------------------------------------------------------------*/
42 
43 #ifndef fixedBlended_H
44 #define fixedBlended_H
45 
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 /*---------------------------------------------------------------------------*\
54  Class fixedBlended Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 template<class Type>
58 class fixedBlended
59 :
60  public surfaceInterpolationScheme<Type>
61 {
62  // Private data
63 
64  const scalar blendingFactor_;
65 
66  // Private Member Functions
67 
68  //- Scheme 1
70 
71  //- Scheme 2
73 
74 
75  //- Disallow default bitwise copy construct
76  fixedBlended(const fixedBlended&);
77 
78  //- Disallow default bitwise assignment
79  void operator=(const fixedBlended&);
80 
81 
82 public:
83 
84  //- Runtime type information
85  TypeName("fixedBlended");
86 
87 
88  // Constructors
89 
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
94  (
95  const fvMesh& mesh,
96  Istream& is
97  )
98  :
99  surfaceInterpolationScheme<Type>(mesh),
100  blendingFactor_(readScalar(is)),
101  tScheme1_
102  (
103  surfaceInterpolationScheme<Type>::New(mesh, is)
104  ),
105  tScheme2_
106  (
107  surfaceInterpolationScheme<Type>::New(mesh, is)
108  )
109  {
110  if (blendingFactor_ < 0 || blendingFactor_ > 1)
111  {
113  << "coefficient = " << blendingFactor_
114  << " should be >= 0 and <= 1"
115  << exit(FatalIOError);
116  }
118  {
119  Info<<"fixedBlended: " << blendingFactor_
120  << "*" << tScheme1_().type()
121  << " + (1-" << blendingFactor_ << ")*"
122  << tScheme2_().type()
123  <<endl;
124  }
125  }
126 
127 
128  //- Construct from mesh, faceFlux and Istream
130  (
131  const fvMesh& mesh,
132  const surfaceScalarField& faceFlux,
133  Istream& is
134  )
135  :
136  surfaceInterpolationScheme<Type>(mesh),
137  blendingFactor_(readScalar(is)),
138  tScheme1_
139  (
140  surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
141  ),
142  tScheme2_
143  (
144  surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
145  )
146  {
147  if (blendingFactor_ < 0 || blendingFactor_ > 1)
148  {
150  << "coefficient = " << blendingFactor_
151  << " should be >= 0 and <= 1"
152  << exit(FatalIOError);
153  }
155  {
156  Info<<"fixedBlended: " << blendingFactor_
157  << "*" << tScheme1_().type()
158  << " + (1-" << blendingFactor_ << ")*"
159  << tScheme2_().type()
160  <<endl;
161  }
162  }
163 
164 
165  // Member Functions
166 
167  //- Return the interpolation weighting factors
170  (
172  ) const
173  {
174  return
175  blendingFactor_*tScheme1_().weights(vf)
176  + (scalar(1) - blendingFactor_)*tScheme2_().weights(vf);
177  }
178 
179 
180  //- Return the face-interpolate of the given cell field
181  // with explicit correction
184  (
186  ) const
187  {
188  return
189  blendingFactor_*tScheme1_().interpolate(vf)
190  + (scalar(1) - blendingFactor_)*tScheme2_().interpolate(vf);
191  }
192 
193 
194  //- Return true if this scheme uses an explicit correction
195  virtual bool corrected() const
196  {
197  return tScheme1_().corrected() || tScheme2_().corrected();
198  }
199 
200 
201  //- Return the explicit correction to the face-interpolate
202  // for the given field
205  (
207  ) const
208  {
209  if (tScheme1_().corrected())
210  {
211  if (tScheme2_().corrected())
212  {
213  return
214  (
215  blendingFactor_
216  * tScheme1_().correction(vf)
217  + (scalar(1) - blendingFactor_)
218  * tScheme2_().correction(vf)
219  );
220  }
221  else
222  {
223  return
224  (
225  blendingFactor_
226  * tScheme1_().correction(vf)
227  );
228  }
229  }
230  else if (tScheme2_().corrected())
231  {
232  return
233  (
234  (scalar(1) - blendingFactor_)
235  * tScheme2_().correction(vf)
236  );
237  }
238  else
239  {
241  (
242  nullptr
243  );
244  }
245  }
246 
247 };
248 
249 
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
251 
252 } // End namespace Foam
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 #endif
257 
258 // ************************************************************************* //
TypeName("fixedBlended")
Runtime type information.
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:204
Two-scheme fixed-blending differencing scheme.
Definition: fixedBlended.H:57
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
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:183
static tmp< surfaceInterpolationScheme< Type > > New(const fvMesh &mesh, Istream &schemeData)
Return new tmp interpolation scheme.
virtual bool corrected() const
Return true if this scheme uses an explicit correction.
Definition: fixedBlended.H:194
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if successful.
Definition: doubleScalar.H:68
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:331
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
messageStream Info
A class for managing temporary objects.
Definition: PtrList.H:53
Abstract base class for surface interpolation schemes.
tmp< surfaceScalarField > weights(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the interpolation weighting factors.
Definition: fixedBlended.H:169
Namespace for OpenFOAM.
IOerror FatalIOError