Loading...
Searching...
No Matches
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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2018-2025 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
30
31#define TEMPLATE \
32 template<class Type, template<class> class PatchField, class GeoMesh>
34
35// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36
37namespace Foam
38{
39
40// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
41
42template<class Type, template<class> class PatchField, class GeoMesh>
43void component
44(
45 GeometricField
46 <
48 PatchField,
49 GeoMesh
50 >& result,
51 const GeometricField<Type, PatchField, GeoMesh>& f1,
52 const direction d
53);
54
55template<class Type, template<class> class PatchField, class GeoMesh>
56void T
57(
58 GeometricField<Type, PatchField, GeoMesh>& result,
59 const GeometricField<Type, PatchField, GeoMesh>& f1
60);
61
62template
63<
64 class Type,
65 template<class> class PatchField,
66 class GeoMesh,
67 direction r
68>
69void pow
70(
71 GeometricField
72 <typename powProduct<Type, r>::type, PatchField, GeoMesh>& result,
73 const GeometricField<Type, PatchField, GeoMesh>& f1
74);
75
76template
77<
78 class Type,
79 template<class> class PatchField,
80 class GeoMesh,
81 direction r
82>
83tmp
84<
85 GeometricField
86 <typename powProduct<Type, r>::type, PatchField, GeoMesh>
87>
88pow
89(
90 const GeometricField<Type, PatchField, GeoMesh>& f1,
92);
93
94template
95<
96 class Type,
97 template<class> class PatchField,
98 class GeoMesh,
99 direction r
100>
101tmp
102<
103 GeometricField
104 <typename powProduct<Type, r>::type, PatchField, GeoMesh>
105>
106pow
107(
108 const tmp<GeometricField<Type, PatchField, GeoMesh>>& tf1,
110);
111
112template<class Type, template<class> class PatchField, class GeoMesh>
113void sqr
114(
115 GeometricField
116 <typename outerProduct<Type, Type>::type, PatchField, GeoMesh>& f1,
117 const GeometricField<Type, PatchField, GeoMesh>& gf1
118);
119
120template<class Type, template<class> class PatchField, class GeoMesh>
121tmp
122<
123 GeometricField
124 <
126 PatchField,
127 GeoMesh
128 >
129>
130sqr(const GeometricField<Type, PatchField, GeoMesh>& f1);
131
132template<class Type, template<class> class PatchField, class GeoMesh>
133tmp
134<
135 GeometricField
136 <
138 PatchField,
139 GeoMesh
140 >
141>
142sqr(const tmp<GeometricField<Type, PatchField, GeoMesh>>& tf1);
143
144template<class Type, template<class> class PatchField, class GeoMesh>
145void magSqr
146(
147 GeometricField<typename typeOfMag<Type>::type, PatchField, GeoMesh>& result,
148 const GeometricField<Type, PatchField, GeoMesh>& f1
149);
150
151template<class Type, template<class> class PatchField, class GeoMesh>
152tmp<GeometricField<typename typeOfMag<Type>::type, PatchField, GeoMesh>>
153magSqr
154(
155 const GeometricField<Type, PatchField, GeoMesh>& f1
156);
157
158template<class Type, template<class> class PatchField, class GeoMesh>
159tmp<GeometricField<typename typeOfMag<Type>::type, PatchField, GeoMesh>>
160magSqr
161(
162 const tmp<GeometricField<Type, PatchField, GeoMesh>>& tf1
163);
164
165template<class Type, template<class> class PatchField, class GeoMesh>
166void mag
167(
168 GeometricField<typename typeOfMag<Type>::type, PatchField, GeoMesh>& result,
169 const GeometricField<Type, PatchField, GeoMesh>& tf1
170);
171
172template<class Type, template<class> class PatchField, class GeoMesh>
173tmp<GeometricField<typename typeOfMag<Type>::type, PatchField, GeoMesh>>
174mag
175(
176 const GeometricField<Type, PatchField, GeoMesh>& f1
177);
178
179template<class Type, template<class> class PatchField, class GeoMesh>
180tmp<GeometricField<typename typeOfMag<Type>::type, PatchField, GeoMesh>>
181mag
182(
183 const tmp<GeometricField<Type, PatchField, GeoMesh>>& tf1
184);
185
186template<class Type, template<class> class PatchField, class GeoMesh>
187void cmptAv
188(
189 GeometricField
190 <
192 PatchField,
193 GeoMesh
194 >& result,
195 const GeometricField<Type, PatchField, GeoMesh>& f1
196);
197
198template<class Type, template<class> class PatchField, class GeoMesh>
199tmp
200<
201 GeometricField
202 <
204 PatchField,
205 GeoMesh
206 >
207>
208cmptAv(const GeometricField<Type, PatchField, GeoMesh>& f1);
209
210template<class Type, template<class> class PatchField, class GeoMesh>
211tmp
212<
213 GeometricField
214 <
216 PatchField,
217 GeoMesh
218 >
219>
220cmptAv(const tmp<GeometricField<Type, PatchField, GeoMesh>>& tf1);
221
222
223#define UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(ReturnType, Func, BinaryOp) \
224 \
225template<class Type, template<class> class PatchField, class GeoMesh> \
226dimensioned<ReturnType> Func \
227( \
228 const GeometricField<Type, PatchField, GeoMesh>& f1, \
229 const label comm = UPstream::worldComm \
230); \
231 \
232template<class Type, template<class> class PatchField, class GeoMesh> \
233dimensioned<ReturnType> Func \
234( \
235 const tmp<GeometricField<Type, PatchField, GeoMesh>>& tf1, \
236 const label comm = UPstream::worldComm \
237);
238
243
244#undef UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY
245
246
247#define UNARY_REDUCTION_FUNCTION(ReturnType, Func) \
248 \
249 \
250template<class Type, template<class> class PatchField, class GeoMesh> \
251dimensioned<ReturnType> Func \
252( \
253 const GeometricField<Type, PatchField, GeoMesh>& f1, \
254 const label comm = UPstream::worldComm \
255); \
256 \
257template<class Type, template<class> class PatchField, class GeoMesh> \
258dimensioned<ReturnType> Func \
259( \
260 const tmp<GeometricField<Type, PatchField, GeoMesh>>& tf1, \
261 const label comm = UPstream::worldComm \
262);
263
267
268#undef UNARY_REDUCTION_FUNCTION
269
270
271BINARY_FUNCTION(Type, Type, Type, max)
272BINARY_FUNCTION(Type, Type, Type, min)
273BINARY_FUNCTION(Type, Type, Type, cmptMultiply)
274BINARY_FUNCTION(Type, Type, Type, cmptDivide)
275
276BINARY_TYPE_FUNCTION(Type, Type, Type, max)
277BINARY_TYPE_FUNCTION(Type, Type, Type, min)
278BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
279BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
280
281// ------------------------------------------------------------------------- //
282
283// Clamp Methods
284
285template<class Type, template<class> class PatchField, class GeoMesh>
286void clamp
287(
288 GeometricField<Type, PatchField, GeoMesh>& result,
289 const GeometricField<Type, PatchField, GeoMesh>& f1,
291);
292
293template<class Type, template<class> class PatchField, class GeoMesh>
294tmp<GeometricField<Type, PatchField, GeoMesh>>
295clamp
296(
297 const GeometricField<Type, PatchField, GeoMesh>& f1,
299);
300
301template<class Type, template<class> class PatchField, class GeoMesh>
302tmp<GeometricField<Type, PatchField, GeoMesh>>
303clamp
304(
305 const tmp<GeometricField<Type, PatchField, GeoMesh>>& tf1,
307);
308
309BINARY_TYPE_FUNCTION_FS(Type, Type, MinMax<Type>, clamp)
310
311
312// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
313
314TERNARY_FUNCTION(Type, Type, Type, scalar, lerp)
315TERNARY_TYPE_FUNCTION_FFS(Type, Type, Type, scalar, lerp)
316
317
318// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
319
320UNARY_OPERATOR(Type, Type, -, negate, transform)
321
322BINARY_OPERATOR(Type, Type, scalar, *, '*', multiply)
323BINARY_OPERATOR(Type, scalar, Type, *, '*', multiply)
324BINARY_OPERATOR(Type, Type, scalar, /, '|', divide)
325
326BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, '*', multiply)
327BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, '*', multiply)
328
329BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, '|', divide)
330
331
332// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
333
334#define PRODUCT_OPERATOR(product, Op, OpFunc) \
335 \
336template \
337<class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
338void OpFunc \
339( \
340 GeometricField \
341 <typename product<Type1, Type2>::type, PatchField, GeoMesh>& result, \
342 const GeometricField<Type1, PatchField, GeoMesh>& f1, \
343 const GeometricField<Type2, PatchField, GeoMesh>& f2 \
344); \
345 \
346template \
347<class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
348tmp \
349< \
350 GeometricField \
351 <typename product<Type1, Type2>::type, PatchField, GeoMesh> \
352> \
353operator Op \
354( \
355 const GeometricField<Type1, PatchField, GeoMesh>& f1, \
356 const GeometricField<Type2, PatchField, GeoMesh>& f2 \
357); \
358 \
359template \
360<class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
361tmp \
362< \
363 GeometricField \
364 <typename product<Type1, Type2>::type, PatchField, GeoMesh> \
365> \
366operator Op \
367( \
368 const GeometricField<Type1, PatchField, GeoMesh>& f1, \
369 const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2 \
370); \
371 \
372template \
373<class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
374tmp \
375< \
376 GeometricField \
377 <typename product<Type1, Type2>::type, PatchField, GeoMesh> \
378> \
379operator Op \
380( \
381 const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
382 const GeometricField<Type2, PatchField, GeoMesh>& f2 \
383); \
384 \
385template \
386<class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
387tmp \
388< \
389 GeometricField \
390 <typename product<Type1, Type2>::type, PatchField, GeoMesh> \
391> \
392operator Op \
393( \
394 const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
395 const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2 \
396); \
397 \
398template \
399<class Form, class Type, template<class> class PatchField, class GeoMesh> \
400void OpFunc \
401( \
402 GeometricField \
403 <typename product<Type, Form>::type, PatchField, GeoMesh>& result, \
404 const GeometricField<Type, PatchField, GeoMesh>& f1, \
405 const dimensioned<Form>& dvs \
406); \
407 \
408template \
409<class Form, class Type, template<class> class PatchField, class GeoMesh> \
410tmp \
411< \
412 GeometricField \
413 <typename product<Type, Form>::type, PatchField, GeoMesh> \
414> \
415operator Op \
416( \
417 const GeometricField<Type, PatchField, GeoMesh>& f1, \
418 const dimensioned<Form>& dvs \
419); \
420 \
421template \
422< \
423 class Form, \
424 class Cmpt, \
425 direction nCmpt, \
426 class Type, template<class> class PatchField, \
427 class GeoMesh \
428> \
429tmp \
430< \
431 GeometricField \
432 <typename product<Form, Type>::type, PatchField, GeoMesh> \
433> \
434operator Op \
435( \
436 const GeometricField<Type, PatchField, GeoMesh>& f1, \
437 const VectorSpace<Form,Cmpt,nCmpt>& vs \
438); \
439 \
440template \
441<class Form, class Type, template<class> class PatchField, class GeoMesh> \
442tmp \
443< \
444 GeometricField \
445 <typename product<Type, Form>::type, PatchField, GeoMesh> \
446> \
447operator Op \
448( \
449 const tmp<GeometricField<Type, PatchField, GeoMesh>>& tf1, \
450 const dimensioned<Form>& dvs \
451); \
452 \
453template \
454< \
455 class Form, \
456 class Cmpt, \
457 direction nCmpt, \
458 class Type, template<class> class PatchField, \
459 class GeoMesh \
460> \
461tmp \
462< \
463 GeometricField \
464 <typename product<Form, Type>::type, PatchField, GeoMesh> \
465> \
466operator Op \
467( \
468 const tmp<GeometricField<Type, PatchField, GeoMesh>>& tf1, \
469 const VectorSpace<Form,Cmpt,nCmpt>& vs \
470); \
471 \
472template \
473<class Form, class Type, template<class> class PatchField, class GeoMesh> \
474void OpFunc \
475( \
476 GeometricField \
477 <typename product<Form, Type>::type, PatchField, GeoMesh>& result, \
478 const dimensioned<Form>& dvs, \
479 const GeometricField<Type, PatchField, GeoMesh>& f2 \
480); \
481 \
482template \
483<class Form, class Type, template<class> class PatchField, class GeoMesh> \
484tmp \
485< \
486 GeometricField \
487 <typename product<Form, Type>::type, PatchField, GeoMesh> \
488> \
489operator Op \
490( \
491 const dimensioned<Form>& dvs, \
492 const GeometricField<Type, PatchField, GeoMesh>& f2 \
493); \
494 \
495template \
496< \
497 class Form, \
498 class Cmpt, \
499 direction nCmpt, \
500 class Type, template<class> class PatchField, \
501 class GeoMesh \
502> \
503tmp \
504< \
505 GeometricField \
506 <typename product<Form, Type>::type, PatchField, GeoMesh> \
507> \
508operator Op \
509( \
510 const VectorSpace<Form,Cmpt,nCmpt>& vs, \
511 const GeometricField<Type, PatchField, GeoMesh>& f2 \
512); \
513 \
514template \
515<class Form, class Type, template<class> class PatchField, class GeoMesh> \
516tmp \
517< \
518 GeometricField \
519 <typename product<Form, Type>::type, PatchField, GeoMesh> \
520> \
521operator Op \
522( \
523 const dimensioned<Form>& dvs, \
524 const tmp<GeometricField<Type, PatchField, GeoMesh>>& tf2 \
525); \
526 \
527template \
528< \
529 class Form, \
530 class Cmpt, \
531 direction nCmpt, \
532 class Type, template<class> class PatchField, \
533 class GeoMesh \
534> \
535tmp \
536< \
537 GeometricField \
538 <typename product<Form, Type>::type, PatchField, GeoMesh> \
539> \
540operator Op \
541( \
542 const VectorSpace<Form,Cmpt,nCmpt>& vs, \
543 const tmp<GeometricField<Type, PatchField, GeoMesh>>& tf2 \
544);
545
546PRODUCT_OPERATOR(typeOfSum, +, add)
547PRODUCT_OPERATOR(typeOfSum, -, subtract)
548
549PRODUCT_OPERATOR(outerProduct, *, outer)
550PRODUCT_OPERATOR(crossProduct, ^, cross)
551PRODUCT_OPERATOR(innerProduct, &, dot)
552PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
553
554#undef PRODUCT_OPERATOR
555
556
557// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
558
559} // End namespace Foam
560
561// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
562
563#include "undefFieldFunctionsM.H"
564
565// ************************************************************************* //
#define BINARY_FUNCTION(ReturnType, Type1, Type2, Func)
#define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)
#define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc, Dfunc)
#define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)
#define TERNARY_FUNCTION(ReturnType, Type1, Type2, Type3, Func)
#define TERNARY_TYPE_FUNCTION_FFS(ReturnType, Type1, Type2, Type3, Func)
#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(ReturnType, Func, gFunc)
#define UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(ReturnType, Func, BinaryOp)
Scalar specific part of the implementation of GeometricField.
Field< Type >::cmptType cmptType
Component type of the field elements.
typeOfRank< typenamepTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank)>::type type
Definition products.H:118
symmTypeOfRank< typenamepTraits< arg1 >::cmptType, arg2 *direction(pTraits< arg1 >::rank)>::type type
Definition products.H:176
pTraits< typenamepTraits< arg1 >::cmptType >::magType type
Definition products.H:96
Represents 0/1 range or concept. Used for tagged dispatch or clamping.
Definition pTraits.H:51
const volScalarField & T
#define PRODUCT_OPERATOR(product, op, opFunc)
Namespace for OpenFOAM.
dimensioned< scalarMinMax > minMaxMag(const DimensionedField< Type, GeoMesh > &f1, const label comm)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:40
dimensionedSymmTensor sqr(const dimensionedVector &dv)
void subtract(DimensionedField< scalar, GeoMesh > &result, const dimensioned< scalar > &dt1, const DimensionedField< scalar, GeoMesh > &f2)
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
dimensionSet clamp(const dimensionSet &a, const dimensionSet &range)
void divide(DimensionedField< Type, GeoMesh > &result, const DimensionedField< Type, GeoMesh > &f1, const DimensionedField< scalar, GeoMesh > &f2)
MinMax< scalar > scalarMinMax
A scalar min/max range.
Definition MinMax.H:97
void dot(FieldField< Field1, typename innerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
MinMax< label > minMax(const labelHashSet &set)
Find the min/max values of labelHashSet.
Definition hashSets.C:54
tmp< DimensionedField< typename DimensionedField< Type, GeoMesh >::cmptType, GeoMesh > > cmptAv(const DimensionedField< Type, GeoMesh > &f1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:26
uint8_t direction
Definition direction.H:49
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
void dotdot(FieldField< Field1, typename scalarProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
void cross(FieldField< Field1, typename crossProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
void negate(DimensionedField< Type, GeoMesh > &result, const DimensionedField< Type, GeoMesh > &f1)
void multiply(DimensionedField< Type, GeoMesh > &result, const DimensionedField< Type, GeoMesh > &f1, const DimensionedField< scalar, GeoMesh > &f2)
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &f1, const label comm)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
void outer(FieldField< Field1, typename outerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
dimensioned< Type > lerp(const dimensioned< Type > &a, const dimensioned< Type > &b, const scalar t)
dimensioned< typename typeOfMag< Type >::type > sumMag(const DimensionedField< Type, GeoMesh > &f1, const label comm)
dict add("bounds", meshBb)