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 -------------------------------------------------------------------------------
11 License
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 
29 #include "DimensionedScalarField.H"
30 
31 #define TEMPLATE template<class Type, class GeoMesh>
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 
39 // * * * * * * * * * * * * * * * Global functions * * * * * * * * * * * * * //
40 
41 template<class Type, class GeoMesh, direction r>
43 pow
44 (
45  const DimensionedField<Type, GeoMesh>& df,
47 );
48 
49 template<class Type, class GeoMesh, direction r>
51 pow
52 (
53  const tmp<DimensionedField<Type, GeoMesh>>& tdf,
55 );
56 
57 template<class Type, class GeoMesh>
59 sqr(const DimensionedField<Type, GeoMesh>& df);
60 
61 template<class Type, class GeoMesh>
63 sqr(const tmp<DimensionedField<Type, GeoMesh>>& tdf);
64 
65 template<class Type, class GeoMesh>
67 magSqr(const DimensionedField<Type, GeoMesh>& df);
68 
69 template<class Type, class GeoMesh>
71 magSqr(const tmp<DimensionedField<Type, GeoMesh>>& tdf);
72 
73 template<class Type, class GeoMesh>
75 mag(const DimensionedField<Type, GeoMesh>& df);
76 
77 template<class Type, class GeoMesh>
79 mag(const tmp<DimensionedField<Type, GeoMesh>>& tdf);
80 
81 template<class Type, class GeoMesh>
82 tmp
83 <
84  DimensionedField
85  <
87  GeoMesh
88  >
89 >
90 cmptAv(const DimensionedField<Type, GeoMesh>& df);
91 
92 template<class Type, class GeoMesh>
93 tmp
94 <
95  DimensionedField
96  <
98  GeoMesh
99  >
100 >
101 cmptAv(const tmp<DimensionedField<Type, GeoMesh>>& tdf);
102 
103 
104 // Forward to FieldFunction via dfunc()
105 #define UNARY_REDUCTION_FUNCTION(returnType, func, dfunc) \
106  \
107 template<class Type, class GeoMesh> \
108 dimensioned<returnType> func \
109 ( \
110  const DimensionedField<Type, GeoMesh>& df \
111 ); \
112 template<class Type, class GeoMesh> \
113 dimensioned<returnType> func \
114 ( \
115  const tmp<DimensionedField<Type, GeoMesh>>& tdf1 \
116 );
117 
124 
126 
127 #undef UNARY_REDUCTION_FUNCTION
128 
129 
130 BINARY_FUNCTION(Type, Type, Type, max)
131 BINARY_FUNCTION(Type, Type, Type, min)
132 BINARY_FUNCTION(Type, Type, Type, cmptMultiply)
133 BINARY_FUNCTION(Type, Type, Type, cmptDivide)
134 
135 BINARY_TYPE_FUNCTION(Type, Type, Type, max)
136 BINARY_TYPE_FUNCTION(Type, Type, Type, min)
137 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
138 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
139 
140 BINARY_TYPE_FUNCTION_FS(Type, Type, MinMax<Type>, clip)
141 
142 
143 // * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * //
144 
145 UNARY_OPERATOR(Type, Type, -, negate, transform)
146 
147 BINARY_OPERATOR(Type, Type, scalar, *, '*', multiply)
148 BINARY_OPERATOR(Type, scalar, Type, *, '*', multiply)
149 BINARY_OPERATOR(Type, Type, scalar, /, '|', divide)
150 
151 BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, '*', multiply)
152 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, '*', multiply)
153 
154 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, '|', divide)
155 
156 
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 
159 #define PRODUCT_OPERATOR(product, op, opFunc) \
160  \
161 template<class Type1, class Type2, class GeoMesh> \
162 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
163 operator op \
164 ( \
165  const DimensionedField<Type1, GeoMesh>& df1, \
166  const DimensionedField<Type2, GeoMesh>& df2 \
167 ); \
168  \
169 template<class Type1, class Type2, class GeoMesh> \
170 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
171 operator op \
172 ( \
173  const DimensionedField<Type1, GeoMesh>& df1, \
174  const tmp<DimensionedField<Type2, GeoMesh>>& tdf2 \
175 ); \
176  \
177 template<class Type1, class Type2, class GeoMesh> \
178 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
179 operator op \
180 ( \
181  const tmp<DimensionedField<Type1, GeoMesh>>& tdf1, \
182  const DimensionedField<Type2, GeoMesh>& df2 \
183 ); \
184  \
185 template<class Type1, class Type2, class GeoMesh> \
186 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
187 operator op \
188 ( \
189  const tmp<DimensionedField<Type1, GeoMesh>>& tdf1, \
190  const tmp<DimensionedField<Type2, GeoMesh>>& tdf2 \
191 ); \
192  \
193 template<class Form, class Type, class GeoMesh> \
194 tmp<DimensionedField<typename product<Type, Form>::type, GeoMesh>> \
195 operator op \
196 ( \
197  const DimensionedField<Type, GeoMesh>& df1, \
198  const dimensioned<Form>& dvs \
199 ); \
200  \
201 template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
202 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
203 operator op \
204 ( \
205  const DimensionedField<Type, GeoMesh>& df1, \
206  const VectorSpace<Form,Cmpt,nCmpt>& vs \
207 ); \
208  \
209 template<class Form, class Type, class GeoMesh> \
210 tmp<DimensionedField<typename product<Type, Form>::type, GeoMesh>> \
211 operator op \
212 ( \
213  const tmp<DimensionedField<Type, GeoMesh>>& tdf1, \
214  const dimensioned<Form>& dvs \
215 ); \
216  \
217 template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
218 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
219 operator op \
220 ( \
221  const tmp<DimensionedField<Type, GeoMesh>>& tdf1, \
222  const VectorSpace<Form,Cmpt,nCmpt>& vs \
223 ); \
224  \
225 template<class Form, class Type, class GeoMesh> \
226 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
227 operator op \
228 ( \
229  const dimensioned<Form>& dvs, \
230  const DimensionedField<Type, GeoMesh>& df1 \
231 ); \
232  \
233 template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
234 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
235 operator op \
236 ( \
237  const VectorSpace<Form,Cmpt,nCmpt>& vs, \
238  const DimensionedField<Type, GeoMesh>& df1 \
239 ); \
240  \
241 template<class Form, class Type, class GeoMesh> \
242 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
243 operator op \
244 ( \
245  const dimensioned<Form>& dvs, \
246  const tmp<DimensionedField<Type, GeoMesh>>& tdf1 \
247 ); \
248  \
249 template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
250 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
251 operator op \
252 ( \
253  const VectorSpace<Form,Cmpt,nCmpt>& vs, \
254  const tmp<DimensionedField<Type, GeoMesh>>& tdf1 \
255 );
256 
257 PRODUCT_OPERATOR(typeOfSum, +, add)
258 PRODUCT_OPERATOR(typeOfSum, -, subtract)
259 
260 PRODUCT_OPERATOR(outerProduct, *, outer)
261 PRODUCT_OPERATOR(crossProduct, ^, cross)
262 PRODUCT_OPERATOR(innerProduct, &, dot)
263 PRODUCT_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 // ************************************************************************* //
BINARY_TYPE_OPERATOR_SF
#define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc)
Definition: DimensionedFieldFunctionsM.C:522
BINARY_OPERATOR
#define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)
Definition: DimensionedFieldFunctionsM.C:412
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:940
Foam::gSumMag
typeOfMag< Type >::type gSumMag(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:598
Foam::cmptMultiply
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::gAverage
Type gAverage(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:604
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:944
undefFieldFunctionsM.H
Foam::sumMag
dimensioned< typename typeOfMag< Type >::type > sumMag(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:332
Foam::powProduct::type
symmTypeOfRank< typename pTraits< arg1 >::cmptType, arg2 *direction(pTraits< arg1 >::rank) >::type type
Definition: products.H:170
Foam::gMinMaxMag
scalarMinMax gMinMaxMag(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:596
Foam::gSum
Type gSum(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:594
BINARY_FUNCTION
#define BINARY_FUNCTION(ReturnType, Type1, Type2, Func)
Definition: DimensionedFieldFunctionsM.C:141
Foam::transform
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:521
PRODUCT_OPERATOR
#define PRODUCT_OPERATOR(product, op, opFunc)
Definition: DimensionedFieldFunctions.H:159
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
Foam::magSqr
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
Foam::divide
void divide(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
DimensionedScalarField.H
Scalar specific part of the implementation of DimensionedField.
BINARY_TYPE_FUNCTION_FS
#define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)
Definition: DimensionedFieldFunctionsM.C:329
Foam::DimensionedField::cmptType
Field< Type >::cmptType cmptType
Component type of the elements of the field.
Definition: DimensionedField.H:92
Foam::cmptAv
tmp< DimensionedField< typename DimensionedField< Type, GeoMesh >::cmptType, GeoMesh >> cmptAv(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:246
Foam::pow
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Definition: dimensionedScalar.C:75
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Foam::scalarMinMax
MinMax< scalar > scalarMinMax
A scalar min/max range.
Definition: MinMax.H:117
Foam::negate
void negate(FieldField< Field, Type > &res, const FieldField< Field, Type > &f)
Foam::minMaxMag
dimensioned< scalarMinMax > minMaxMag(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:330
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:939
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
BINARY_TYPE_FUNCTION
#define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func)
Definition: DimensionedFieldFunctionsM.C:405
Foam::cmptDivide
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
Foam::clip
dimensionSet clip(const dimensionSet &ds1, const dimensionSet &ds2)
Definition: dimensionSet.C:278
UNARY_OPERATOR
#define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc, Dfunc)
Definition: DimensionedFieldFunctionsM.C:87
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
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:942
Foam::sum
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:327
UNARY_REDUCTION_FUNCTION
#define UNARY_REDUCTION_FUNCTION(returnType, func, dfunc)
Definition: DimensionedFieldFunctions.H:105
Foam::roots::type
type
Types of root.
Definition: Roots.H:54
Foam::minMax
MinMax< label > minMax(const labelHashSet &set)
Find the min/max values of labelHashSet.
Definition: hashSets.C:61
Foam::gMin
Type gMin(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:593
BINARY_TYPE_OPERATOR_FS
#define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpName, OpFunc)
Definition: DimensionedFieldFunctionsM.C:599
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:943
Foam::typeOfMag::type
pTraits< typename pTraits< arg1 >::cmptType >::magType type
Definition: products.H:92
Foam::gMax
Type gMax(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:592
Foam::average
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:328
DimensionedFieldFunctionsM.H
Foam::gMinMax
MinMax< Type > gMinMax(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:595
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:945