dune-mmesh (1.4)

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{
12
13 namespace MMeshInterfaceImpl
14 {
15
17 template < typename HostEntity, int dim >
18 static inline auto computeCGALIndices( const HostEntity& hostEntity )
19 {
20 std::array< std::pair< std::size_t, std::size_t >, dim+1 > pairs;
21 for ( std::size_t i = 0; i < dim+1; ++i )
22 {
23 auto i0 = (hostEntity.second+i+1)%(dim+2);
24 pairs[i].first = i0;
25 pairs[i].second = hostEntity.first->vertex( i0 )->info().id;
26 }
27
28 std::sort(pairs.begin(), pairs.end(), [](auto& a, auto& b){ return a.second < b.second; });
29
30 std::array< std::size_t, dim+1 > indices;
31 for ( std::size_t i = 0; i < dim+1; ++i )
32 indices[i] = pairs[i].first;
33
34 assert( hostEntity.first->vertex(indices[0])->info().id < hostEntity.first->vertex(indices[1])->info().id );
35
36 if constexpr (dim == 2)
37 assert( hostEntity.first->vertex(indices[1])->info().id < hostEntity.first->vertex(indices[2])->info().id );
38
39 return indices;
40 }
41
42 }
43
44}
45
46#endif
static auto computeCGALIndices(const HostEntity &hostEntity)
Return list of indices sorted by id.
Definition: common.hh:18
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Apr 6, 22:49, 2025)