Line | Branch | Exec | Source |
---|---|---|---|
1 | // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | ||
2 | // vi: set et ts=4 sw=4 sts=4: | ||
3 | // | ||
4 | // SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder | ||
5 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
6 | // | ||
7 | /*! | ||
8 | * \file | ||
9 | * \ingroup Geometry | ||
10 | * \brief Compute the center point of a convex polytope geometry or a random-access container of corner points | ||
11 | */ | ||
12 | #ifndef DUMUX_GEOMETRY_CENTER_HH | ||
13 | #define DUMUX_GEOMETRY_CENTER_HH | ||
14 | |||
15 | #include <numeric> | ||
16 | |||
17 | namespace Dumux { | ||
18 | |||
19 | /*! | ||
20 | * \ingroup Geometry | ||
21 | * \brief The center of a given list of corners | ||
22 | */ | ||
23 | template<class Corners> | ||
24 | 60667085 | typename Corners::value_type center(const Corners& corners) | |
25 | { | ||
26 | using Pos = typename Corners::value_type; | ||
27 | 264599204 | auto center = std::accumulate(corners.begin(), corners.end(), Pos(0.0)); | |
28 |
2/4✓ Branch 1 taken 48764 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 48764 times.
✗ Branch 5 not taken.
|
65860836 | center /= corners.size(); |
29 | 60667085 | return center; | |
30 | } | ||
31 | |||
32 | } // end namespace Dumux | ||
33 | |||
34 | #endif | ||
35 |