libMesh
Loading...
Searching...
No Matches
parallel_algorithms.h
Go to the documentation of this file.
1
2// The libMesh Finite Element Library.
3// Copyright (C) 2002-2026 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
4
5// This library is free software; you can redistribute it and/or
6// modify it under the terms of the GNU Lesser General Public
7// License as published by the Free Software Foundation; either
8// version 2.1 of the License, or (at your option) any later version.
9
10// This library is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13// Lesser General Public License for more details.
14
15// You should have received a copy of the GNU Lesser General Public
16// License along with this library; if not, write to the Free Software
17// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19
20
21#ifndef LIBMESH_PARALLEL_ALGORITHMS_H
22#define LIBMESH_PARALLEL_ALGORITHMS_H
23
24// The library configuration options
25#include "libmesh/libmesh_config.h"
26
27// C++ headers
28#include <numeric>
29
30// Workaround incomplete C++17 support in some compilers/libs
31
32#ifdef LIBMESH_HAVE_CXX17_TRANSFORM_REDUCE
33template <typename InputIt, class T, class BinaryOp, class UnaryOp>
34T libmesh_transform_reduce(InputIt begin, InputIt end, T init, BinaryOp reduce, UnaryOp transform)
35{
36 return std::transform_reduce(begin, end, init, reduce, transform);
37}
38#else
39template <typename InputIt, class T, class BinaryOp, class UnaryOp>
40T libmesh_transform_reduce(InputIt begin, InputIt end, T init, BinaryOp reduce, UnaryOp transform)
41{
42 // Reuse init as returnval.
43 //
44 // Don't try to do any fancy reduce() reordering/vectorization;
45 // people who want that can get a real compiler.
46 for (auto it = begin; it != end; ++it)
47 init = reduce(init, transform(*it));
48 return init;
49}
50#endif // LIBMESH_HAVE_CXX17_TRANSFORM_REDUCE
51
52#endif // LIBMESH_PARALLEL_ALGORITHMS_H
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
T libmesh_transform_reduce(InputIt begin, InputIt end, T init, BinaryOp reduce, UnaryOp transform)