dune-mmesh (unstable)

common.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_MMESH_INTERFACE_COMMON_HH
4#define DUNE_MMESH_INTERFACE_COMMON_HH
5
10namespace Dune {
11
12namespace MMeshInterfaceImpl {
13
15template <typename HostEntity, int dim>
16static inline auto computeCGALIndices(const HostEntity& hostEntity) {
17 std::array<std::pair<std::size_t, std::size_t>, dim + 1> pairs;
18 for (std::size_t i = 0; i < dim + 1; ++i) {
19 auto i0 = (hostEntity.second + i + 1) % (dim + 2);
20 pairs[i].first = i0;
21 pairs[i].second = hostEntity.first->vertex(i0)->info().id;
22 }
23
24 std::sort(pairs.begin(), pairs.end(),
25 [](auto& a, auto& b) { return a.second < b.second; });
26
27 std::array<std::size_t, dim + 1> indices;
28 for (std::size_t i = 0; i < dim + 1; ++i) indices[i] = pairs[i].first;
29
30 assert(hostEntity.first->vertex(indices[0])->info().id <
31 hostEntity.first->vertex(indices[1])->info().id);
32
33 if constexpr (dim == 2)
34 assert(hostEntity.first->vertex(indices[1])->info().id <
35 hostEntity.first->vertex(indices[2])->info().id);
36
37 return indices;
38}
39
40} // namespace MMeshInterfaceImpl
41
42} // namespace Dune
43
44#endif
static auto computeCGALIndices(const HostEntity &hostEntity)
Return list of indices sorted by id.
Definition: common.hh:16
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Mar 17, 23:30, 2025)