GeometricFieldFunctions.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) 2018-2019 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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\*---------------------------------------------------------------------------*/
28
30
31#define TEMPLATE \
32 template<class Type, template<class> class PatchField, class GeoMesh>
34
35// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36
37namespace Foam
38{
39
40// * * * * * * * * * * * * * * * Global functions * * * * * * * * * * * * * //
41
42template<class Type, template<class> class PatchField, class GeoMesh>
43void component
44(
45 GeometricField
46 <
48 PatchField,
49 GeoMesh
50 >& gcf,
51 const GeometricField<Type, PatchField, GeoMesh>& gf,
52 const direction d
53);
54
55template<class Type, template<class> class PatchField, class GeoMesh>
56void T
57(
58 GeometricField<Type, PatchField, GeoMesh>& gf,
59 const GeometricField<Type, PatchField, GeoMesh>& gf1
60);
61
62template
63<
64 class Type,
65 template<class> class PatchField,
66 class GeoMesh,
67 direction r
68>
69void pow
70(
71 GeometricField<typename powProduct<Type, r>::type, PatchField, GeoMesh>& gf,
72 const GeometricField<Type, PatchField, GeoMesh>& gf1
73);
74
75template
76<
77 class Type,
78 template<class> class PatchField,
79 class GeoMesh,
80 direction r
81>
82tmp
83<
84 GeometricField
85 <typename powProduct<Type, r>::type, PatchField, GeoMesh>
86>
87pow
88(
89 const GeometricField<Type, PatchField, GeoMesh>& gf,
91);
92
93template
94<
95 class Type,
96 template<class> class PatchField,
97 class GeoMesh,
98 direction r
99>
100tmp
101<
102 GeometricField
103 <typename powProduct<Type, r>::type, PatchField, GeoMesh>
104>
105pow
106(
107 const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf,
109);
110
111template<class Type, template<class> class PatchField, class GeoMesh>
112void sqr
113(
114 GeometricField
115 <typename outerProduct<Type, Type>::type, PatchField, GeoMesh>& gf,
116 const GeometricField<Type, PatchField, GeoMesh>& gf1
117);
118
119template<class Type, template<class> class PatchField, class GeoMesh>
120tmp
121<
122 GeometricField
123 <
125 PatchField,
126 GeoMesh
127 >
128>
129sqr(const GeometricField<Type, PatchField, GeoMesh>& gf);
130
131template<class Type, template<class> class PatchField, class GeoMesh>
132tmp
133<
134 GeometricField
135 <
137 PatchField,
138 GeoMesh
139 >
140>
141sqr(const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf);
142
143template<class Type, template<class> class PatchField, class GeoMesh>
144void magSqr
145(
146 GeometricField<typename typeOfMag<Type>::type, PatchField, GeoMesh>& gsf,
147 const GeometricField<Type, PatchField, GeoMesh>& gf
148);
149
150template<class Type, template<class> class PatchField, class GeoMesh>
151tmp<GeometricField<typename typeOfMag<Type>::type, PatchField, GeoMesh>>
152magSqr
153(
154 const GeometricField<Type, PatchField, GeoMesh>& gf
155);
156
157template<class Type, template<class> class PatchField, class GeoMesh>
158tmp<GeometricField<typename typeOfMag<Type>::type, PatchField, GeoMesh>>
159magSqr
160(
161 const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf
162);
163
164template<class Type, template<class> class PatchField, class GeoMesh>
165void mag
166(
167 GeometricField<typename typeOfMag<Type>::type, PatchField, GeoMesh>& gsf,
168 const GeometricField<Type, PatchField, GeoMesh>& gf
169);
170
171template<class Type, template<class> class PatchField, class GeoMesh>
172tmp<GeometricField<typename typeOfMag<Type>::type, PatchField, GeoMesh>>
173mag
174(
175 const GeometricField<Type, PatchField, GeoMesh>& gf
176);
177
178template<class Type, template<class> class PatchField, class GeoMesh>
179tmp<GeometricField<typename typeOfMag<Type>::type, PatchField, GeoMesh>>
180mag
181(
182 const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf
183);
184
185template<class Type, template<class> class PatchField, class GeoMesh>
186void cmptAv
187(
188 GeometricField
189 <
191 PatchField,
192 GeoMesh
193 >& gcf,
194 const GeometricField<Type, PatchField, GeoMesh>& gf
195);
196
197template<class Type, template<class> class PatchField, class GeoMesh>
198tmp
199<
200 GeometricField
201 <
203 PatchField,
204 GeoMesh
205 >
206>
207cmptAv(const GeometricField<Type, PatchField, GeoMesh>& gf);
208
209template<class Type, template<class> class PatchField, class GeoMesh>
210tmp
211<
212 GeometricField
213 <
215 PatchField,
216 GeoMesh
217 >
218>
219cmptAv(const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf);
220
221
222#define UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(returnType, func, binaryOp) \
223 \
224template<class Type, template<class> class PatchField, class GeoMesh> \
225dimensioned<returnType> func \
226( \
227 const GeometricField<Type, PatchField, GeoMesh>& gf \
228); \
229 \
230template<class Type, template<class> class PatchField, class GeoMesh> \
231dimensioned<returnType> func \
232( \
233 const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf1 \
234);
235
238UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(MinMax<Type>, minMax, minMaxOp)
240
241#undef UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY
242
243
244#define UNARY_REDUCTION_FUNCTION(returnType, func, gFunc) \
245 \
246template<class Type, template<class> class PatchField, class GeoMesh> \
247dimensioned<returnType> func \
248( \
249 const GeometricField<Type, PatchField, GeoMesh>& gf \
250); \
251 \
252template<class Type, template<class> class PatchField, class GeoMesh> \
253dimensioned<returnType> func \
254( \
255 const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf1 \
256);
257
261
262#undef UNARY_REDUCTION_FUNCTION
263
264
265BINARY_FUNCTION(Type, Type, Type, max)
266BINARY_FUNCTION(Type, Type, Type, min)
268BINARY_FUNCTION(Type, Type, Type, cmptDivide)
269
270BINARY_TYPE_FUNCTION(Type, Type, Type, max)
271BINARY_TYPE_FUNCTION(Type, Type, Type, min)
274
275
276// * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * //
277
279
280BINARY_OPERATOR(Type, Type, scalar, *, '*', multiply)
281BINARY_OPERATOR(Type, scalar, Type, *, '*', multiply)
282BINARY_OPERATOR(Type, Type, scalar, /, '|', divide)
283
284BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, '*', multiply)
285BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, '*', multiply)
286
287BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, '|', divide)
288
289
290// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
291
292#define PRODUCT_OPERATOR(product, op, opFunc) \
293 \
294template \
295<class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
296void opFunc \
297( \
298 GeometricField \
299 <typename product<Type1, Type2>::type, PatchField, GeoMesh>& gf, \
300 const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
301 const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
302); \
303 \
304template \
305<class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
306tmp \
307< \
308 GeometricField \
309 <typename product<Type1, Type2>::type, PatchField, GeoMesh> \
310> \
311operator op \
312( \
313 const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
314 const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
315); \
316 \
317template \
318<class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
319tmp \
320< \
321 GeometricField \
322 <typename product<Type1, Type2>::type, PatchField, GeoMesh> \
323> \
324operator op \
325( \
326 const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
327 const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tgf2 \
328); \
329 \
330template \
331<class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
332tmp \
333< \
334 GeometricField \
335 <typename product<Type1, Type2>::type, PatchField, GeoMesh> \
336> \
337operator op \
338( \
339 const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tgf1, \
340 const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
341); \
342 \
343template \
344<class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
345tmp \
346< \
347 GeometricField \
348 <typename product<Type1, Type2>::type, PatchField, GeoMesh> \
349> \
350operator op \
351( \
352 const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tgf1, \
353 const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tgf2 \
354); \
355 \
356template \
357<class Form, class Type, template<class> class PatchField, class GeoMesh> \
358void opFunc \
359( \
360 GeometricField \
361 <typename product<Type, Form>::type, PatchField, GeoMesh>& gf, \
362 const GeometricField<Type, PatchField, GeoMesh>& gf1, \
363 const dimensioned<Form>& dvs \
364); \
365 \
366template \
367<class Form, class Type, template<class> class PatchField, class GeoMesh> \
368tmp \
369< \
370 GeometricField \
371 <typename product<Type, Form>::type, PatchField, GeoMesh> \
372> \
373operator op \
374( \
375 const GeometricField<Type, PatchField, GeoMesh>& gf1, \
376 const dimensioned<Form>& dvs \
377); \
378 \
379template \
380< \
381 class Form, \
382 class Cmpt, \
383 direction nCmpt, \
384 class Type, template<class> class PatchField, \
385 class GeoMesh \
386> \
387tmp \
388< \
389 GeometricField \
390 <typename product<Form, Type>::type, PatchField, GeoMesh> \
391> \
392operator op \
393( \
394 const GeometricField<Type, PatchField, GeoMesh>& gf1, \
395 const VectorSpace<Form,Cmpt,nCmpt>& vs \
396); \
397 \
398template \
399<class Form, class Type, template<class> class PatchField, class GeoMesh> \
400tmp \
401< \
402 GeometricField \
403 <typename product<Type, Form>::type, PatchField, GeoMesh> \
404> \
405operator op \
406( \
407 const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf1, \
408 const dimensioned<Form>& dvs \
409); \
410 \
411template \
412< \
413 class Form, \
414 class Cmpt, \
415 direction nCmpt, \
416 class Type, template<class> class PatchField, \
417 class GeoMesh \
418> \
419tmp \
420< \
421 GeometricField \
422 <typename product<Form, Type>::type, PatchField, GeoMesh> \
423> \
424operator op \
425( \
426 const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf1, \
427 const VectorSpace<Form,Cmpt,nCmpt>& vs \
428); \
429 \
430template \
431<class Form, class Type, template<class> class PatchField, class GeoMesh> \
432void opFunc \
433( \
434 GeometricField \
435 <typename product<Form, Type>::type, PatchField, GeoMesh>& gf, \
436 const dimensioned<Form>& dvs, \
437 const GeometricField<Type, PatchField, GeoMesh>& gf1 \
438); \
439 \
440template \
441<class Form, class Type, template<class> class PatchField, class GeoMesh> \
442tmp \
443< \
444 GeometricField \
445 <typename product<Form, Type>::type, PatchField, GeoMesh> \
446> \
447operator op \
448( \
449 const dimensioned<Form>& dvs, \
450 const GeometricField<Type, PatchField, GeoMesh>& gf1 \
451); \
452 \
453template \
454< \
455 class Form, \
456 class Cmpt, \
457 direction nCmpt, \
458 class Type, template<class> class PatchField, \
459 class GeoMesh \
460> \
461tmp \
462< \
463 GeometricField \
464 <typename product<Form, Type>::type, PatchField, GeoMesh> \
465> \
466operator op \
467( \
468 const VectorSpace<Form,Cmpt,nCmpt>& vs, \
469 const GeometricField<Type, PatchField, GeoMesh>& gf1 \
470); \
471 \
472template \
473<class Form, class Type, template<class> class PatchField, class GeoMesh> \
474tmp \
475< \
476 GeometricField \
477 <typename product<Form, Type>::type, PatchField, GeoMesh> \
478> \
479operator op \
480( \
481 const dimensioned<Form>& dvs, \
482 const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf1 \
483); \
484 \
485template \
486< \
487 class Form, \
488 class Cmpt, \
489 direction nCmpt, \
490 class Type, template<class> class PatchField, \
491 class GeoMesh \
492> \
493tmp \
494< \
495 GeometricField \
496 <typename product<Form, Type>::type, PatchField, GeoMesh> \
497> \
498operator op \
499( \
500 const VectorSpace<Form,Cmpt,nCmpt>& vs, \
501 const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf1 \
502);
503
504PRODUCT_OPERATOR(typeOfSum, +, add)
505PRODUCT_OPERATOR(typeOfSum, -, subtract)
506
507PRODUCT_OPERATOR(outerProduct, *, outer)
508PRODUCT_OPERATOR(crossProduct, ^, cross)
509PRODUCT_OPERATOR(innerProduct, &, dot)
510PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
511
512#undef PRODUCT_OPERATOR
513
514
515// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
516
517} // End namespace Foam
518
519// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
520
521#include "undefFieldFunctionsM.H"
522
523// ************************************************************************* //
#define BINARY_FUNCTION(ReturnType, Type1, Type2, Func)
#define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc, Dfunc)
#define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)
#define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc)
#define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpName, OpFunc)
#define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func)
#define UNARY_REDUCTION_FUNCTION(returnType, func, dfunc)
#define UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(returnType, func, binaryOp)
Scalar specific part of the implementation of GeometricField.
Field< Type >::cmptType cmptType
The field component type.
typeOfRank< typenamepTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank)>::type type
Definition: products.H:114
symmTypeOfRank< typenamepTraits< arg1 >::cmptType, arg2 *direction(pTraits< arg1 >::rank)>::type type
Definition: products.H:170
pTraits< typenamepTraits< arg1 >::cmptType >::magType type
Definition: products.H:92
const volScalarField & T
#define PRODUCT_OPERATOR(product, op, opFunc)
Namespace for OpenFOAM.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Type gSum(const FieldField< Field, Type > &f)
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:536
dimensionedSymmTensor sqr(const dimensionedVector &dv)
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
void subtract(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
MinMax< scalar > scalarMinMax
A scalar min/max range.
Definition: MinMax.H:117
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
void dot(FieldField< Field1, typename innerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
MinMax< label > minMax(const labelHashSet &set)
Find the min/max values of labelHashSet.
Definition: hashSets.C:61
dimensioned< typename typeOfMag< Type >::type > sumMag(const DimensionedField< Type, GeoMesh > &df)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
void negate(FieldField< Field, Type > &res, const FieldField< Field, Type > &f)
void multiply(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
uint8_t direction
Definition: direction.H:56
Type gAverage(const FieldField< Field, Type > &f)
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
typeOfMag< Type >::type gSumMag(const FieldField< Field, Type > &f)
void dotdot(FieldField< Field1, typename scalarProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
void cross(FieldField< Field1, typename crossProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
tmp< DimensionedField< typename DimensionedField< Type, GeoMesh >::cmptType, GeoMesh > > cmptAv(const DimensionedField< Type, GeoMesh > &df)
dimensioned< scalarMinMax > minMaxMag(const DimensionedField< Type, GeoMesh > &df)
void divide(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
void outer(FieldField< Field1, typename outerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)