surfaceInterpolate.C
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-2012 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 \*---------------------------------------------------------------------------*/
25 
26 #include "surfaceInterpolate.H"
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace fvc
36 {
37 
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 
40 // Return weighting factors for scheme given by name in dictionary
41 template<class Type>
42 tmp<surfaceInterpolationScheme<Type> > scheme
43 (
44  const surfaceScalarField& faceFlux,
45  Istream& streamData
46 )
47 {
49  (
50  faceFlux.mesh(),
51  faceFlux,
52  streamData
53  );
54 }
55 
56 
57 // Return weighting factors for scheme given by name in dictionary
58 template<class Type>
60 (
61  const surfaceScalarField& faceFlux,
62  const word& name
63 )
64 {
66  (
67  faceFlux.mesh(),
68  faceFlux,
69  faceFlux.mesh().interpolationScheme(name)
70  );
71 }
72 
73 
74 // Return weighting factors for scheme given by name in dictionary
75 template<class Type>
77 (
78  const fvMesh& mesh,
79  Istream& streamData
80 )
81 {
83  (
84  mesh,
85  streamData
86  );
87 }
88 
89 
90 // Return weighting factors for scheme given by name in dictionary
91 template<class Type>
93 (
94  const fvMesh& mesh,
95  const word& name
96 )
97 {
99  (
100  mesh,
101  mesh.interpolationScheme(name)
102  );
103 }
104 
105 
106 // Interpolate field onto faces using scheme given by name in dictionary
107 template<class Type>
110 (
112  const surfaceScalarField& faceFlux,
113  Istream& schemeData
114 )
115 {
116  if (surfaceInterpolation::debug)
117  {
118  Info<< "interpolate"
119  << "(const GeometricField<Type, fvPatchField, volMesh>&, "
120  << "const surfaceScalarField&, Istream&) : "
121  << "interpolating GeometricField<Type, fvPatchField, volMesh> "
122  << endl;
123  }
124 
125  return scheme<Type>(faceFlux, schemeData)().interpolate(vf);
126 }
127 
128 
129 // Interpolate field onto faces using scheme given by name in dictionary
130 template<class Type>
133 (
135  const surfaceScalarField& faceFlux,
136  const word& name
137 )
138 {
139  if (surfaceInterpolation::debug)
140  {
141  Info<< "interpolate"
142  << "(const GeometricField<Type, fvPatchField, volMesh>&, "
143  << "const surfaceScalarField&, const word&) : "
144  << "interpolating GeometricField<Type, fvPatchField, volMesh> "
145  << "using " << name
146  << endl;
147  }
148 
149  return scheme<Type>(faceFlux, name)().interpolate(vf);
150 }
151 
152 // Interpolate field onto faces using scheme given by name in dictionary
153 template<class Type>
156 (
158  const surfaceScalarField& faceFlux,
159  const word& name
160 )
161 {
163  interpolate(tvf(), faceFlux, name);
164 
165  tvf.clear();
166 
167  return tsf;
168 }
169 
170 // Interpolate field onto faces using scheme given by name in dictionary
171 template<class Type>
174 (
176  const tmp<surfaceScalarField>& tFaceFlux,
177  const word& name
178 )
179 {
181  interpolate(vf, tFaceFlux(), name);
182 
183  tFaceFlux.clear();
184 
185  return tsf;
186 }
187 
188 // Interpolate field onto faces using scheme given by name in dictionary
189 template<class Type>
192 (
194  const tmp<surfaceScalarField>& tFaceFlux,
195  const word& name
196 )
197 {
199  interpolate(tvf(), tFaceFlux(), name);
200 
201  tvf.clear();
202  tFaceFlux.clear();
203 
204  return tsf;
205 }
206 
207 
208 // Interpolate field onto faces using scheme given by name in dictionary
209 template<class Type>
212 (
214  Istream& schemeData
215 )
216 {
217  if (surfaceInterpolation::debug)
218  {
219  Info<< "interpolate"
220  << "(const GeometricField<Type, fvPatchField, volMesh>&, "
221  << "Istream&) : "
222  << "interpolating GeometricField<Type, fvPatchField, volMesh> "
223  << endl;
224  }
225 
226  return scheme<Type>(vf.mesh(), schemeData)().interpolate(vf);
227 }
228 
229 // Interpolate field onto faces using scheme given by name in dictionary
230 template<class Type>
233 (
235  const word& name
236 )
237 {
238  if (surfaceInterpolation::debug)
239  {
240  Info<< "interpolate"
241  << "(const GeometricField<Type, fvPatchField, volMesh>&, "
242  << "const word&) : "
243  << "interpolating GeometricField<Type, fvPatchField, volMesh> "
244  << "using " << name
245  << endl;
246  }
247 
248  return scheme<Type>(vf.mesh(), name)().interpolate(vf);
249 }
250 
251 // Interpolate field onto faces using scheme given by name in dictionary
252 template<class Type>
255 (
257  const word& name
258 )
259 {
261  interpolate(tvf(), name);
262 
263  tvf.clear();
264 
265  return tsf;
266 }
267 
268 
269 // Interpolate field onto faces using central differencing
270 template<class Type>
273 (
275 )
276 {
277  if (surfaceInterpolation::debug)
278  {
279  Info<< "interpolate"
280  << "(const GeometricField<Type, fvPatchField, volMesh>&) : "
281  << "interpolating GeometricField<Type, fvPatchField, volMesh> "
282  << "using run-time selected scheme"
283  << endl;
284  }
285 
286  return interpolate(vf, "interpolate(" + vf.name() + ')');
287 }
288 
289 
290 // Interpolate field onto faces using central differencing
291 template<class Type>
294 (
296 )
297 {
299  interpolate(tvf());
300  tvf.clear();
301  return tsf;
302 }
303 
304 
305 template<class Type>
307 (
308  const FieldField<fvPatchField, Type>& fvpff
309 )
310 {
312  (
314  );
315 
316  forAll(*fvspffPtr, patchi)
317  {
318  fvspffPtr->set
319  (
320  patchi,
321  fvsPatchField<Type>::NewCalculatedType(fvpff[patchi].patch()).ptr()
322  );
323  (*fvspffPtr)[patchi] = fvpff[patchi];
324  }
325 
326  return tmp<FieldField<fvsPatchField, Type> >(fvspffPtr);
327 }
328 
329 
330 template<class Type>
332 (
333  const tmp<FieldField<fvPatchField, Type> >& tfvpff
334 )
335 {
336  tmp<FieldField<fvsPatchField, Type> > tfvspff = interpolate(tfvpff());
337  tfvpff.clear();
338  return tfvspff;
339 }
340 
341 
342 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
343 
344 } // End namespace fvc
345 
346 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
347 
348 } // End namespace Foam
349 
350 // ************************************************************************* //
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &vf, const surfaceScalarField &faceFlux, Istream &schemeData)
static tmp< surfaceInterpolationScheme< Type > > New(const fvMesh &mesh, Istream &schemeData)
Return new tmp interpolation scheme.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
label size() const
Return the number of elements in the PtrList.
Generic field type.
Definition: FieldField.H:51
bool set(const label) const
Is element set.
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
void clear() const
If object pointer points to valid object:
Definition: tmpI.H:174
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
A class for handling words, derived from string.
Definition: word.H:59
Surface Interpolation.
messageStream Info
const Mesh & mesh() const
Return mesh.
ITstream & interpolationScheme(const word &name) const
Definition: fvSchemes.C:398
Namespace for OpenFOAM.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
#define forAll(list, i)
Definition: UList.H:421
label patchi
const word & name() const
Return name.
Definition: IOobject.H:260
A class for managing temporary objects.
Definition: PtrList.H:118
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:65
tmp< surfaceInterpolationScheme< Type > > scheme(const surfaceScalarField &faceFlux, Istream &streamData)