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 | Copyright (C) 2011-2015 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<class Type, template<class> class PatchField, class GeoMesh, int r>
60 void pow
61 (
62  GeometricField<typename powProduct<Type, r>::type, PatchField, GeoMesh>& gf,
63  const GeometricField<Type, PatchField, GeoMesh>& gf1
64 );
65 
66 template<class Type, template<class> class PatchField, class GeoMesh, int r>
67 tmp
68 <
69  GeometricField
70  <typename powProduct<Type, r>::type, PatchField, GeoMesh>
71 >
72 pow
73 (
74  const GeometricField<Type, PatchField, GeoMesh>& gf,
76 );
77 
78 template<class Type, template<class> class PatchField, class GeoMesh, int r>
79 tmp
80 <
81  GeometricField
82  <typename powProduct<Type, r>::type, PatchField, GeoMesh>
83 >
84 pow
85 (
86  const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf,
88 );
89 
90 template<class Type, template<class> class PatchField, class GeoMesh>
91 void sqr
92 (
93  GeometricField
94  <typename outerProduct<Type, Type>::type, PatchField, GeoMesh>& gf,
95  const GeometricField<Type, PatchField, GeoMesh>& gf1
96 );
97 
98 template<class Type, template<class> class PatchField, class GeoMesh>
99 tmp
100 <
101  GeometricField
102  <
104  PatchField,
105  GeoMesh
106  >
107 >
108 sqr(const GeometricField<Type, PatchField, GeoMesh>& gf);
109 
110 template<class Type, template<class> class PatchField, class GeoMesh>
111 tmp
112 <
113  GeometricField
114  <
116  PatchField,
117  GeoMesh
118  >
119 >
120 sqr(const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf);
121 
122 template<class Type, template<class> class PatchField, class GeoMesh>
123 void magSqr
124 (
125  GeometricField<scalar, PatchField, GeoMesh>& gsf,
126  const GeometricField<Type, PatchField, GeoMesh>& gf
127 );
128 
129 template<class Type, template<class> class PatchField, class GeoMesh>
130 tmp<GeometricField<scalar, PatchField, GeoMesh> > magSqr
131 (
132  const GeometricField<Type, PatchField, GeoMesh>& gf
133 );
134 
135 template<class Type, template<class> class PatchField, class GeoMesh>
136 tmp<GeometricField<scalar, PatchField, GeoMesh> > magSqr
137 (
138  const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf
139 );
140 
141 template<class Type, template<class> class PatchField, class GeoMesh>
142 void mag
143 (
144  GeometricField<scalar, PatchField, GeoMesh>& gsf,
145  const GeometricField<Type, PatchField, GeoMesh>& gf
146 );
147 
148 template<class Type, template<class> class PatchField, class GeoMesh>
149 tmp<GeometricField<scalar, PatchField, GeoMesh> > mag
150 (
151  const GeometricField<Type, PatchField, GeoMesh>& gf
152 );
153 
154 template<class Type, template<class> class PatchField, class GeoMesh>
155 tmp<GeometricField<scalar, PatchField, GeoMesh> > mag
156 (
157  const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf
158 );
159 
160 template<class Type, template<class> class PatchField, class GeoMesh>
161 void cmptAv
162 (
163  GeometricField
164  <
166  PatchField,
167  GeoMesh
168  >& gcf,
169  const GeometricField<Type, PatchField, GeoMesh>& gf
170 );
171 
172 template<class Type, template<class> class PatchField, class GeoMesh>
173 tmp
174 <
175  GeometricField
176  <
178  PatchField,
179  GeoMesh
180  >
181 >
182 cmptAv(const GeometricField<Type, PatchField, GeoMesh>& gf);
183 
184 template<class Type, template<class> class PatchField, class GeoMesh>
185 tmp
186 <
187  GeometricField
188  <
190  PatchField,
191  GeoMesh
192  >
193 >
194 cmptAv(const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf);
195 
196 
197 #define UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(returnType, func, gFunc) \
198  \
199 template<class Type, template<class> class PatchField, class GeoMesh> \
200 dimensioned<returnType> func \
201 ( \
202  const GeometricField<Type, PatchField, GeoMesh>& gf \
203 ); \
204  \
205 template<class Type, template<class> class PatchField, class GeoMesh> \
206 dimensioned<returnType> func \
207 ( \
208  const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1 \
209 );
210 
213 
214 #undef UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY
215 
216 
217 #define UNARY_REDUCTION_FUNCTION(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 
234 
235 #undef UNARY_REDUCTION_FUNCTION
236 
237 
238 BINARY_FUNCTION(Type, Type, Type, max)
239 BINARY_FUNCTION(Type, Type, Type, min)
240 BINARY_FUNCTION(Type, Type, Type, cmptMultiply)
241 BINARY_FUNCTION(Type, Type, Type, cmptDivide)
242 
243 BINARY_TYPE_FUNCTION(Type, Type, Type, max)
244 BINARY_TYPE_FUNCTION(Type, Type, Type, min)
245 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
246 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
247 
248 
249 // * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * //
250 
251 UNARY_OPERATOR(Type, Type, -, negate, transform)
252 
253 BINARY_OPERATOR(Type, Type, scalar, *, '*', multiply)
254 BINARY_OPERATOR(Type, scalar, Type, *, '*', multiply)
255 BINARY_OPERATOR(Type, Type, scalar, /, '|', divide)
256 
257 BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, '*', multiply)
258 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, '*', multiply)
259 
260 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, '|', divide)
261 
262 
263 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
264 
265 #define PRODUCT_OPERATOR(product, op, opFunc) \
266  \
267 template \
268 <class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
269 void opFunc \
270 ( \
271  GeometricField \
272  <typename product<Type1, Type2>::type, PatchField, GeoMesh>& gf, \
273  const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
274  const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
275 ); \
276  \
277 template \
278 <class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
279 tmp \
280 < \
281  GeometricField \
282  <typename product<Type1, Type2>::type, PatchField, GeoMesh> \
283 > \
284 operator op \
285 ( \
286  const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
287  const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
288 ); \
289  \
290 template \
291 <class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
292 tmp \
293 < \
294  GeometricField \
295  <typename product<Type1, Type2>::type, PatchField, GeoMesh> \
296 > \
297 operator op \
298 ( \
299  const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
300  const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2 \
301 ); \
302  \
303 template \
304 <class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
305 tmp \
306 < \
307  GeometricField \
308  <typename product<Type1, Type2>::type, PatchField, GeoMesh> \
309 > \
310 operator op \
311 ( \
312  const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1, \
313  const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
314 ); \
315  \
316 template \
317 <class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
318 tmp \
319 < \
320  GeometricField \
321  <typename product<Type1, Type2>::type, PatchField, GeoMesh> \
322 > \
323 operator op \
324 ( \
325  const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1, \
326  const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2 \
327 ); \
328  \
329 template \
330 <class Form, class Type, template<class> class PatchField, class GeoMesh> \
331 void opFunc \
332 ( \
333  GeometricField \
334  <typename product<Type, Form>::type, PatchField, GeoMesh>& gf, \
335  const GeometricField<Type, PatchField, GeoMesh>& gf1, \
336  const dimensioned<Form>& dvs \
337 ); \
338  \
339 template \
340 <class Form, class Type, template<class> class PatchField, class GeoMesh> \
341 tmp \
342 < \
343  GeometricField \
344  <typename product<Type, Form>::type, PatchField, GeoMesh> \
345 > \
346 operator op \
347 ( \
348  const GeometricField<Type, PatchField, GeoMesh>& gf1, \
349  const dimensioned<Form>& dvs \
350 ); \
351  \
352 template \
353 < \
354  class Form, \
355  class Cmpt, \
356  int nCmpt, \
357  class Type, template<class> class PatchField, \
358  class GeoMesh \
359 > \
360 tmp \
361 < \
362  GeometricField \
363  <typename product<Form, Type>::type, PatchField, GeoMesh> \
364 > \
365 operator op \
366 ( \
367  const GeometricField<Type, PatchField, GeoMesh>& gf1, \
368  const VectorSpace<Form,Cmpt,nCmpt>& vs \
369 ); \
370  \
371 template \
372 <class Form, class Type, template<class> class PatchField, class GeoMesh> \
373 tmp \
374 < \
375  GeometricField \
376  <typename product<Type, Form>::type, PatchField, GeoMesh> \
377 > \
378 operator op \
379 ( \
380  const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1, \
381  const dimensioned<Form>& dvs \
382 ); \
383  \
384 template \
385 < \
386  class Form, \
387  class Cmpt, \
388  int nCmpt, \
389  class Type, template<class> class PatchField, \
390  class GeoMesh \
391 > \
392 tmp \
393 < \
394  GeometricField \
395  <typename product<Form, Type>::type, PatchField, GeoMesh> \
396 > \
397 operator op \
398 ( \
399  const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1, \
400  const VectorSpace<Form,Cmpt,nCmpt>& vs \
401 ); \
402  \
403 template \
404 <class Form, class Type, template<class> class PatchField, class GeoMesh> \
405 void opFunc \
406 ( \
407  GeometricField \
408  <typename product<Form, Type>::type, PatchField, GeoMesh>& gf, \
409  const dimensioned<Form>& dvs, \
410  const GeometricField<Type, PatchField, GeoMesh>& gf1 \
411 ); \
412  \
413 template \
414 <class Form, class Type, template<class> class PatchField, class GeoMesh> \
415 tmp \
416 < \
417  GeometricField \
418  <typename product<Form, Type>::type, PatchField, GeoMesh> \
419 > \
420 operator op \
421 ( \
422  const dimensioned<Form>& dvs, \
423  const GeometricField<Type, PatchField, GeoMesh>& gf1 \
424 ); \
425  \
426 template \
427 < \
428  class Form, \
429  class Cmpt, \
430  int nCmpt, \
431  class Type, template<class> class PatchField, \
432  class GeoMesh \
433 > \
434 tmp \
435 < \
436  GeometricField \
437  <typename product<Form, Type>::type, PatchField, GeoMesh> \
438 > \
439 operator op \
440 ( \
441  const VectorSpace<Form,Cmpt,nCmpt>& vs, \
442  const GeometricField<Type, PatchField, GeoMesh>& gf1 \
443 ); \
444  \
445 template \
446 <class Form, class Type, template<class> class PatchField, class GeoMesh> \
447 tmp \
448 < \
449  GeometricField \
450  <typename product<Form, Type>::type, PatchField, GeoMesh> \
451 > \
452 operator op \
453 ( \
454  const dimensioned<Form>& dvs, \
455  const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1 \
456 ); \
457  \
458 template \
459 < \
460  class Form, \
461  class Cmpt, \
462  int nCmpt, \
463  class Type, template<class> class PatchField, \
464  class GeoMesh \
465 > \
466 tmp \
467 < \
468  GeometricField \
469  <typename product<Form, Type>::type, PatchField, GeoMesh> \
470 > \
471 operator op \
472 ( \
473  const VectorSpace<Form,Cmpt,nCmpt>& vs, \
474  const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1 \
475 );
476 
477 PRODUCT_OPERATOR(typeOfSum, +, add)
478 PRODUCT_OPERATOR(typeOfSum, -, subtract)
479 
480 PRODUCT_OPERATOR(outerProduct, *, outer)
481 PRODUCT_OPERATOR(crossProduct, ^, cross)
482 PRODUCT_OPERATOR(innerProduct, &, dot)
483 PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
484 
485 #undef PRODUCT_OPERATOR
486 
487 
488 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
489 
490 } // End namespace Foam
491 
492 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
493 
494 #include "undefFieldFunctionsM.H"
495 
496 // ************************************************************************* //
BINARY_TYPE_OPERATOR_SF
#define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc)
Definition: DimensionedFieldFunctionsM.C:531
BINARY_OPERATOR
#define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)
Definition: DimensionedFieldFunctionsM.C:417
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:871
Foam::component
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
Definition: FieldFieldFunctions.C:41
Foam::cmptMultiply
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::gAverage
Type gAverage(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:571
UNARY_REDUCTION_FUNCTION
#define UNARY_REDUCTION_FUNCTION(returnType, func, gFunc)
Definition: GeometricFieldFunctions.H:217
Foam::outerProduct::type
typeOfRank< typename pTraits< arg1 >::cmptType, int(pTraits< arg1 >::rank)+int(pTraits< arg2 >::rank) >::type type
Definition: products.H:72
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:875
undefFieldFunctionsM.H
GeometricScalarField.H
Scalar specific part of the implementation of GeometricField.
Foam::gSum
Type gSum(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:564
BINARY_FUNCTION
#define BINARY_FUNCTION(ReturnType, Type1, Type2, Func)
Definition: DimensionedFieldFunctionsM.C:142
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
Foam::GeometricField::cmptType
Field< Type >::cmptType cmptType
Definition: GeometricField.H:273
Foam::transform
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:465
Foam::powProduct::type
symmTypeOfRank< typename pTraits< arg1 >::cmptType, arg2 *int(pTraits< arg1 >::rank) >::type type
Definition: products.H:118
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:55
Foam::pow
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Definition: dimensionedScalar.C:73
Foam::sumMag
dimensioned< scalar > sumMag(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:334
Foam::negate
void negate(FieldField< Field, Type > &res, const FieldField< Field, Type > &f)
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:870
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
PRODUCT_OPERATOR
#define PRODUCT_OPERATOR(product, op, opFunc)
Definition: GeometricFieldFunctions.H:265
Foam::gSumMag
scalar gSumMag(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:565
BINARY_TYPE_FUNCTION
#define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func)
Definition: DimensionedFieldFunctionsM.C:410
Foam::max
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::cmptDivide
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:49
UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY
#define UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(returnType, func, gFunc)
Definition: GeometricFieldFunctions.H:197
Foam::cmptAv
tmp< DimensionedField< typename DimensionedField< Type, GeoMesh >::cmptType, GeoMesh >> cmptAv(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:252
UNARY_OPERATOR
#define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc, Dfunc)
Definition: DimensionedFieldFunctionsM.C:86
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:873
Foam::sum
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:333
Foam::direction
unsigned char direction
Definition: direction.H:43
Foam::gMin
Type gMin(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:563
BINARY_TYPE_OPERATOR_FS
#define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpName, OpFunc)
Definition: DimensionedFieldFunctionsM.C:608
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:874
Foam::min
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::magSqr
dimensioned< scalar > magSqr(const dimensioned< Type > &)
Foam::gMax
Type gMax(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:562
Foam::average
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:335
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:876