FieldReductionFunctions.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-2026 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 "UPstream.H"
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 #define G_REDUCTION_FUNCTION(ReturnType, gFunc, Func, rFunc) \
36  \
37  template<class Type> \
38  ReturnType gFunc \
39  ( \
40  const UList<Type>& f, \
41  const label comm = UPstream::worldComm \
42  );
43 
44 #define TMP_REDUCTION_FUNCTION(ReturnType, Func) \
45  \
46  template<class Type> \
47  ReturnType Func(const tmp<Field<Type>>& tf1);
48 
49 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
50 
51 template<class Type>
52 Type max(const UList<Type>& f);
53 
57 
58 template<class Type>
59 Type min(const UList<Type>& f);
60 
64 
65 template<class Type>
66 Type sum(const UList<Type>& f);
67 
71 
72 template<class Type>
73 Type maxMagSqr(const UList<Type>& f);
74 
78 
79 template<class Type>
80 Type minMagSqr(const UList<Type>& f);
81 
85 
86 template<class Type>
87 scalar sumProd(const UList<Type>& f1, const UList<Type>& f2);
88 
89 template<class Type>
90 scalar gSumProd
91 (
92  const UList<Type>& f1,
93  const UList<Type>& f2,
94  const label comm = UPstream::worldComm
95 );
96 
97 template<class Type>
98 Type sumCmptProd(const UList<Type>& f1, const UList<Type>& f2);
99 
100 template<class Type>
101 Type gSumCmptProd
102 (
103  const UList<Type>& f1,
104  const UList<Type>& f2,
105  const label comm = UPstream::worldComm
106 );
107 
108 template<class Type>
109 scalar sumSqr(const UList<Type>& f);
110 
114 
115 template<class Type>
116 scalar sumMag(const UList<Type>& f);
117 
121 
122 template<class Type>
123 Type sumCmptMag(const UList<Type>& f);
124 
128 
129 template<class Type>
130 Type average(const UList<Type>& f);
131 
132 template<class Type>
133 Type gAverage
134 (
135  const UList<Type>& f,
136  const label comm = UPstream::worldComm
137 );
138 
141 
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 
144 #undef G_REDUCTION_FUNCTION
145 #undef TMP_REDUCTION_FUNCTION
146 
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148 
149 } // End namespace Foam
150 
151 // ************************************************************************* //
#define TMP_REDUCTION_FUNCTION(ReturnType, Func)
#define G_REDUCTION_FUNCTION(ReturnType, gFunc, Func, rFunc)
static label worldComm
Default communicator (all processors)
Definition: UPstream.H:278
Namespace for OpenFOAM.
Type gMin(const UList< Type > &f, const label comm)
Type gAverage(const UList< Type > &f, const label comm)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
scalar gSumSqr(const UList< Type > &f, const label comm)
scalar gSumProd(const UList< Type > &f1, const UList< Type > &f2, const label comm)
dimensioned< Type > average(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dimensioned< scalar > sumMag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
Type sumCmptProd(const UList< Type > &f1, const UList< Type > &f2)
Type maxMagSqr(const UList< Type > &f)
Type gSum(const UList< Type > &f, const label comm)
Type gMaxMagSqr(const UList< Type > &f, const label comm)
scalar gSumMag(const UList< Type > &f, const label comm)
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
scalar sumProd(const UList< Type > &f1, const UList< Type > &f2)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
Type gMax(const UList< Type > &f, const label comm)
Type minMagSqr(const UList< Type > &f)
scalar sumSqr(const UList< Type > &f)
Type gMinMagSqr(const UList< Type > &f, const label comm)
Type gSumCmptMag(const UList< Type > &f, const label comm)
Type sumCmptMag(const UList< Type > &f)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
Type gSumCmptProd(const UList< Type > &f1, const UList< Type > &f2, const label comm)
labelList f(nPoints)