FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 /*---------------------------------------------------------------------------*\
46  Class localBlended Declaration
47 \*---------------------------------------------------------------------------*/
48 
49 template<class Type>
51 :
52  public surfaceInterpolationScheme<Type>
53 {
54  // Private Member Functions
55 
56  //- Scheme 1
58 
59  //- Scheme 2
61 
62 
63  //- Disallow default bitwise copy construct
64  localBlended(const localBlended&);
65 
66  //- Disallow default bitwise assignment
67  void operator=(const localBlended&);
68 
69 
70 public:
71 
72  //- Runtime type information
73  TypeName("localBlended");
74 
75 
76  // Constructors
77 
78  //- Construct from mesh and Istream.
79  // The name of the flux field is read from the Istream and looked-up
80  // from the mesh objectRegistry
82  (
83  const fvMesh& mesh,
84  Istream& is
85  )
86  :
88  tScheme1_
89  (
91  ),
92  tScheme2_
93  (
95  )
96  {}
97 
98  //- Construct from mesh, faceFlux and Istream
100  (
101  const fvMesh& mesh,
102  const surfaceScalarField& faceFlux,
103  Istream& is
104  )
105  :
107  tScheme1_
108  (
109  surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
110  ),
111  tScheme2_
112  (
113  surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
114  )
115  {}
116 
117 
118  // Member Functions
119 
120  //- Return the interpolation weighting factors
122  (
124  ) const
125  {
126  const surfaceScalarField& blendingFactor =
127  this->mesh().objectRegistry:: lookupObject<const surfaceScalarField>
128  (
129  word(vf.name() + "BlendingFactor")
130  );
131 
132  return
133  blendingFactor*tScheme1_().weights(vf)
134  + (scalar(1) - blendingFactor)*tScheme2_().weights(vf);
135  }
136 
137  //- Return the face-interpolate of the given cell field
138  // with explicit correction
141  {
142  const surfaceScalarField& blendingFactor =
143  (
144  this->mesh().objectRegistry:: lookupObject<const surfaceScalarField>
145  (
146  word(vf.name() + "BlendingFactor")
147  )
148  );
149 
150  return
151  blendingFactor*tScheme1_().interpolate(vf)
152  + (scalar(1) - blendingFactor)*tScheme2_().interpolate(vf);
153  }
154 
155 
156  //- Return true if this scheme uses an explicit correction
157  virtual bool corrected() const
158  {
159  return tScheme1_().corrected() || tScheme2_().corrected();
160  }
161 
162 
163  //- Return the explicit correction to the face-interpolate
164  // for the given field
166  correction
167  (
169  ) const
170  {
171  const surfaceScalarField& blendingFactor =
172  this->mesh().objectRegistry:: lookupObject<const surfaceScalarField>
173  (
174  word(vf.name() + "BlendingFactor")
175  );
176 
177  if (tScheme1_().corrected())
178  {
179  if (tScheme2_().corrected())
180  {
181  return
182  (
183  blendingFactor
184  * tScheme1_().correction(vf)
185  + (scalar(1.0) - blendingFactor)
186  * tScheme2_().correction(vf)
187  );
188  }
189  else
190  {
191  return
192  (
193  blendingFactor
194  * tScheme1_().correction(vf)
195  );
196  }
197  }
198  else if (tScheme2_().corrected())
199  {
200  return
201  (
202  (scalar(1.0) - blendingFactor)
203  * tScheme2_().correction(vf)
204  );
205  }
206  else
207  {
209  (
210  NULL
211  );
212  }
213  }
214 };
215 
216 
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 
219 } // End namespace Foam
220 
221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
222 
223 #endif
224 
225 // ************************ vim: set sw=4 sts=4 et: ************************ //
226