Loading...
Searching...
No Matches
DimensionedFieldFunctions.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) 2019-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 template<class Type, class GeoMesh>
33
34// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35
36namespace Foam
37{
38
39// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
40
41template<class Type, class GeoMesh, direction r>
42tmp<DimensionedField<typename powProduct<Type, r>::type, GeoMesh>>
43pow
44(
45 const DimensionedField<Type, GeoMesh>& f1,
47);
48
49template<class Type, class GeoMesh, direction r>
50tmp<DimensionedField<typename powProduct<Type, r>::type, GeoMesh>>
51pow
52(
53 const tmp<DimensionedField<Type, GeoMesh>>& tf1,
55);
56
57template<class Type, class GeoMesh>
58tmp<DimensionedField<typename outerProduct<Type, Type>::type, GeoMesh>>
59sqr(const DimensionedField<Type, GeoMesh>& f1);
60
61template<class Type, class GeoMesh>
62tmp<DimensionedField<typename outerProduct<Type, Type>::type, GeoMesh>>
63sqr(const tmp<DimensionedField<Type, GeoMesh>>& tf1);
64
65template<class Type, class GeoMesh>
66tmp<DimensionedField<typename typeOfMag<Type>::type, GeoMesh>>
67magSqr(const DimensionedField<Type, GeoMesh>& f1);
68
69template<class Type, class GeoMesh>
70tmp<DimensionedField<typename typeOfMag<Type>::type, GeoMesh>>
71magSqr(const tmp<DimensionedField<Type, GeoMesh>>& tf1);
72
73template<class Type, class GeoMesh>
74tmp<DimensionedField<typename typeOfMag<Type>::type, GeoMesh>>
75mag(const DimensionedField<Type, GeoMesh>& f1);
76
77template<class Type, class GeoMesh>
78tmp<DimensionedField<typename typeOfMag<Type>::type, GeoMesh>>
79mag(const tmp<DimensionedField<Type, GeoMesh>>& tf1);
80
81template<class Type, class GeoMesh>
82tmp
83<
84 DimensionedField
85 <
87 GeoMesh
88 >
89>
90cmptAv(const DimensionedField<Type, GeoMesh>& f1);
91
92template<class Type, class GeoMesh>
93tmp
94<
95 DimensionedField
96 <
98 GeoMesh
99 >
100>
101cmptAv(const tmp<DimensionedField<Type, GeoMesh>>& tf1);
102
103
104// Forward to FieldFunction via gFunc()
105#define UNARY_REDUCTION_FUNCTION(ReturnType, Func, gFunc) \
106 \
107template<class Type, class GeoMesh> \
108dimensioned<ReturnType> Func \
109( \
110 const DimensionedField<Type, GeoMesh>& f1, \
111 const label comm = UPstream::worldComm \
112); \
113template<class Type, class GeoMesh> \
114dimensioned<ReturnType> Func \
115( \
116 const tmp<DimensionedField<Type, GeoMesh>>& tf1, \
117 const label comm = UPstream::worldComm \
118);
119
126
128
129#undef UNARY_REDUCTION_FUNCTION
130
131
132BINARY_FUNCTION(Type, Type, Type, max)
133BINARY_FUNCTION(Type, Type, Type, min)
134BINARY_FUNCTION(Type, Type, Type, cmptMultiply)
135BINARY_FUNCTION(Type, Type, Type, cmptDivide)
136
137BINARY_TYPE_FUNCTION(Type, Type, Type, max)
138BINARY_TYPE_FUNCTION(Type, Type, Type, min)
139BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
140BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
141
142
143// ------------------------------------------------------------------------- //
144
145// Clamp Methods
146
147template<class Type, class GeoMesh>
148void clamp
149(
150 DimensionedField<Type, GeoMesh>& result,
151 const DimensionedField<Type, GeoMesh>& f1,
153);
154
155template<class Type, class GeoMesh>
156tmp<DimensionedField<Type, GeoMesh>>
157clamp
158(
159 const DimensionedField<Type, GeoMesh>& f1,
161);
162
163template<class Type, class GeoMesh>
164tmp<DimensionedField<Type, GeoMesh>>
165clamp
166(
167 const tmp<DimensionedField<Type, GeoMesh>>& tf1,
169);
170
171BINARY_TYPE_FUNCTION_FS(Type, Type, MinMax<Type>, clamp)
172
173
174// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175
176TERNARY_FUNCTION(Type, Type, Type, scalar, lerp)
177TERNARY_TYPE_FUNCTION_FFS(Type, Type, Type, scalar, lerp)
178
179
180// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
181
182UNARY_OPERATOR(Type, Type, -, negate, transform)
183
184BINARY_OPERATOR(Type, Type, scalar, *, '*', multiply)
185BINARY_OPERATOR(Type, scalar, Type, *, '*', multiply)
186BINARY_OPERATOR(Type, Type, scalar, /, '|', divide)
187
188BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, '*', multiply)
189BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, '*', multiply)
190
191BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, '|', divide)
192
193
194// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195
196#define PRODUCT_OPERATOR(product, Op, OpFunc) \
197 \
198template<class Type1, class Type2, class GeoMesh> \
199tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
200operator Op \
201( \
202 const DimensionedField<Type1, GeoMesh>& f1, \
203 const DimensionedField<Type2, GeoMesh>& f2 \
204); \
205 \
206template<class Type1, class Type2, class GeoMesh> \
207tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
208operator Op \
209( \
210 const DimensionedField<Type1, GeoMesh>& f1, \
211 const tmp<DimensionedField<Type2, GeoMesh>>& tf2 \
212); \
213 \
214template<class Type1, class Type2, class GeoMesh> \
215tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
216operator Op \
217( \
218 const tmp<DimensionedField<Type1, GeoMesh>>& tf1, \
219 const DimensionedField<Type2, GeoMesh>& f2 \
220); \
221 \
222template<class Type1, class Type2, class GeoMesh> \
223tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
224operator Op \
225( \
226 const tmp<DimensionedField<Type1, GeoMesh>>& tf1, \
227 const tmp<DimensionedField<Type2, GeoMesh>>& tf2 \
228); \
229 \
230template<class Form, class Type, class GeoMesh> \
231tmp<DimensionedField<typename product<Type, Form>::type, GeoMesh>> \
232operator Op \
233( \
234 const DimensionedField<Type, GeoMesh>& f1, \
235 const dimensioned<Form>& dvs \
236); \
237 \
238template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
239tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
240operator Op \
241( \
242 const DimensionedField<Type, GeoMesh>& f1, \
243 const VectorSpace<Form,Cmpt,nCmpt>& vs \
244); \
245 \
246template<class Form, class Type, class GeoMesh> \
247tmp<DimensionedField<typename product<Type, Form>::type, GeoMesh>> \
248operator Op \
249( \
250 const tmp<DimensionedField<Type, GeoMesh>>& tf1, \
251 const dimensioned<Form>& dvs \
252); \
253 \
254template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
255tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
256operator Op \
257( \
258 const tmp<DimensionedField<Type, GeoMesh>>& tf1, \
259 const VectorSpace<Form,Cmpt,nCmpt>& vs \
260); \
261 \
262template<class Form, class Type, class GeoMesh> \
263tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
264operator Op \
265( \
266 const dimensioned<Form>& dvs, \
267 const DimensionedField<Type, GeoMesh>& f2 \
268); \
269 \
270template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
271tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
272operator Op \
273( \
274 const VectorSpace<Form,Cmpt,nCmpt>& vs, \
275 const DimensionedField<Type, GeoMesh>& f2 \
276); \
277 \
278template<class Form, class Type, class GeoMesh> \
279tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
280operator Op \
281( \
282 const dimensioned<Form>& dvs, \
283 const tmp<DimensionedField<Type, GeoMesh>>& tf2 \
284); \
285 \
286template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
287tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
288operator Op \
289( \
290 const VectorSpace<Form,Cmpt,nCmpt>& vs, \
291 const tmp<DimensionedField<Type, GeoMesh>>& tf2 \
292);
293
294PRODUCT_OPERATOR(typeOfSum, +, add)
295PRODUCT_OPERATOR(typeOfSum, -, subtract)
296
297PRODUCT_OPERATOR(outerProduct, *, outer)
298PRODUCT_OPERATOR(crossProduct, ^, cross)
299PRODUCT_OPERATOR(innerProduct, &, dot)
300PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
301
302#undef PRODUCT_OPERATOR
303
304
305// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
306
307} // End namespace Foam
308
309// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
310
311#include "undefFieldFunctionsM.H"
312
313// ************************************************************************* //
#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)
Scalar specific part of the implementation of DimensionedField.
Field< Type >::cmptType cmptType
Component type of the field elements.
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
#define PRODUCT_OPERATOR(product, op, opFunc)
Namespace for OpenFOAM.
Type gAverage(const FieldField< Field, Type > &f, const label comm)
The global arithmetic average of a FieldField.
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
Type gSum(const FieldField< Field, Type > &f)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
void subtract(DimensionedField< scalar, GeoMesh > &result, const dimensioned< scalar > &dt1, const DimensionedField< scalar, GeoMesh > &f2)
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)
scalarMinMax gMinMaxMag(const FieldField< Field, Type > &f)
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
MinMax< Type > gMinMax(const FieldField< Field, Type > &f)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
typeOfMag< Type >::type gSumMag(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 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)
Type gMax(const FieldField< Field, Type > &f)
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)