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-2023 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>& f1,
47 );
48 
49 template<class Type, class GeoMesh, direction r>
51 pow
52 (
53  const tmp<DimensionedField<Type, GeoMesh>>& tf1,
55 );
56 
57 template<class Type, class GeoMesh>
59 sqr(const DimensionedField<Type, GeoMesh>& f1);
60 
61 template<class Type, class GeoMesh>
63 sqr(const tmp<DimensionedField<Type, GeoMesh>>& tf1);
64 
65 template<class Type, class GeoMesh>
67 magSqr(const DimensionedField<Type, GeoMesh>& f1);
68 
69 template<class Type, class GeoMesh>
71 magSqr(const tmp<DimensionedField<Type, GeoMesh>>& tf1);
72 
73 template<class Type, class GeoMesh>
75 mag(const DimensionedField<Type, GeoMesh>& f1);
76 
77 template<class Type, class GeoMesh>
79 mag(const tmp<DimensionedField<Type, GeoMesh>>& tf1);
80 
81 template<class Type, class GeoMesh>
82 tmp
83 <
84  DimensionedField
85  <
87  GeoMesh
88  >
89 >
90 cmptAv(const DimensionedField<Type, GeoMesh>& f1);
91 
92 template<class Type, class GeoMesh>
93 tmp
94 <
95  DimensionedField
96  <
98  GeoMesh
99  >
100 >
101 cmptAv(const tmp<DimensionedField<Type, GeoMesh>>& tf1);
102 
103 
104 // Forward to FieldFunction via gFunc()
105 #define UNARY_REDUCTION_FUNCTION(ReturnType, Func, gFunc) \
106  \
107 template<class Type, class GeoMesh> \
108 dimensioned<ReturnType> Func \
109 ( \
110  const DimensionedField<Type, GeoMesh>& f1 \
111 ); \
112 template<class Type, class GeoMesh> \
113 dimensioned<ReturnType> Func \
114 ( \
115  const tmp<DimensionedField<Type, GeoMesh>>& tf1 \
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 
141 // ------------------------------------------------------------------------- //
142 
143 // Clamp Methods
144 
145 template<class Type, class GeoMesh>
146 void clamp
147 (
148  DimensionedField<Type, GeoMesh>& result,
149  const DimensionedField<Type, GeoMesh>& f1,
150  const Foam::zero_one
151 );
152 
153 template<class Type, class GeoMesh>
154 tmp<DimensionedField<Type, GeoMesh>>
155 clamp
156 (
157  const DimensionedField<Type, GeoMesh>& f1,
158  const Foam::zero_one
159 );
160 
161 template<class Type, class GeoMesh>
162 tmp<DimensionedField<Type, GeoMesh>>
163 clamp
164 (
165  const tmp<DimensionedField<Type, GeoMesh>>& tf1,
166  const Foam::zero_one
167 );
168 
169 BINARY_TYPE_FUNCTION_FS(Type, Type, MinMax<Type>, clamp)
170 
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 TERNARY_FUNCTION(Type, Type, Type, scalar, lerp)
175 TERNARY_TYPE_FUNCTION_FFS(Type, Type, Type, scalar, lerp)
176 
177 
178 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
179 
180 UNARY_OPERATOR(Type, Type, -, negate, transform)
181 
182 BINARY_OPERATOR(Type, Type, scalar, *, '*', multiply)
183 BINARY_OPERATOR(Type, scalar, Type, *, '*', multiply)
184 BINARY_OPERATOR(Type, Type, scalar, /, '|', divide)
185 
186 BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, '*', multiply)
187 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, '*', multiply)
188 
189 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, '|', divide)
190 
191 
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193 
194 #define PRODUCT_OPERATOR(product, Op, OpFunc) \
195  \
196 template<class Type1, class Type2, class GeoMesh> \
197 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
198 operator Op \
199 ( \
200  const DimensionedField<Type1, GeoMesh>& f1, \
201  const DimensionedField<Type2, GeoMesh>& f2 \
202 ); \
203  \
204 template<class Type1, class Type2, class GeoMesh> \
205 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
206 operator Op \
207 ( \
208  const DimensionedField<Type1, GeoMesh>& f1, \
209  const tmp<DimensionedField<Type2, GeoMesh>>& tf2 \
210 ); \
211  \
212 template<class Type1, class Type2, class GeoMesh> \
213 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
214 operator Op \
215 ( \
216  const tmp<DimensionedField<Type1, GeoMesh>>& tf1, \
217  const DimensionedField<Type2, GeoMesh>& f2 \
218 ); \
219  \
220 template<class Type1, class Type2, class GeoMesh> \
221 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
222 operator Op \
223 ( \
224  const tmp<DimensionedField<Type1, GeoMesh>>& tf1, \
225  const tmp<DimensionedField<Type2, GeoMesh>>& tf2 \
226 ); \
227  \
228 template<class Form, class Type, class GeoMesh> \
229 tmp<DimensionedField<typename product<Type, Form>::type, GeoMesh>> \
230 operator Op \
231 ( \
232  const DimensionedField<Type, GeoMesh>& f1, \
233  const dimensioned<Form>& dvs \
234 ); \
235  \
236 template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
237 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
238 operator Op \
239 ( \
240  const DimensionedField<Type, GeoMesh>& f1, \
241  const VectorSpace<Form,Cmpt,nCmpt>& vs \
242 ); \
243  \
244 template<class Form, class Type, class GeoMesh> \
245 tmp<DimensionedField<typename product<Type, Form>::type, GeoMesh>> \
246 operator Op \
247 ( \
248  const tmp<DimensionedField<Type, GeoMesh>>& tf1, \
249  const dimensioned<Form>& dvs \
250 ); \
251  \
252 template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
253 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
254 operator Op \
255 ( \
256  const tmp<DimensionedField<Type, GeoMesh>>& tf1, \
257  const VectorSpace<Form,Cmpt,nCmpt>& vs \
258 ); \
259  \
260 template<class Form, class Type, class GeoMesh> \
261 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
262 operator Op \
263 ( \
264  const dimensioned<Form>& dvs, \
265  const DimensionedField<Type, GeoMesh>& f2 \
266 ); \
267  \
268 template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
269 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
270 operator Op \
271 ( \
272  const VectorSpace<Form,Cmpt,nCmpt>& vs, \
273  const DimensionedField<Type, GeoMesh>& f2 \
274 ); \
275  \
276 template<class Form, class Type, class GeoMesh> \
277 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
278 operator Op \
279 ( \
280  const dimensioned<Form>& dvs, \
281  const tmp<DimensionedField<Type, GeoMesh>>& tf2 \
282 ); \
283  \
284 template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
285 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
286 operator Op \
287 ( \
288  const VectorSpace<Form,Cmpt,nCmpt>& vs, \
289  const tmp<DimensionedField<Type, GeoMesh>>& tf2 \
290 );
291 
292 PRODUCT_OPERATOR(typeOfSum, +, add)
293 PRODUCT_OPERATOR(typeOfSum, -, subtract)
294 
295 PRODUCT_OPERATOR(outerProduct, *, outer)
296 PRODUCT_OPERATOR(crossProduct, ^, cross)
297 PRODUCT_OPERATOR(innerProduct, &, dot)
298 PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
299 
300 #undef PRODUCT_OPERATOR
301 
302 
303 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
304 
305 } // End namespace Foam
306 
307 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
308 
309 #include "undefFieldFunctionsM.H"
310 
311 // ************************************************************************* //
dimensioned< typename typeOfMag< Type >::type > sumMag(const DimensionedField< Type, GeoMesh > &f1)
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &f1)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1)
#define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)
type
Types of root.
Definition: Roots.H:52
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
tmp< DimensionedField< typename DimensionedField< Type, GeoMesh >::cmptType, GeoMesh >> cmptAv(const DimensionedField< Type, GeoMesh > &f1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Type gMin(const FieldField< Field, Type > &f)
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)
#define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc)
#define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpName, OpFunc)
void cross(FieldField< Field1, typename crossProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
#define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func)
Field< Type >::cmptType cmptType
Component type of the field elements.
void dotdot(FieldField< Field1, typename scalarProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
void subtract(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
void outer(FieldField< Field1, typename outerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
void dot(FieldField< Field1, typename innerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
MinMax< label > minMax(const labelHashSet &set)
Find the min/max values of labelHashSet.
Definition: hashSets.C:54
#define BINARY_FUNCTION(ReturnType, Type1, Type2, Func)
Type gSum(const FieldField< Field, Type > &f)
MinMax< Type > gMinMax(const FieldField< Field, Type > &f)
void negate(DimensionedField< Type, GeoMesh > &result, const DimensionedField< Type, GeoMesh > &f1)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:26
#define PRODUCT_OPERATOR(product, Op, OpFunc)
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Type gMax(const FieldField< Field, Type > &f)
scalarMinMax gMinMaxMag(const FieldField< Field, Type > &f)
dimensioned< Type > lerp(const dimensioned< Type > &a, const dimensioned< Type > &b, const scalar t)
typeOfMag< Type >::type gSumMag(const FieldField< Field, Type > &f)
Represents 0/1 range or concept. Used for tagged dispatch or clamping.
Definition: pTraits.H:84
symmTypeOfRank< typename pTraits< arg1 >::cmptType, arg2 *direction(pTraits< arg1 >::rank) >::type type
Definition: products.H:176
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
dimensioned< scalarMinMax > minMaxMag(const DimensionedField< Type, GeoMesh > &f1)
Type gAverage(const FieldField< Field, Type > &f)
BINARY_TYPE_FUNCTION_FS(Type, Type, MinMax< Type >, clip)
#define UNARY_REDUCTION_FUNCTION(ReturnType, Func, gFunc)
Scalar specific part of the implementation of DimensionedField.
#define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc, Dfunc)
#define TERNARY_TYPE_FUNCTION_FFS(ReturnType, Type1, Type2, Type3, Func)
void multiply(DimensionedField< Type, GeoMesh > &result, const DimensionedField< Type, GeoMesh > &f1, const DimensionedField< scalar, GeoMesh > &f2)
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:521
#define TERNARY_FUNCTION(ReturnType, Type1, Type2, Type3, Func)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
Namespace for OpenFOAM.
dimensionSet clamp(const dimensionSet &a, const dimensionSet &range)
Definition: dimensionSet.C:271
pTraits< typename pTraits< arg1 >::cmptType >::magType type
Definition: products.H:96