1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
28 Combination-Reduction operation for a parallel run.
30 The information from all nodes is collected on the master node,
31 combined using the given combination function and the result is
32 broadcast to all nodes
34 \*---------------------------------------------------------------------------*/
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 #define EqOp(opName, op) \
48 template<class T1, class T2> \
53 void operator()(T1& x, const T2& y) const \
64 void operator()(T& x, const T& y) const \
73 EqOp(multiplyEq, x *= y)
74 EqOp(divideEq, x /= y)
75 EqOp(eqMag, x = mag(y))
76 EqOp(plusEqMagSqr, x += magSqr(y))
77 EqOp(maxEq, x = max(x, y))
78 EqOp(minEq, x = min(x, y))
79 EqOp(minMagSqrEq, x = (magSqr(x)<=magSqr(y) ? x : y))
80 EqOp(maxMagSqrEq, x = (magSqr(x)>=magSqr(y) ? x : y))
81 EqOp(andEq, x = (x && y))
82 EqOp(orEq, x = (x || y))
91 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
93 #define Op(opName, op) \
95 template<class T, class T1, class T2> \
100 T operator()(const T1& x, const T2& y) const \
106 template<class T1, class T2> \
111 T1 operator()(const T1& x, const T2& y) const \
122 T operator()(const T& x, const T& y) const \
134 Op(cmptMultiply, cmptMultiply(x, y))
135 Op(cmptDivide, cmptDivide(x, y))
136 Op(stabilise, stabilise(x, y))
139 Op(minMod, minMod(x, y))
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 } // End namespace Foam
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 // ************************************************************************* //