AMDiS 2.10
The Adaptive Multi-Dimensional Simulation Toolbox
NodeIndices.hpp
1#pragma once
2
3#include <dune/common/rangeutilities.hh>
4
5#include <amdis/common/Concepts.hpp>
6#include <amdis/typetree/MultiIndex.hpp>
7#include <amdis/utility/MappedRangeView.hpp>
8
9namespace AMDiS
10{
12 template <class LocalView, class Node>
13 auto nodeIndices(LocalView const& localView, Node const& node)
14 {
15 static_assert(Concepts::LocalView<LocalView>, "");
16 static_assert(Concepts::BasisTree<Node, typename LocalView::GridView>, "");
17
18 return mappedRangeView(Dune::range(node.size()), [&](std::size_t j) -> typename LocalView::MultiIndex {
19 return localView.index(node.localIndex(j));
20 });
21 }
22
24 template <class LocalView>
25 auto nodeIndices(LocalView const& localView)
26 {
27 static_assert(Concepts::LocalView<LocalView>, "");
28
29 return mappedRangeView(Dune::range(localView.size()), [&](std::size_t i) -> typename LocalView::MultiIndex {
30 return localView.index(i);
31 });
32 }
33
34
36 template <class LocalView, class Node>
37 std::size_t nodeIndexCount(LocalView const& /*localView*/, Node const& node)
38 {
39 return node.size();
40 }
41
43 template <class LocalView>
44 std::size_t nodeIndexCount(LocalView const& localView)
45 {
46 return localView.size();
47 }
48
49} // end namespace AMDiS
constexpr bool MultiIndex
A multi-index type.
Definition: Concepts.hpp:149
constexpr bool LocalView
A Dune::Functions::LocalView type.
Definition: Concepts.hpp:181