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