AMDiS  0.3
The Adaptive Multi-Dimensional Simulation Toolbox
TreeContainerTrafo.hpp
1 #pragma once
2 
3 #include <amdis/common/RecursiveForEach.hpp>
4 #include <amdis/common/RecursiveMap.hpp>
5 #include <amdis/typetree/TreeContainer.hpp>
6 
7 namespace AMDiS {
8 namespace Recursive {
9 
10 // specializations of recursive utilities for TreeContainer entries
11 
12 template <class Value>
13 struct Apply<TypeTree::LeafNodeStorage<Value>>
14 {
15  template <class F, class VC>
16  static auto impl(F&& f, VC const& vc)
17  {
19  Recursive::apply(f,vc.value())};
20  }
21 };
22 
23 template <class Value, class Container>
24 struct Apply<TypeTree::InnerNodeStorage<Value,Container>>
25 {
26  template <class F, class VC>
27  static auto impl(F&& f, VC const& vc)
28  {
30  Recursive::apply(f,vc.value()),
31  Recursive::apply(f,vc.container())};
32  }
33 };
34 
35 template <class Container>
36 struct Apply<TypeTree::TreeContainerStorage<Container>>
37 {
38  template <class F, class TC>
39  static auto impl(F&& f, TC const& c)
40  {
41  return TypeTree::TreeContainerStorage{Recursive::apply(f,c.data())};
42  }
43 };
44 
45 // -------------------------------------------------------------------------
46 
47 
48 template <class Value>
49 struct ForEach<TypeTree::LeafNodeStorage<Value>>
50 {
51  template <class VC, class F>
52  static void impl(VC&& vc, F&& f)
53  {
54  Recursive::forEach(vc.value(),f);
55  }
56 };
57 
58 template <class Value, class Container>
59 struct ForEach<TypeTree::InnerNodeStorage<Value,Container>>
60 {
61  template <class VC, class F>
62  static void impl(VC&& vc, F&& f)
63  {
64  Recursive::forEach(vc.value(),f);
65  Recursive::forEach(vc.container(),f);
66  }
67 };
68 
69 template <class Container>
70 struct ForEach<TypeTree::TreeContainerStorage<Container>>
71 {
72  template <class F, class TC>
73  static void impl(TC&& c, F&& f)
74  {
75  Recursive::forEach(c.data(),f);
76  }
77 };
78 
79 }} // end namespace AMDiS::Recursive
Default implementation of the recursive forEach function.
Definition: RecursiveForEach.hpp:21
Contains all classes needed for solving linear and non linear equation systems.
Definition: AdaptBase.hpp:6
Definition: TreeContainer.hpp:53
Vector data-structure with tree-path index access and hierarchic structure given by the Container tem...
Definition: TreeContainer.hpp:169
Default implementation of the recursive map function.
Definition: RecursiveApply.hpp:16
Definition: TreeContainer.hpp:23