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