All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2018 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  <
44  typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
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,
87  typename powProduct<Type, r>::type
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,
105  typename powProduct<Type, r>::type
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  <
121  typename outerProduct<Type, Type>::type,
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  <
133  typename outerProduct<Type, Type>::type,
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  <
183  typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
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  <
195  typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
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  <
207  typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
208  PatchField,
209  GeoMesh
210  >
211 >
212 cmptAv(const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf);
213 
214 
215 #define UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(returnType, func, gFunc) \
216  \
217 template<class Type, template<class> class PatchField, class GeoMesh> \
218 dimensioned<returnType> func \
219 ( \
220  const GeometricField<Type, PatchField, GeoMesh>& gf \
221 ); \
222  \
223 template<class Type, template<class> class PatchField, class GeoMesh> \
224 dimensioned<returnType> func \
225 ( \
226  const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf1 \
227 );
228 
231 
232 #undef UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY
233 
234 
235 #define UNARY_REDUCTION_FUNCTION(returnType, func, gFunc) \
236  \
237 template<class Type, template<class> class PatchField, class GeoMesh> \
238 dimensioned<returnType> func \
239 ( \
240  const GeometricField<Type, PatchField, GeoMesh>& gf \
241 ); \
242  \
243 template<class Type, template<class> class PatchField, class GeoMesh> \
244 dimensioned<returnType> func \
245 ( \
246  const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf1 \
247 );
248 
252 
253 #undef UNARY_REDUCTION_FUNCTION
254 
255 
256 BINARY_FUNCTION(Type, Type, Type, max)
257 BINARY_FUNCTION(Type, Type, Type, min)
258 BINARY_FUNCTION(Type, Type, Type, cmptMultiply)
259 BINARY_FUNCTION(Type, Type, Type, cmptDivide)
260 
261 BINARY_TYPE_FUNCTION(Type, Type, Type, max)
262 BINARY_TYPE_FUNCTION(Type, Type, Type, min)
263 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
264 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
265 
266 
267 // * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * //
268 
269 UNARY_OPERATOR(Type, Type, -, negate, transform)
270 
271 BINARY_OPERATOR(Type, Type, scalar, *, '*', multiply)
272 BINARY_OPERATOR(Type, scalar, Type, *, '*', multiply)
273 BINARY_OPERATOR(Type, Type, scalar, /, '|', divide)
274 
275 BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, '*', multiply)
276 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, '*', multiply)
277 
278 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, '|', divide)
279 
280 
281 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
282 
283 #define PRODUCT_OPERATOR(product, op, opFunc) \
284  \
285 template \
286 <class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
287 void opFunc \
288 ( \
289  GeometricField \
290  <typename product<Type1, Type2>::type, PatchField, GeoMesh>& gf, \
291  const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
292  const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
293 ); \
294  \
295 template \
296 <class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
297 tmp \
298 < \
299  GeometricField \
300  <typename product<Type1, Type2>::type, PatchField, GeoMesh> \
301 > \
302 operator op \
303 ( \
304  const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
305  const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
306 ); \
307  \
308 template \
309 <class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
310 tmp \
311 < \
312  GeometricField \
313  <typename product<Type1, Type2>::type, PatchField, GeoMesh> \
314 > \
315 operator op \
316 ( \
317  const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
318  const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tgf2 \
319 ); \
320  \
321 template \
322 <class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
323 tmp \
324 < \
325  GeometricField \
326  <typename product<Type1, Type2>::type, PatchField, GeoMesh> \
327 > \
328 operator op \
329 ( \
330  const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tgf1, \
331  const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
332 ); \
333  \
334 template \
335 <class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
336 tmp \
337 < \
338  GeometricField \
339  <typename product<Type1, Type2>::type, PatchField, GeoMesh> \
340 > \
341 operator op \
342 ( \
343  const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tgf1, \
344  const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tgf2 \
345 ); \
346  \
347 template \
348 <class Form, class Type, template<class> class PatchField, class GeoMesh> \
349 void opFunc \
350 ( \
351  GeometricField \
352  <typename product<Type, Form>::type, PatchField, GeoMesh>& gf, \
353  const GeometricField<Type, PatchField, GeoMesh>& gf1, \
354  const dimensioned<Form>& dvs \
355 ); \
356  \
357 template \
358 <class Form, class Type, template<class> class PatchField, class GeoMesh> \
359 tmp \
360 < \
361  GeometricField \
362  <typename product<Type, Form>::type, PatchField, GeoMesh> \
363 > \
364 operator op \
365 ( \
366  const GeometricField<Type, PatchField, GeoMesh>& gf1, \
367  const dimensioned<Form>& dvs \
368 ); \
369  \
370 template \
371 < \
372  class Form, \
373  class Cmpt, \
374  direction nCmpt, \
375  class Type, template<class> class PatchField, \
376  class GeoMesh \
377 > \
378 tmp \
379 < \
380  GeometricField \
381  <typename product<Form, Type>::type, PatchField, GeoMesh> \
382 > \
383 operator op \
384 ( \
385  const GeometricField<Type, PatchField, GeoMesh>& gf1, \
386  const VectorSpace<Form,Cmpt,nCmpt>& vs \
387 ); \
388  \
389 template \
390 <class Form, class Type, template<class> class PatchField, class GeoMesh> \
391 tmp \
392 < \
393  GeometricField \
394  <typename product<Type, Form>::type, PatchField, GeoMesh> \
395 > \
396 operator op \
397 ( \
398  const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf1, \
399  const dimensioned<Form>& dvs \
400 ); \
401  \
402 template \
403 < \
404  class Form, \
405  class Cmpt, \
406  direction nCmpt, \
407  class Type, template<class> class PatchField, \
408  class GeoMesh \
409 > \
410 tmp \
411 < \
412  GeometricField \
413  <typename product<Form, Type>::type, PatchField, GeoMesh> \
414 > \
415 operator op \
416 ( \
417  const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf1, \
418  const VectorSpace<Form,Cmpt,nCmpt>& vs \
419 ); \
420  \
421 template \
422 <class Form, class Type, template<class> class PatchField, class GeoMesh> \
423 void opFunc \
424 ( \
425  GeometricField \
426  <typename product<Form, Type>::type, PatchField, GeoMesh>& gf, \
427  const dimensioned<Form>& dvs, \
428  const GeometricField<Type, PatchField, GeoMesh>& gf1 \
429 ); \
430  \
431 template \
432 <class Form, class Type, template<class> class PatchField, class GeoMesh> \
433 tmp \
434 < \
435  GeometricField \
436  <typename product<Form, Type>::type, PatchField, GeoMesh> \
437 > \
438 operator op \
439 ( \
440  const dimensioned<Form>& dvs, \
441  const GeometricField<Type, PatchField, GeoMesh>& gf1 \
442 ); \
443  \
444 template \
445 < \
446  class Form, \
447  class Cmpt, \
448  direction nCmpt, \
449  class Type, template<class> class PatchField, \
450  class GeoMesh \
451 > \
452 tmp \
453 < \
454  GeometricField \
455  <typename product<Form, Type>::type, PatchField, GeoMesh> \
456 > \
457 operator op \
458 ( \
459  const VectorSpace<Form,Cmpt,nCmpt>& vs, \
460  const GeometricField<Type, PatchField, GeoMesh>& gf1 \
461 ); \
462  \
463 template \
464 <class Form, class Type, template<class> class PatchField, class GeoMesh> \
465 tmp \
466 < \
467  GeometricField \
468  <typename product<Form, Type>::type, PatchField, GeoMesh> \
469 > \
470 operator op \
471 ( \
472  const dimensioned<Form>& dvs, \
473  const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf1 \
474 ); \
475  \
476 template \
477 < \
478  class Form, \
479  class Cmpt, \
480  direction nCmpt, \
481  class Type, template<class> class PatchField, \
482  class GeoMesh \
483 > \
484 tmp \
485 < \
486  GeometricField \
487  <typename product<Form, Type>::type, PatchField, GeoMesh> \
488 > \
489 operator op \
490 ( \
491  const VectorSpace<Form,Cmpt,nCmpt>& vs, \
492  const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf1 \
493 );
494 
495 PRODUCT_OPERATOR(typeOfSum, +, add)
496 PRODUCT_OPERATOR(typeOfSum, -, subtract)
497 
498 PRODUCT_OPERATOR(outerProduct, *, outer)
499 PRODUCT_OPERATOR(crossProduct, ^, cross)
500 PRODUCT_OPERATOR(innerProduct, &, dot)
501 PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
502 
503 #undef PRODUCT_OPERATOR
504 
505 
506 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
507 
508 } // End namespace Foam
509 
510 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
511 
512 #include "undefFieldFunctionsM.H"
513 
514 // ************************************************************************* //
void divide(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
scalar gSumMag(const FieldField< Field, Type > &f)
#define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)
void multiply(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Type gMin(const FieldField< Field, Type > &f)
tmp< DimensionedField< typename DimensionedField< Type, GeoMesh >::cmptType, GeoMesh >> cmptAv(const DimensionedField< Type, GeoMesh > &df)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
uint8_t direction
Definition: direction.H:45
#define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc)
#define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpName, OpFunc)
void cross(FieldField< Field1, typename crossProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
#define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func)
void dotdot(FieldField< Field1, typename scalarProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
void subtract(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
void outer(FieldField< Field1, typename outerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
void dot(FieldField< Field1, typename innerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
#define PRODUCT_OPERATOR(product, op, opFunc)
#define BINARY_FUNCTION(ReturnType, Type1, Type2, Func)
Scalar specific part of the implementation of GeometricField.
#define UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(returnType, func, gFunc)
Type gSum(const FieldField< Field, Type > &f)
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
dimensioned< scalar > magSqr(const dimensioned< Type > &)
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Type gMax(const FieldField< Field, Type > &f)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
void negate(FieldField< Field, Type > &res, const FieldField< Field, Type > &f)
Type gAverage(const FieldField< Field, Type > &f)
dimensioned< scalar > mag(const dimensioned< Type > &)
#define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc, Dfunc)
#define UNARY_REDUCTION_FUNCTION(returnType, func, gFunc)
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
Namespace for OpenFOAM.
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:477
dimensioned< scalar > sumMag(const DimensionedField< Type, GeoMesh > &df)