surfaceInterpolate.C
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-2022 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 template<class Type>
33 (
34  const surfaceScalarField& faceFlux,
35  Istream& streamData
36 )
37 {
39  (
40  faceFlux.mesh(),
41  faceFlux,
42  streamData
43  );
44 }
45 
46 
47 template<class Type>
49 (
50  const surfaceScalarField& faceFlux,
51  const word& name
52 )
53 {
55  (
56  faceFlux.mesh(),
57  faceFlux,
58  faceFlux.mesh().schemes().interpolation(name)
59  );
60 }
61 
62 
63 template<class Type>
65 (
66  const fvMesh& mesh,
67  Istream& streamData
68 )
69 {
71  (
72  mesh,
73  streamData
74  );
75 }
76 
77 
78 template<class Type>
80 (
81  const fvMesh& mesh,
82  const word& name
83 )
84 {
86  (
87  mesh,
88  mesh.schemes().interpolation(name)
89  );
90 }
91 
92 
93 template<class Type>
96 (
97  const VolField<Type>& vf,
98  const surfaceScalarField& faceFlux,
99  Istream& schemeData
100 )
101 {
102  if (surfaceInterpolation::debug)
103  {
105  << "interpolating VolField<Type> "
106  << vf.name() << endl;
107  }
108 
109  return scheme<Type>(faceFlux, schemeData)().interpolate(vf);
110 }
111 
112 
113 template<class Type>
116 (
117  const VolField<Type>& vf,
118  const surfaceScalarField& faceFlux,
119  const word& name
120 )
121 {
122  if (surfaceInterpolation::debug)
123  {
125  << "interpolating VolField<Type> "
126  << vf.name() << " using " << name << endl;
127  }
128 
129  return scheme<Type>(faceFlux, name)().interpolate(vf);
130 }
131 
132 template<class Type>
135 (
136  const tmp<VolField<Type>>& tvf,
137  const surfaceScalarField& faceFlux,
138  const word& name
139 )
140 {
141  tmp<SurfaceField<Type>> tsf =
142  interpolate(tvf(), faceFlux, name);
143 
144  tvf.clear();
145 
146  return tsf;
147 }
148 
149 template<class Type>
152 (
153  const VolField<Type>& vf,
154  const tmp<surfaceScalarField>& tFaceFlux,
155  const word& name
156 )
157 {
158  tmp<SurfaceField<Type>> tsf =
159  interpolate(vf, tFaceFlux(), name);
160 
161  tFaceFlux.clear();
162 
163  return tsf;
164 }
165 
166 template<class Type>
169 (
170  const tmp<VolField<Type>>& tvf,
171  const tmp<surfaceScalarField>& tFaceFlux,
172  const word& name
173 )
174 {
175  tmp<SurfaceField<Type>> tsf =
176  interpolate(tvf(), tFaceFlux(), name);
177 
178  tvf.clear();
179  tFaceFlux.clear();
180 
181  return tsf;
182 }
183 
184 
185 template<class Type>
188 (
189  const VolField<Type>& vf,
190  Istream& schemeData
191 )
192 {
193  if (surfaceInterpolation::debug)
194  {
196  << "interpolating VolField<Type> "
197  << vf.name() << endl;
198  }
199 
200  return scheme<Type>(vf.mesh(), schemeData)().interpolate(vf);
201 }
202 
203 template<class Type>
206 (
207  const VolField<Type>& vf,
208  const word& name
209 )
210 {
211  if (surfaceInterpolation::debug)
212  {
214  << "interpolating VolField<Type> "
215  << vf.name() << " using " << name
216  << endl;
217  }
218 
219  return scheme<Type>(vf.mesh(), name)().interpolate(vf);
220 }
221 
222 template<class Type>
225 (
226  const tmp<VolField<Type>>& tvf,
227  const word& name
228 )
229 {
230  tmp<SurfaceField<Type>> tsf =
231  interpolate(tvf(), name);
232 
233  tvf.clear();
234 
235  return tsf;
236 }
237 
238 
239 template<class Type>
242 (
243  const VolField<Type>& vf
244 )
245 {
246  if (surfaceInterpolation::debug)
247  {
249  << "interpolating VolField<Type> "
250  << vf.name() << " using run-time selected scheme"
251  << endl;
252  }
253 
254  return interpolate(vf, "interpolate(" + vf.name() + ')');
255 }
256 
257 
258 template<class Type>
261 (
262  const tmp<VolField<Type>>& tvf
263 )
264 {
265  tmp<SurfaceField<Type>> tsf =
266  interpolate(tvf());
267  tvf.clear();
268  return tsf;
269 }
270 
271 
272 template<class Type>
275 (
276  const FieldField<fvPatchField, Type>& fvpff
277 )
278 {
279  FieldField<fvsPatchField, Type>* fvspffPtr
280  (
281  new FieldField<fvsPatchField, Type>(fvpff.size())
282  );
283 
284  forAll(*fvspffPtr, patchi)
285  {
286  fvspffPtr->set
287  (
288  patchi,
289  fvsPatchField<Type>::NewCalculatedType(fvpff[patchi].patch()).ptr()
290  );
291  (*fvspffPtr)[patchi] = fvpff[patchi];
292  }
293 
294  return tmp<FieldField<fvsPatchField, Type>>(fvspffPtr);
295 }
296 
297 
298 template<class Type>
301 (
302  const tmp<FieldField<fvPatchField, Type>>& tfvpff
303 )
304 {
305  tmp<FieldField<fvsPatchField, Type>> tfvspff = interpolate(tfvpff());
306  tfvpff.clear();
307  return tfvspff;
308 }
309 
310 
311 template<class Type>
312 Foam::tmp
313 <
315 >
317 (
318  const surfaceVectorField& Sf,
319  const VolField<Type>& vf
320 )
321 {
322  if (surfaceInterpolation::debug)
323  {
325  << "interpolating VolField<Type> "
326  << vf.name() << " using run-time selected scheme"
327  << endl;
328  }
329 
330  return scheme<Type>
331  (
332  vf.mesh(),
333  "dotInterpolate(" + Sf.name() + ',' + vf.name() + ')'
334  )().dotInterpolate(Sf, vf);
335 }
336 
337 
338 template<class Type>
339 Foam::tmp
340 <
342 >
344 (
345  const surfaceVectorField& Sf,
346  const tmp<VolField<Type>>& tvf
347 )
348 {
350  (
351  dotInterpolate(Sf, tvf())
352  );
353  tvf.clear();
354  return tsf;
355 }
356 
357 
358 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Generic GeometricField class.
A class for managing temporary objects.
Definition: tmp.H:55
label patchi
#define InfoInFunction
Report an information message using Foam::Info.
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
static tmp< surfaceInterpolationScheme< Type > > scheme(const surfaceScalarField &faceFlux, Istream &schemeData)
Return weighting factors for scheme given from Istream.
static tmp< SurfaceField< Type > > interpolate(const VolField< Type > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
static tmp< SurfaceField< typename innerProduct< vector, Type >::type > > dotInterpolate(const surfaceVectorField &Sf, const VolField< Type > &tvf)
Interpolate field onto faces.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
SurfaceField< scalar > surfaceScalarField
SurfaceField< vector > surfaceVectorField
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488