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 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>& df,
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>>& tdf,
55);
56
57template<class Type, class GeoMesh>
58tmp<DimensionedField<typename outerProduct<Type, Type>::type, GeoMesh>>
59sqr(const DimensionedField<Type, GeoMesh>& df);
60
61template<class Type, class GeoMesh>
62tmp<DimensionedField<typename outerProduct<Type, Type>::type, GeoMesh>>
63sqr(const tmp<DimensionedField<Type, GeoMesh>>& tdf);
64
65template<class Type, class GeoMesh>
66tmp<DimensionedField<typename typeOfMag<Type>::type, GeoMesh>>
67magSqr(const DimensionedField<Type, GeoMesh>& df);
68
69template<class Type, class GeoMesh>
70tmp<DimensionedField<typename typeOfMag<Type>::type, GeoMesh>>
71magSqr(const tmp<DimensionedField<Type, GeoMesh>>& tdf);
72
73template<class Type, class GeoMesh>
74tmp<DimensionedField<typename typeOfMag<Type>::type, GeoMesh>>
75mag(const DimensionedField<Type, GeoMesh>& df);
76
77template<class Type, class GeoMesh>
78tmp<DimensionedField<typename typeOfMag<Type>::type, GeoMesh>>
79mag(const tmp<DimensionedField<Type, GeoMesh>>& tdf);
80
81template<class Type, class GeoMesh>
82tmp
83<
84 DimensionedField
85 <
87 GeoMesh
88 >
89>
90cmptAv(const DimensionedField<Type, GeoMesh>& df);
91
92template<class Type, class GeoMesh>
93tmp
94<
95 DimensionedField
96 <
98 GeoMesh
99 >
100>
101cmptAv(const tmp<DimensionedField<Type, GeoMesh>>& tdf);
102
103
104// Forward to FieldFunction via dfunc()
105#define UNARY_REDUCTION_FUNCTION(returnType, func, dfunc) \
106 \
107template<class Type, class GeoMesh> \
108dimensioned<returnType> func \
109( \
110 const DimensionedField<Type, GeoMesh>& df \
111); \
112template<class Type, class GeoMesh> \
113dimensioned<returnType> func \
114( \
115 const tmp<DimensionedField<Type, GeoMesh>>& tdf1 \
116);
117
124
126
127#undef UNARY_REDUCTION_FUNCTION
128
129
130BINARY_FUNCTION(Type, Type, Type, max)
131BINARY_FUNCTION(Type, Type, Type, min)
133BINARY_FUNCTION(Type, Type, Type, cmptDivide)
134
135BINARY_TYPE_FUNCTION(Type, Type, Type, max)
136BINARY_TYPE_FUNCTION(Type, Type, Type, min)
139
141
142
143// * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * //
144
146
147BINARY_OPERATOR(Type, Type, scalar, *, '*', multiply)
148BINARY_OPERATOR(Type, scalar, Type, *, '*', multiply)
149BINARY_OPERATOR(Type, Type, scalar, /, '|', divide)
150
151BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, '*', multiply)
152BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, '*', multiply)
153
154BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, '|', divide)
155
156
157// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158
159#define PRODUCT_OPERATOR(product, op, opFunc) \
160 \
161template<class Type1, class Type2, class GeoMesh> \
162tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
163operator op \
164( \
165 const DimensionedField<Type1, GeoMesh>& df1, \
166 const DimensionedField<Type2, GeoMesh>& df2 \
167); \
168 \
169template<class Type1, class Type2, class GeoMesh> \
170tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
171operator op \
172( \
173 const DimensionedField<Type1, GeoMesh>& df1, \
174 const tmp<DimensionedField<Type2, GeoMesh>>& tdf2 \
175); \
176 \
177template<class Type1, class Type2, class GeoMesh> \
178tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
179operator op \
180( \
181 const tmp<DimensionedField<Type1, GeoMesh>>& tdf1, \
182 const DimensionedField<Type2, GeoMesh>& df2 \
183); \
184 \
185template<class Type1, class Type2, class GeoMesh> \
186tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
187operator op \
188( \
189 const tmp<DimensionedField<Type1, GeoMesh>>& tdf1, \
190 const tmp<DimensionedField<Type2, GeoMesh>>& tdf2 \
191); \
192 \
193template<class Form, class Type, class GeoMesh> \
194tmp<DimensionedField<typename product<Type, Form>::type, GeoMesh>> \
195operator op \
196( \
197 const DimensionedField<Type, GeoMesh>& df1, \
198 const dimensioned<Form>& dvs \
199); \
200 \
201template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
202tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
203operator op \
204( \
205 const DimensionedField<Type, GeoMesh>& df1, \
206 const VectorSpace<Form,Cmpt,nCmpt>& vs \
207); \
208 \
209template<class Form, class Type, class GeoMesh> \
210tmp<DimensionedField<typename product<Type, Form>::type, GeoMesh>> \
211operator op \
212( \
213 const tmp<DimensionedField<Type, GeoMesh>>& tdf1, \
214 const dimensioned<Form>& dvs \
215); \
216 \
217template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
218tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
219operator op \
220( \
221 const tmp<DimensionedField<Type, GeoMesh>>& tdf1, \
222 const VectorSpace<Form,Cmpt,nCmpt>& vs \
223); \
224 \
225template<class Form, class Type, class GeoMesh> \
226tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
227operator op \
228( \
229 const dimensioned<Form>& dvs, \
230 const DimensionedField<Type, GeoMesh>& df1 \
231); \
232 \
233template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
234tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
235operator op \
236( \
237 const VectorSpace<Form,Cmpt,nCmpt>& vs, \
238 const DimensionedField<Type, GeoMesh>& df1 \
239); \
240 \
241template<class Form, class Type, class GeoMesh> \
242tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
243operator op \
244( \
245 const dimensioned<Form>& dvs, \
246 const tmp<DimensionedField<Type, GeoMesh>>& tdf1 \
247); \
248 \
249template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
250tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
251operator op \
252( \
253 const VectorSpace<Form,Cmpt,nCmpt>& vs, \
254 const tmp<DimensionedField<Type, GeoMesh>>& tdf1 \
255);
256
257PRODUCT_OPERATOR(typeOfSum, +, add)
258PRODUCT_OPERATOR(typeOfSum, -, subtract)
259
260PRODUCT_OPERATOR(outerProduct, *, outer)
261PRODUCT_OPERATOR(crossProduct, ^, cross)
262PRODUCT_OPERATOR(innerProduct, &, dot)
263PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
264
265#undef PRODUCT_OPERATOR
266
267
268// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
269
270} // End namespace Foam
271
272// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
273
274#include "undefFieldFunctionsM.H"
275
276// ************************************************************************* //
#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 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, dfunc)
Scalar specific part of the implementation of DimensionedField.
Field< Type >::cmptType cmptType
Component type of the elements of the field.
A min/max value pair with additional methods. In addition to conveniently storing values,...
Definition: MinMax.H:128
symmTypeOfRank< typenamepTraits< arg1 >::cmptType, arg2 *direction(pTraits< arg1 >::rank)>::type type
Definition: products.H:170
pTraits< typenamepTraits< arg1 >::cmptType >::magType type
Definition: products.H:92
#define PRODUCT_OPERATOR(product, op, opFunc)
Namespace for OpenFOAM.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
dimensionSet clip(const dimensionSet &ds1, const dimensionSet &ds2)
Definition: dimensionSet.C:278
Type gSum(const FieldField< Field, Type > &f)
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:536
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
void subtract(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
MinMax< scalar > scalarMinMax
A scalar min/max range.
Definition: MinMax.H:117
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
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:61
dimensioned< typename typeOfMag< Type >::type > sumMag(const DimensionedField< Type, GeoMesh > &df)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
void negate(FieldField< Field, Type > &res, const FieldField< Field, Type > &f)
void multiply(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
Type gAverage(const FieldField< Field, Type > &f)
MinMax< Type > gMinMax(const FieldField< Field, Type > &f)
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)
tmp< DimensionedField< typename DimensionedField< Type, GeoMesh >::cmptType, GeoMesh > > cmptAv(const DimensionedField< Type, GeoMesh > &df)
dimensioned< scalarMinMax > minMaxMag(const DimensionedField< Type, GeoMesh > &df)
Type gMax(const FieldField< Field, Type > &f)
void divide(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
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)