3#ifndef DUNE_MMESH_GRID_COMMON_HH
4#define DUNE_MMESH_GRID_COMMON_HH
15 std::size_t operator() (
const std::vector<std::size_t>& a)
const
17 std::size_t hash = std::hash<std::size_t>{}(a[0]);
18 for ( std::size_t i = 1; i < a.size(); ++i )
19 hash = hash ^ (std::hash<std::size_t>{}(a[i]) << i);
26 template< std::
size_t dim >
27 std::size_t operator() (
const std::array<std::size_t, dim>& a)
const
29 std::size_t hash = std::hash<std::size_t>{}(a[0]);
30 for ( std::size_t i = 1; i < a.size(); ++i )
31 hash = hash ^ (std::hash<std::size_t>{}(a[i]) << i);
43 sort_indices(std::array< std::size_t, dim > ids)
46 bool operator()(std::size_t i, std::size_t j)
const
48 return ids_[i] < ids_[j];
52 std::array< std::size_t, dim > ids_;
56 template<
int dim,
typename ctype =
double >
57 static inline auto&
ref()
59 return ReferenceElements<ctype, dim>::simplex();
63 template <
typename HostEntity,
int dim >
66 std::array< std::size_t, dim+1 > ids, indices;
67 for ( std::size_t i = 0; i < dim+1; ++i )
69 ids[i] = hostEntity->vertex( i )->info().id;
72 std::sort(indices.begin(), indices.end(), sort_indices<dim+1>(ids));
78 template< std::
size_t dim >
79 static inline std::size_t duneFacetToCgalSecond (
const std::size_t duneFacet,
const std::array< std::size_t, dim+1 >& cgalIndex )
82 for ( std::size_t k = 0; k < dim; ++k )
83 sum += cgalIndex[ ref<dim>().subEntity(duneFacet, 1, k, dim) ];
85 static constexpr int max = (dim == 2) ? 3 : 6;
90 template< std::
size_t dim,
typename HostFacet >
91 static inline std::size_t cgalFacetToDuneFacet (
const HostFacet& facet )
93 const auto& i = facet.second;
94 const auto& cgalIndex = facet.first->info().cgalIndex;
97 auto duneIndex = cgalIndex;
98 for ( std::size_t k = 0; k < dim+1; ++k )
99 duneIndex[ cgalIndex[k] ] = k;
102 for ( std::size_t k = 0; k < dim; ++k )
103 sum += duneIndex[ (i+k+1)%(dim+1) ];
105 static const int thr = (dim == 2) ? 1 : 3;
109 template< std::
size_t dim,
typename HostEdge >
110 static inline std::size_t cgalEdgeToDuneEdge(
const HostEdge& cgalEdge )
112 const auto& c = cgalEdge.first;
113 const auto& i = cgalEdge.second;
114 const auto& j = cgalEdge.third;
116 const auto& cgalIndex = c->info().cgalIndex;
119 auto duneIndex = cgalIndex;
120 for ( std::size_t k = 0; k < dim+1; ++k )
121 duneIndex[ cgalIndex[k] ] = k;
123 auto i0 = duneIndex[ i ];
124 auto j0 = duneIndex[ j ];
static auto & ref()
return reference element
Definition: common.hh:57
static auto computeCGALIndices(const HostEntity &hostEntity)
Return list of indices sorted by id.
Definition: common.hh:64
Hash a UInt array.
Definition: common.hh:25
Hash a UInt vector.
Definition: common.hh:14