FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 
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<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  <
165  typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
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  <
177  typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
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  <
189  typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
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 #ifndef __INTEL_COMPILER
254 BINARY_OPERATOR(Type, Type, scalar, *, '*', multiply)
255 BINARY_OPERATOR(Type, scalar, Type, *, '*', multiply)
256 #endif
257 BINARY_OPERATOR(Type, Type, scalar, /, '|', divide)
258 
259 BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, '*', multiply)
260 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, '*', multiply)
261 
262 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, '|', divide)
263 
264 
265 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266 
267 #define PRODUCT_OPERATOR(product, op, opFunc) \
268  \
269 template \
270 <class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
271 void opFunc \
272 ( \
273  GeometricField \
274  <typename product<Type1, Type2>::type, PatchField, GeoMesh>& gf, \
275  const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
276  const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
277 ); \
278  \
279 template \
280 <class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
281 tmp \
282 < \
283  GeometricField \
284  <typename product<Type1, Type2>::type, PatchField, GeoMesh> \
285 > \
286 operator op \
287 ( \
288  const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
289  const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
290 ); \
291  \
292 template \
293 <class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
294 tmp \
295 < \
296  GeometricField \
297  <typename product<Type1, Type2>::type, PatchField, GeoMesh> \
298 > \
299 operator op \
300 ( \
301  const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
302  const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2 \
303 ); \
304  \
305 template \
306 <class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
307 tmp \
308 < \
309  GeometricField \
310  <typename product<Type1, Type2>::type, PatchField, GeoMesh> \
311 > \
312 operator op \
313 ( \
314  const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1, \
315  const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
316 ); \
317  \
318 template \
319 <class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
320 tmp \
321 < \
322  GeometricField \
323  <typename product<Type1, Type2>::type, PatchField, GeoMesh> \
324 > \
325 operator op \
326 ( \
327  const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1, \
328  const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2 \
329 ); \
330  \
331 template \
332 <class Form, class Type, template<class> class PatchField, class GeoMesh> \
333 void opFunc \
334 ( \
335  GeometricField \
336  <typename product<Type, Form>::type, PatchField, GeoMesh>& gf, \
337  const GeometricField<Type, PatchField, GeoMesh>& gf1, \
338  const dimensioned<Form>& dvs \
339 ); \
340  \
341 template \
342 <class Form, class Type, template<class> class PatchField, class GeoMesh> \
343 tmp \
344 < \
345  GeometricField \
346  <typename product<Type, Form>::type, PatchField, GeoMesh> \
347 > \
348 operator op \
349 ( \
350  const GeometricField<Type, PatchField, GeoMesh>& gf1, \
351  const dimensioned<Form>& dvs \
352 ); \
353  \
354 template \
355 < \
356  class Form, \
357  class Cmpt, \
358  int nCmpt, \
359  class Type, template<class> class PatchField, \
360  class GeoMesh \
361 > \
362 tmp \
363 < \
364  GeometricField \
365  <typename product<Form, Type>::type, PatchField, GeoMesh> \
366 > \
367 operator op \
368 ( \
369  const GeometricField<Type, PatchField, GeoMesh>& gf1, \
370  const VectorSpace<Form,Cmpt,nCmpt>& vs \
371 ); \
372  \
373 template \
374 <class Form, class Type, template<class> class PatchField, class GeoMesh> \
375 tmp \
376 < \
377  GeometricField \
378  <typename product<Type, Form>::type, PatchField, GeoMesh> \
379 > \
380 operator op \
381 ( \
382  const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1, \
383  const dimensioned<Form>& dvs \
384 ); \
385  \
386 template \
387 < \
388  class Form, \
389  class Cmpt, \
390  int nCmpt, \
391  class Type, template<class> class PatchField, \
392  class GeoMesh \
393 > \
394 tmp \
395 < \
396  GeometricField \
397  <typename product<Form, Type>::type, PatchField, GeoMesh> \
398 > \
399 operator op \
400 ( \
401  const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1, \
402  const VectorSpace<Form,Cmpt,nCmpt>& vs \
403 ); \
404  \
405 template \
406 <class Form, class Type, template<class> class PatchField, class GeoMesh> \
407 void opFunc \
408 ( \
409  GeometricField \
410  <typename product<Form, Type>::type, PatchField, GeoMesh>& gf, \
411  const dimensioned<Form>& dvs, \
412  const GeometricField<Type, PatchField, GeoMesh>& gf1 \
413 ); \
414  \
415 template \
416 <class Form, class Type, template<class> class PatchField, class GeoMesh> \
417 tmp \
418 < \
419  GeometricField \
420  <typename product<Form, Type>::type, PatchField, GeoMesh> \
421 > \
422 operator op \
423 ( \
424  const dimensioned<Form>& dvs, \
425  const GeometricField<Type, PatchField, GeoMesh>& gf1 \
426 ); \
427  \
428 template \
429 < \
430  class Form, \
431  class Cmpt, \
432  int nCmpt, \
433  class Type, template<class> class PatchField, \
434  class GeoMesh \
435 > \
436 tmp \
437 < \
438  GeometricField \
439  <typename product<Form, Type>::type, PatchField, GeoMesh> \
440 > \
441 operator op \
442 ( \
443  const VectorSpace<Form,Cmpt,nCmpt>& vs, \
444  const GeometricField<Type, PatchField, GeoMesh>& gf1 \
445 ); \
446  \
447 template \
448 <class Form, class Type, template<class> class PatchField, class GeoMesh> \
449 tmp \
450 < \
451  GeometricField \
452  <typename product<Form, Type>::type, PatchField, GeoMesh> \
453 > \
454 operator op \
455 ( \
456  const dimensioned<Form>& dvs, \
457  const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1 \
458 ); \
459  \
460 template \
461 < \
462  class Form, \
463  class Cmpt, \
464  int nCmpt, \
465  class Type, template<class> class PatchField, \
466  class GeoMesh \
467 > \
468 tmp \
469 < \
470  GeometricField \
471  <typename product<Form, Type>::type, PatchField, GeoMesh> \
472 > \
473 operator op \
474 ( \
475  const VectorSpace<Form,Cmpt,nCmpt>& vs, \
476  const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1 \
477 );
478 
479 PRODUCT_OPERATOR(typeOfSum, +, add)
480 PRODUCT_OPERATOR(typeOfSum, -, subtract)
481 
482 PRODUCT_OPERATOR(outerProduct, *, outer)
483 PRODUCT_OPERATOR(crossProduct, ^, cross)
484 PRODUCT_OPERATOR(innerProduct, &, dot)
485 PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
486 
487 #undef PRODUCT_OPERATOR
488 
489 
490 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
491 
492 } // End namespace Foam
493 
494 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
495 
497 
498 // ************************ vim: set sw=4 sts=4 et: ************************ //