localBlended.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 | Copyright (C) 2011-2016 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::localBlended
26 
27 Description
28  Two-scheme localBlended differencing scheme.
29 
30 SourceFiles
31  localBlended.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef localBlended_H
36 #define localBlended_H
37 
39 #include "blendedSchemeBase.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class localBlended Declaration
48 \*---------------------------------------------------------------------------*/
49 
50 template<class Type>
51 class localBlended
52 :
53  public surfaceInterpolationScheme<Type>,
54  public blendedSchemeBase<Type>
55 {
56  // Private Member Functions
57 
58  //- Scheme 1
60 
61  //- Scheme 2
63 
64 
65  //- Disallow default bitwise copy construct
66  localBlended(const localBlended&);
67 
68  //- Disallow default bitwise assignment
69  void operator=(const localBlended&);
70 
71 
72 public:
73 
74  //- Runtime type information
75  TypeName("localBlended");
76 
77 
78  // Constructors
79 
80  //- Construct from mesh and Istream.
81  // The name of the flux field is read from the Istream and looked-up
82  // from the mesh objectRegistry
84  (
85  const fvMesh& mesh,
86  Istream& is
87  )
88  :
89  surfaceInterpolationScheme<Type>(mesh),
90  tScheme1_
91  (
92  surfaceInterpolationScheme<Type>::New(mesh, is)
93  ),
94  tScheme2_
95  (
96  surfaceInterpolationScheme<Type>::New(mesh, is)
97  )
98  {}
99 
100  //- Construct from mesh, faceFlux and Istream
102  (
103  const fvMesh& mesh,
104  const surfaceScalarField& faceFlux,
105  Istream& is
106  )
107  :
108  surfaceInterpolationScheme<Type>(mesh),
109  tScheme1_
110  (
111  surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
112  ),
113  tScheme2_
114  (
115  surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
116  )
117  {}
118 
119 
120  //- Destructor
121  virtual ~localBlended()
122  {}
123 
124 
125  // Member Functions
126 
127  //- Return the face-based blending factor
129  (
131  ) const
132  {
133  return
134  this->mesh().objectRegistry::template
135  lookupObject<const surfaceScalarField>
136  (
137  word(vf.name() + "BlendingFactor")
138  );
139  }
140 
141  //- Return the interpolation weighting factors
143  (
145  ) const
146  {
148  this->mesh().objectRegistry::template
149  lookupObject<const surfaceScalarField>
150  (
151  word(vf.name() + "BlendingFactor")
152  );
153 
154  return
155  blendingFactor*tScheme1_().weights(vf)
156  + (scalar(1) - blendingFactor)*tScheme2_().weights(vf);
157  }
158 
159  //- Return the face-interpolate of the given cell field
160  // with explicit correction
163  {
165  (
166  this->mesh().objectRegistry::template
167  lookupObject<const surfaceScalarField>
168  (
169  word(vf.name() + "BlendingFactor")
170  )
171  );
172 
173  return
174  blendingFactor*tScheme1_().interpolate(vf)
175  + (scalar(1) - blendingFactor)*tScheme2_().interpolate(vf);
176  }
177 
178 
179  //- Return true if this scheme uses an explicit correction
180  virtual bool corrected() const
181  {
182  return tScheme1_().corrected() || tScheme2_().corrected();
183  }
184 
185 
186  //- Return the explicit correction to the face-interpolate
187  // for the given field
190  (
192  ) const
193  {
195  this->mesh().objectRegistry::template
196  lookupObject<const surfaceScalarField>
197  (
198  word(vf.name() + "BlendingFactor")
199  );
200 
201  if (tScheme1_().corrected())
202  {
203  if (tScheme2_().corrected())
204  {
205  return
206  (
207  blendingFactor
208  * tScheme1_().correction(vf)
209  + (scalar(1.0) - blendingFactor)
210  * tScheme2_().correction(vf)
211  );
212  }
213  else
214  {
215  return
216  (
217  blendingFactor
218  * tScheme1_().correction(vf)
219  );
220  }
221  }
222  else if (tScheme2_().corrected())
223  {
224  return
225  (
226  (scalar(1.0) - blendingFactor)
227  * tScheme2_().correction(vf)
228  );
229  }
230  else
231  {
233  (
234  NULL
235  );
236  }
237  }
238 };
239 
240 
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 
243 } // End namespace Foam
244 
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 
247 #endif
248 
249 // ************************************************************************* //
const fvMesh & mesh() const
Return mesh reference.
virtual tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > correction(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the explicit correction to the face-interpolate.
Definition: localBlended.H:189
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
virtual bool corrected() const
Return true if this scheme uses an explicit correction.
Definition: localBlended.H:179
virtual ~localBlended()
Destructor.
Definition: localBlended.H:120
A class for handling words, derived from string.
Definition: word.H:59
static tmp< surfaceInterpolationScheme< Type > > New(const fvMesh &mesh, Istream &schemeData)
Return new tmp interpolation scheme.
Base class for blended schemes to provide access to the blending factor surface field.
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the face-interpolate of the given cell field.
Definition: localBlended.H:161
tmp< surfaceScalarField > weights(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the interpolation weighting factors.
Definition: localBlended.H:142
Two-scheme localBlended differencing scheme.
Definition: localBlended.H:50
virtual tmp< surfaceScalarField > blendingFactor(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the face-based blending factor.
Definition: localBlended.H:128
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
A class for managing temporary objects.
Definition: PtrList.H:54
TypeName("localBlended")
Runtime type information.
Abstract base class for surface interpolation schemes.
const word & name() const
Return name.
Definition: IOobject.H:260
Namespace for OpenFOAM.