All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DimensionedFieldFunctions.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "DimensionedScalarField.H"
27 
28 #define TEMPLATE template<class Type, class GeoMesh>
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 
36 // * * * * * * * * * * * * * * * Global functions * * * * * * * * * * * * * //
37 
38 template<class Type, class GeoMesh, direction r>
39 tmp<DimensionedField<typename powProduct<Type, r>::type, GeoMesh>>
40 pow
41 (
42  const DimensionedField<Type, GeoMesh>& df,
44 );
45 
46 template<class Type, class GeoMesh, direction r>
47 tmp<DimensionedField<typename powProduct<Type, r>::type, GeoMesh>>
48 pow
49 (
50  const tmp<DimensionedField<Type, GeoMesh>>& tdf,
52 );
53 
54 template<class Type, class GeoMesh>
55 tmp<DimensionedField<typename outerProduct<Type, Type>::type, GeoMesh>>
56 sqr(const DimensionedField<Type, GeoMesh>& df);
57 
58 template<class Type, class GeoMesh>
59 tmp<DimensionedField<typename outerProduct<Type, Type>::type, GeoMesh>>
60 sqr(const tmp<DimensionedField<Type, GeoMesh>>& tdf);
61 
62 template<class Type, class GeoMesh>
63 tmp<DimensionedField<scalar, GeoMesh>> magSqr
64 (
65  const DimensionedField<Type, GeoMesh>& df
66 );
67 
68 template<class Type, class GeoMesh>
69 tmp<DimensionedField<scalar, GeoMesh>> magSqr
70 (
71  const tmp<DimensionedField<Type, GeoMesh>>& tdf
72 );
73 
74 template<class Type, class GeoMesh>
75 tmp<DimensionedField<scalar, GeoMesh>> mag
76 (
77  const DimensionedField<Type, GeoMesh>& df
78 );
79 
80 template<class Type, class GeoMesh>
81 tmp<DimensionedField<scalar, GeoMesh>> mag
82 (
83  const tmp<DimensionedField<Type, GeoMesh>>& tdf
84 );
85 
86 template<class Type, class GeoMesh>
87 tmp
88 <
89  DimensionedField
91 >
92 cmptAv(const DimensionedField<Type, GeoMesh>& df);
93 
94 template<class Type, class GeoMesh>
95 tmp
96 <
97  DimensionedField
99 >
100 cmptAv(const tmp<DimensionedField<Type, GeoMesh>>& tdf);
101 
103 
104 
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 
123 
124 #undef UNARY_REDUCTION_FUNCTION
125 
126 
127 BINARY_FUNCTION(Type, Type, Type, max)
128 BINARY_FUNCTION(Type, Type, Type, min)
129 BINARY_FUNCTION(Type, Type, Type, cmptMultiply)
130 BINARY_FUNCTION(Type, Type, Type, cmptDivide)
131 
132 BINARY_TYPE_FUNCTION(Type, Type, Type, max)
133 BINARY_TYPE_FUNCTION(Type, Type, Type, min)
136 
137 
138 // * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * //
139 
141 
142 BINARY_OPERATOR(Type, Type, scalar, *, '*', multiply)
143 BINARY_OPERATOR(Type, scalar, Type, *, '*', multiply)
144 BINARY_OPERATOR(Type, Type, scalar, /, '|', divide)
145 
146 BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, '*', multiply)
147 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, '*', multiply)
148 
149 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, '|', divide)
150 
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 #define PRODUCT_OPERATOR(product, op, opFunc) \
155  \
156 template<class Type1, class Type2, class GeoMesh> \
157 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
158 operator op \
159 ( \
160  const DimensionedField<Type1, GeoMesh>& df1, \
161  const DimensionedField<Type2, GeoMesh>& df2 \
162 ); \
163  \
164 template<class Type1, class Type2, class GeoMesh> \
165 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
166 operator op \
167 ( \
168  const DimensionedField<Type1, GeoMesh>& df1, \
169  const tmp<DimensionedField<Type2, GeoMesh>>& tdf2 \
170 ); \
171  \
172 template<class Type1, class Type2, class GeoMesh> \
173 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
174 operator op \
175 ( \
176  const tmp<DimensionedField<Type1, GeoMesh>>& tdf1, \
177  const DimensionedField<Type2, GeoMesh>& df2 \
178 ); \
179  \
180 template<class Type1, class Type2, class GeoMesh> \
181 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
182 operator op \
183 ( \
184  const tmp<DimensionedField<Type1, GeoMesh>>& tdf1, \
185  const tmp<DimensionedField<Type2, GeoMesh>>& tdf2 \
186 ); \
187  \
188 template<class Form, class Type, class GeoMesh> \
189 tmp<DimensionedField<typename product<Type, Form>::type, GeoMesh>> \
190 operator op \
191 ( \
192  const DimensionedField<Type, GeoMesh>& df1, \
193  const dimensioned<Form>& dvs \
194 ); \
195  \
196 template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
197 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
198 operator op \
199 ( \
200  const DimensionedField<Type, GeoMesh>& df1, \
201  const VectorSpace<Form,Cmpt,nCmpt>& vs \
202 ); \
203  \
204 template<class Form, class Type, class GeoMesh> \
205 tmp<DimensionedField<typename product<Type, Form>::type, GeoMesh>> \
206 operator op \
207 ( \
208  const tmp<DimensionedField<Type, GeoMesh>>& tdf1, \
209  const dimensioned<Form>& dvs \
210 ); \
211  \
212 template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
213 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
214 operator op \
215 ( \
216  const tmp<DimensionedField<Type, GeoMesh>>& tdf1, \
217  const VectorSpace<Form,Cmpt,nCmpt>& vs \
218 ); \
219  \
220 template<class Form, class Type, class GeoMesh> \
221 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
222 operator op \
223 ( \
224  const dimensioned<Form>& dvs, \
225  const DimensionedField<Type, GeoMesh>& df1 \
226 ); \
227  \
228 template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
229 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
230 operator op \
231 ( \
232  const VectorSpace<Form,Cmpt,nCmpt>& vs, \
233  const DimensionedField<Type, GeoMesh>& df1 \
234 ); \
235  \
236 template<class Form, class Type, class GeoMesh> \
237 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
238 operator op \
239 ( \
240  const dimensioned<Form>& dvs, \
241  const tmp<DimensionedField<Type, GeoMesh>>& tdf1 \
242 ); \
243  \
244 template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
245 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
246 operator op \
247 ( \
248  const VectorSpace<Form,Cmpt,nCmpt>& vs, \
249  const tmp<DimensionedField<Type, GeoMesh>>& tdf1 \
250 );
251 
252 PRODUCT_OPERATOR(typeOfSum, +, add)
253 PRODUCT_OPERATOR(typeOfSum, -, subtract)
254 
255 PRODUCT_OPERATOR(outerProduct, *, outer)
256 PRODUCT_OPERATOR(crossProduct, ^, cross)
257 PRODUCT_OPERATOR(innerProduct, &, dot)
258 PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
259 
260 #undef PRODUCT_OPERATOR
261 
262 
263 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
264 
265 } // End namespace Foam
266 
267 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268 
269 #include "undefFieldFunctionsM.H"
270 
271 // ************************************************************************* //
#define BINARY_FUNCTION(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)
#define PRODUCT_OPERATOR(product, op, opFunc)
Scalar specific part of the implementation of DimensionedField.
Field< Type >::cmptType cmptType
Component type of the elements of the field.
symmTypeOfRank< typename pTraits< arg1 >::cmptType, arg2 *direction(pTraits< arg1 >::rank) >::type type
Definition: products.H:136
Namespace for OpenFOAM.
void negate(FieldField< Field, Type > &res, const FieldField< Field, Type > &f)
Type gSum(const FieldField< Field, Type > &f)
scalar gSumMag(const FieldField< Field, Type > &f)
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 > average(const DimensionedField< Type, GeoMesh > &df)
UNARY_FUNCTION(Type, Type, cmptMag, cmptMag)
void dot(FieldField< Field1, typename innerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
void divide(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
tmp< DimensionedField< typename DimensionedField< Type, GeoMesh >::cmptType, GeoMesh >> cmptAv(const DimensionedField< Type, GeoMesh > &df)
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:504
dimensioned< scalar > mag(const dimensioned< Type > &)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
dimensionSet cmptMag(const dimensionSet &)
Definition: dimensionSet.C:296
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
Type gAverage(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)
dimensioned< scalar > magSqr(const dimensioned< Type > &)
void multiply(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
Type gMax(const FieldField< Field, Type > &f)
void outer(FieldField< Field1, typename outerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
dimensioned< scalar > sumMag(const DimensionedField< Type, GeoMesh > &df)