1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 Combination-Reduction operation for a parallel run. The
29 information from all nodes is collected on the master node,
30 combined using the given combination function and the result is
31 broadcast to all nodes
34 \*---------------------------------------------------------------------------*/
36 #ifndef PstreamCombineReduceOps_H
37 #define PstreamCombineReduceOps_H
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 template <class T, class CombineOp>
52 const List<Pstream::commsStruct>& comms,
57 Pstream::combineGather(comms, Value, cop);
58 Pstream::combineScatter(comms, Value);
62 template <class T, class CombineOp>
63 void combineReduce(T& Value, const CombineOp& cop)
65 if (Pstream::nProcs() < Pstream::nProcsSimpleSum())
67 Pstream::combineGather(Pstream::linearCommunication(), Value, cop);
68 Pstream::combineScatter(Pstream::linearCommunication(), Value);
72 Pstream::combineGather(Pstream::treeCommunication(), Value, cop);
73 Pstream::combineScatter(Pstream::treeCommunication(), Value);
78 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
80 } // End namespace Foam
82 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
86 // ************************************************************************* //