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