DUNE-FEM (unstable)

tuple.hh
1#ifndef DUNE_FEM_HPDG_SPACE_COMMON_DATAPROJECTION_TUPLE_HH
2#define DUNE_FEM_HPDG_SPACE_COMMON_DATAPROJECTION_TUPLE_HH
3
4#include <cstddef>
5
6#include <tuple>
7#include <utility>
8#include <vector>
9
10#include <dune/fem/common/forloop.hh>
11
12#include "dataprojection.hh"
13#include "default.hh"
14
15namespace Dune
16{
17
18 namespace Fem
19 {
20
21 namespace hpDG
22 {
23
24 // DataProjectionTuple
25 // -------------------
26
33 template< class... DataProjections >
35
36 template< class Head, class... Tail >
37 class DataProjectionTuple< Head, Tail... >
38 : public DataProjection< typename Head::DiscreteFunctionSpaceType, DataProjectionTuple< Head, Tail... > >
39 {
40 using ThisType = DataProjectionTuple< Head, Tail... >;
41 using BaseType = DataProjection< typename Head::DiscreteFunctionSpaceType, DataProjectionTuple< Head, Tail... > >;
42
43 public:
45 using DiscreteFunctionSpaceType = typename BaseType::DiscreteFunctionSpaceType;
47 using BasisFunctionSetType = typename BaseType::BasisFunctionSetType;
49 using EntityType = typename BaseType::EntityType;
50
51 private:
52 template< int i >
53 struct Operation
54 {
55 static void apply ( const EntityType &entity,
56 const BasisFunctionSetType &prior,
57 const BasisFunctionSetType &present,
58 const std::vector< std::size_t > &origin,
59 const std::vector< std::size_t > &destination,
60 std::tuple< Head, Tail... > &tuple )
61 {
62 std::get< i >( tuple )( entity, prior, present, origin, destination );
63 }
64 };
65
66 template< int i >
67 struct Project
68 {
69 template <class TemporaryStorage>
70 static void apply ( TemporaryStorage& tmp,
71 std::tuple< Head, Tail... > &tuple )
72 {
73 std::get< i >( tuple )( tmp );
74 }
75 };
76
77 template< int i >
78 struct AddToList
79 {
80 template< class Communicator >
81 static void apply ( Communicator &comm,
82 std::tuple< Head, Tail... > &tuple )
83 {
84 std::get< i >( tuple ).addToList( comm );
85 }
86 };
87
88 public:
93 DataProjectionTuple ( Head &&head, Tail &&...tail )
94 : tuple_( std::forward< Head >( head ), std::forward< Tail >( tail )... )
95 {}
96
99#ifndef DOXYGEN
100
101 DataProjectionTuple ( const ThisType & ) = delete;
102
103 DataProjectionTuple ( ThisType && ) = default;
104
105 ThisType &operator= ( const ThisType & ) = delete;
106
107 ThisType &operator= ( ThisType && ) = default;
108
109#endif // #ifndef DOXYGEN
110
112 void operator() ( const EntityType &entity,
113 const BasisFunctionSetType &prior,
114 const BasisFunctionSetType &present,
115 const std::vector< std::size_t > &origin,
116 const std::vector< std::size_t > &destination )
117 {
118 Dune::Fem::ForLoop< Operation, 0, sizeof...( Tail ) >::apply( entity, prior, present, origin, destination, tuple_ );
119 }
120
121 template <class TemporaryStorage>
122 void operator () ( TemporaryStorage& tmp )
123 {
124 Dune::Fem::ForLoop< Project, 0, sizeof...( Tail ) >::apply( tmp, tuple_ );
125 }
126
128 template< class Communicator >
129 void addToList ( Communicator &comm )
130 {
131 Dune::Fem::ForLoop< AddToList, 0, sizeof...( Tail ) >::apply( comm, tuple_ );
132 }
133
134 protected:
135 std::tuple< Head, Tail... > tuple_;
136 };
137
138
139
140 // DefaultDataProjectionTuple
141 // --------------------------
142
149 template< class... DiscreteFunctions >
151 : public DataProjectionTuple< DefaultDataProjection< DiscreteFunctions >... >
152 {
154
155 public:
156 explicit DefaultDataProjectionTuple ( DiscreteFunctions &... discreteFunctions )
157 : BaseType( DefaultDataProjection< DiscreteFunctions >( discreteFunctions )... )
158 {}
159 };
160
161 } // namespace hpDG
162
163 // forward types to Fem namespace for convenience
165
166 } // namespace Fem
167
168} // namespace Dune
169
170#endif // #ifndef DUNE_FEM_HPDG_SPACE_COMMON_DATAPROJECTION_TUPLE_HH
A DataProjection wrapping an arbitrary number of projection operators.
Definition: tuple.hh:34
Abstract definition of the local restriction and prolongation of discrete functions.
Definition: dataprojection.hh:29
A DataProjection for managing an arbitrary number of discrete functions.
Definition: tuple.hh:152
Local -projection for the restriction and prolongation of discrete functions.
Definition: default.hh:40
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integer_sequence< T, II... > tail(std::integer_sequence< T, I0, II... >)
For a sequence [head,tail...) return the tail sequence.
Definition: integersequence.hh:58
constexpr std::integral_constant< T, I0 > head(std::integer_sequence< T, I0, II... >)
For a sequence [head,tail...) return the single head element.
Definition: integersequence.hh:53
STL namespace.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 27, 22:29, 2024)