dune-fem  2.8-git
space/common/dataprojection/tuple.hh
Go to the documentation of this file.
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 
11 
12 #include "dataprojection.hh"
13 #include "default.hh"
14 
15 namespace 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:
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
164  using hpDG::DefaultDataProjectionTuple ;
165 
166  } // namespace Fem
167 
168 } // namespace Dune
169 
170 #endif // #ifndef DUNE_FEM_HPDG_SPACE_COMMON_DATAPROJECTION_TUPLE_HH
Definition: bindguard.hh:11
Definition: forloop.hh:17
Abstract definition of the local restriction and prolongation of discrete functions.
Definition: dataprojection/dataprojection.hh:29
typename BasisFunctionSetType::EntityType EntityType
entity type
Definition: dataprojection/dataprojection.hh:38
typename DiscreteFunctionSpaceType::BasisFunctionSetType BasisFunctionSetType
basis function set type
Definition: dataprojection/dataprojection.hh:36
Local -projection for the restriction and prolongation of discrete functions.
Definition: space/common/dataprojection/default.hh:40
A DataProjection wrapping an arbitrary number of projection operators.
Definition: space/common/dataprojection/tuple.hh:34
Definition: space/common/dataprojection/tuple.hh:39
typename BaseType::EntityType EntityType
entity type
Definition: space/common/dataprojection/tuple.hh:49
DataProjectionTuple(Head &&head, Tail &&...tail)
Definition: space/common/dataprojection/tuple.hh:93
std::tuple< Head, Tail... > tuple_
Definition: space/common/dataprojection/tuple.hh:135
typename BaseType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
discrete function space type
Definition: space/common/dataprojection/tuple.hh:45
typename BaseType::BasisFunctionSetType BasisFunctionSetType
basis function set type
Definition: space/common/dataprojection/tuple.hh:47
void addToList(Communicator &comm)
()
Definition: space/common/dataprojection/tuple.hh:129
A DataProjection for managing an arbitrary number of discrete functions.
Definition: space/common/dataprojection/tuple.hh:152
DefaultDataProjectionTuple(DiscreteFunctions &... discreteFunctions)
Definition: space/common/dataprojection/tuple.hh:156
discrete function space