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-2018 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
90  <typename DimensionedField<Type, GeoMesh>::cmptType, GeoMesh>
91 >
92 cmptAv(const DimensionedField<Type, GeoMesh>& df);
93 
94 template<class Type, class GeoMesh>
95 tmp
96 <
97  DimensionedField
98  <typename DimensionedField<Type, GeoMesh>::cmptType, GeoMesh>
99 >
100 cmptAv(const tmp<DimensionedField<Type, GeoMesh>>& tdf);
101 
102 
103 #define UNARY_REDUCTION_FUNCTION(returnType, func, dfunc) \
104  \
105 template<class Type, class GeoMesh> \
106 dimensioned<returnType> func \
107 ( \
108  const DimensionedField<Type, GeoMesh>& df \
109 ); \
110 template<class Type, class GeoMesh> \
111 dimensioned<returnType> func \
112 ( \
113  const tmp<DimensionedField<Type, GeoMesh>>& tdf1 \
114 );
115 
121 
122 #undef UNARY_REDUCTION_FUNCTION
123 
124 
125 BINARY_FUNCTION(Type, Type, Type, max)
126 BINARY_FUNCTION(Type, Type, Type, min)
127 BINARY_FUNCTION(Type, Type, Type, cmptMultiply)
128 BINARY_FUNCTION(Type, Type, Type, cmptDivide)
129 
130 BINARY_TYPE_FUNCTION(Type, Type, Type, max)
131 BINARY_TYPE_FUNCTION(Type, Type, Type, min)
132 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
133 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
134 
135 
136 // * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * //
137 
138 UNARY_OPERATOR(Type, Type, -, negate, transform)
139 
140 BINARY_OPERATOR(Type, Type, scalar, *, '*', multiply)
141 BINARY_OPERATOR(Type, scalar, Type, *, '*', multiply)
142 BINARY_OPERATOR(Type, Type, scalar, /, '|', divide)
143 
144 BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, '*', multiply)
145 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, '*', multiply)
146 
147 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, '|', divide)
148 
149 
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 
152 #define PRODUCT_OPERATOR(product, op, opFunc) \
153  \
154 template<class Type1, class Type2, class GeoMesh> \
155 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
156 operator op \
157 ( \
158  const DimensionedField<Type1, GeoMesh>& df1, \
159  const DimensionedField<Type2, GeoMesh>& df2 \
160 ); \
161  \
162 template<class Type1, class Type2, class GeoMesh> \
163 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
164 operator op \
165 ( \
166  const DimensionedField<Type1, GeoMesh>& df1, \
167  const tmp<DimensionedField<Type2, GeoMesh>>& tdf2 \
168 ); \
169  \
170 template<class Type1, class Type2, class GeoMesh> \
171 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
172 operator op \
173 ( \
174  const tmp<DimensionedField<Type1, GeoMesh>>& tdf1, \
175  const DimensionedField<Type2, GeoMesh>& df2 \
176 ); \
177  \
178 template<class Type1, class Type2, class GeoMesh> \
179 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh>> \
180 operator op \
181 ( \
182  const tmp<DimensionedField<Type1, GeoMesh>>& tdf1, \
183  const tmp<DimensionedField<Type2, GeoMesh>>& tdf2 \
184 ); \
185  \
186 template<class Form, class Type, class GeoMesh> \
187 tmp<DimensionedField<typename product<Type, Form>::type, GeoMesh>> \
188 operator op \
189 ( \
190  const DimensionedField<Type, GeoMesh>& df1, \
191  const dimensioned<Form>& dvs \
192 ); \
193  \
194 template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
195 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
196 operator op \
197 ( \
198  const DimensionedField<Type, GeoMesh>& df1, \
199  const VectorSpace<Form,Cmpt,nCmpt>& vs \
200 ); \
201  \
202 template<class Form, class Type, class GeoMesh> \
203 tmp<DimensionedField<typename product<Type, Form>::type, GeoMesh>> \
204 operator op \
205 ( \
206  const tmp<DimensionedField<Type, GeoMesh>>& tdf1, \
207  const dimensioned<Form>& dvs \
208 ); \
209  \
210 template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
211 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
212 operator op \
213 ( \
214  const tmp<DimensionedField<Type, GeoMesh>>& tdf1, \
215  const VectorSpace<Form,Cmpt,nCmpt>& vs \
216 ); \
217  \
218 template<class Form, class Type, class GeoMesh> \
219 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
220 operator op \
221 ( \
222  const dimensioned<Form>& dvs, \
223  const DimensionedField<Type, GeoMesh>& df1 \
224 ); \
225  \
226 template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
227 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
228 operator op \
229 ( \
230  const VectorSpace<Form,Cmpt,nCmpt>& vs, \
231  const DimensionedField<Type, GeoMesh>& df1 \
232 ); \
233  \
234 template<class Form, class Type, class GeoMesh> \
235 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
236 operator op \
237 ( \
238  const dimensioned<Form>& dvs, \
239  const tmp<DimensionedField<Type, GeoMesh>>& tdf1 \
240 ); \
241  \
242 template<class Form, class Cmpt, direction nCmpt, class Type, class GeoMesh> \
243 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh>> \
244 operator op \
245 ( \
246  const VectorSpace<Form,Cmpt,nCmpt>& vs, \
247  const tmp<DimensionedField<Type, GeoMesh>>& tdf1 \
248 );
249 
250 PRODUCT_OPERATOR(typeOfSum, +, add)
251 PRODUCT_OPERATOR(typeOfSum, -, subtract)
252 
253 PRODUCT_OPERATOR(outerProduct, *, outer)
254 PRODUCT_OPERATOR(crossProduct, ^, cross)
255 PRODUCT_OPERATOR(innerProduct, &, dot)
256 PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
257 
258 #undef PRODUCT_OPERATOR
259 
260 
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262 
263 } // End namespace Foam
264 
265 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266 
267 #include "undefFieldFunctionsM.H"
268 
269 // ************************************************************************* //
void divide(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
scalar gSumMag(const FieldField< Field, Type > &f)
#define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)
void multiply(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Type gMin(const FieldField< Field, Type > &f)
tmp< DimensionedField< typename DimensionedField< Type, GeoMesh >::cmptType, GeoMesh >> cmptAv(const DimensionedField< Type, GeoMesh > &df)
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)
#define PRODUCT_OPERATOR(product, op, 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)
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 > &)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
#define BINARY_FUNCTION(ReturnType, Type1, Type2, Func)
Type gSum(const FieldField< Field, Type > &f)
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
dimensioned< scalar > magSqr(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)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
symmTypeOfRank< typename pTraits< arg1 >::cmptType, arg2 *direction(pTraits< arg1 >::rank) >::type type
Definition: products.H:136
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
void negate(FieldField< Field, Type > &res, const FieldField< Field, Type > &f)
Type gAverage(const FieldField< Field, Type > &f)
#define UNARY_REDUCTION_FUNCTION(returnType, func, dfunc)
dimensioned< scalar > mag(const dimensioned< Type > &)
Scalar specific part of the implementation of DimensionedField.
#define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc, Dfunc)
Namespace for OpenFOAM.
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:477
dimensioned< scalar > sumMag(const DimensionedField< Type, GeoMesh > &df)