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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::localBlended
29 
30 Group
31  grpFvSurfaceInterpolationSchemes
32 
33 Description
34  Two-scheme localBlended differencing scheme.
35 
36 SourceFiles
37  localBlended.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef localBlended_H
42 #define localBlended_H
43 
45 #include "blendedSchemeBase.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class localBlended Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 template<class Type>
57 class localBlended
58 :
59  public surfaceInterpolationScheme<Type>,
60  public blendedSchemeBase<Type>
61 {
62  // Private Member Functions
63 
64  //- Scheme 1
66 
67  //- Scheme 2
69 
70 
71  //- No copy construct
72  localBlended(const localBlended&) = delete;
73 
74  //- No copy assignment
75  void operator=(const localBlended&) = delete;
76 
77 
78 public:
79 
80  //- Runtime type information
81  TypeName("localBlended");
82 
83 
84  // Constructors
85 
86  //- Construct from mesh and Istream.
87  // The name of the flux field is read from the Istream and looked-up
88  // from the mesh objectRegistry
90  (
91  const fvMesh& mesh,
92  Istream& is
93  )
94  :
96  tScheme1_
97  (
99  ),
100  tScheme2_
101  (
103  )
104  {}
105 
106  //- Construct from mesh, faceFlux and Istream
108  (
109  const fvMesh& mesh,
110  const surfaceScalarField& faceFlux,
111  Istream& is
112  )
113  :
115  tScheme1_
116  (
117  surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
118  ),
119  tScheme2_
120  (
121  surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
122  )
123  {}
124 
125 
126  //- Destructor
127  virtual ~localBlended() = default;
128 
129 
130  // Member Functions
131 
132  //- Return the face-based blending factor
134  (
136  ) const
137  {
138  return
139  this->mesh().objectRegistry::template
140  lookupObject<const surfaceScalarField>
141  (
142  word(vf.name() + "BlendingFactor")
143  );
144  }
145 
146  //- Return the interpolation weighting factors
148  (
150  ) const
151  {
153  this->mesh().objectRegistry::template
154  lookupObject<const surfaceScalarField>
155  (
156  word(vf.name() + "BlendingFactor")
157  );
158 
159  return
160  blendingFactor*tScheme1_().weights(vf)
161  + (scalar(1) - blendingFactor)*tScheme2_().weights(vf);
162  }
163 
164  //- Return the face-interpolate of the given cell field
165  // with explicit correction
168  {
170  (
171  this->mesh().objectRegistry::template
172  lookupObject<const surfaceScalarField>
173  (
174  word(vf.name() + "BlendingFactor")
175  )
176  );
177 
178  return
179  blendingFactor*tScheme1_().interpolate(vf)
180  + (scalar(1) - blendingFactor)*tScheme2_().interpolate(vf);
181  }
182 
183 
184  //- Return true if this scheme uses an explicit correction
185  virtual bool corrected() const
186  {
187  return tScheme1_().corrected() || tScheme2_().corrected();
188  }
189 
190 
191  //- Return the explicit correction to the face-interpolate
192  // for the given field
195  (
197  ) const
198  {
200  this->mesh().objectRegistry::template
201  lookupObject<const surfaceScalarField>
202  (
203  word(vf.name() + "BlendingFactor")
204  );
205 
206  if (tScheme1_().corrected())
207  {
208  if (tScheme2_().corrected())
209  {
210  return
211  (
213  * tScheme1_().correction(vf)
214  + (scalar(1) - blendingFactor)
215  * tScheme2_().correction(vf)
216  );
217  }
218  else
219  {
220  return
221  (
223  * tScheme1_().correction(vf)
224  );
225  }
226  }
227  else if (tScheme2_().corrected())
228  {
229  return
230  (
231  (scalar(1) - blendingFactor)
232  * tScheme2_().correction(vf)
233  );
234  }
235  else
236  {
238  (
239  nullptr
240  );
241  }
242  }
243 };
244 
245 
246 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
247 
248 } // End namespace Foam
249 
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
251 
252 #endif
253 
254 // ************************************************************************* //
Foam::surfaceInterpolationScheme::New
static tmp< surfaceInterpolationScheme< Type > > New(const fvMesh &mesh, Istream &schemeData)
Return new tmp interpolation scheme.
Definition: surfaceInterpolationScheme.C:40
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
blendedSchemeBase.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::localBlended::interpolate
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:166
Foam::localBlended::TypeName
TypeName("localBlended")
Runtime type information.
Foam::localBlended
Two-scheme localBlended differencing scheme.
Definition: localBlended.H:56
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::localBlended::blendingFactor
virtual tmp< surfaceScalarField > blendingFactor(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the face-based blending factor.
Definition: localBlended.H:133
Foam::localBlended::~localBlended
virtual ~localBlended()=default
Destructor.
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::localBlended::corrected
virtual bool corrected() const
Return true if this scheme uses an explicit correction.
Definition: localBlended.H:184
Foam::surfaceInterpolationScheme
Abstract base class for surface interpolation schemes.
Definition: surfaceInterpolationScheme.H:57
Foam::surfaceInterpolationScheme::mesh
const fvMesh & mesh() const
Return mesh reference.
Definition: surfaceInterpolationScheme.H:144
Foam::localBlended::weights
tmp< surfaceScalarField > weights(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the interpolation weighting factors.
Definition: localBlended.H:147
Foam::localBlended::correction
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:194
Foam::GeometricField< scalar, fvsPatchField, surfaceMesh >
Foam::blendedSchemeBase
Base class for blended schemes to provide access to the blending factor surface field.
Definition: blendedSchemeBase.H:55
surfaceInterpolationScheme.H