dune-fem  2.4.1-rc
operator/matrix/functor.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_OPERATOR_MATRIX_FUNCTOR_HH
2 #define DUNE_FEM_OPERATOR_MATRIX_FUNCTOR_HH
3 
4 #include <utility>
5 
6 
7 namespace Dune
8 {
9 
10  namespace Fem
11  {
12 
13  // IndexFunctor
14  // ------------
15 
16  template< class Functor, class Index >
17  struct IndexFunctor
18  {
19  constexpr IndexFunctor ( Functor functor, int localIndex, Index globalIndex )
20  : functor_( functor ),
21  localIndex_( localIndex ),
22  globalIndex_( globalIndex )
23  {}
24 
25  template< class GlobalKey >
26  void operator() ( const int localKey, const GlobalKey &globalKey )
27  {
28  functor_( std::make_pair( localIndex_, localKey ), std::make_pair( globalIndex_, globalKey ) );
29  }
30 
31  private:
32  Functor functor_;
33  int localIndex_;
34  Index globalIndex_;
35  };
36 
37 
38  // PairFunctor
39  // -----------
40 
41  template< class Mapper, class Entity, class Functor >
42  struct PairFunctor
43  {
44  PairFunctor ( const Mapper &mapper, const Entity &entity, Functor functor )
45  : mapper_( mapper ), entity_( entity ), functor_( std::move( functor ) )
46  {}
47 
48  template< class GlobalKey >
49  void operator() ( const int localKey, const GlobalKey &globalKey )
50  {
51  mapper_.mapEach( entity_, IndexFunctor< Functor, GlobalKey >( functor_, localKey, globalKey ) );
52  }
53 
54  private:
55  const Mapper &mapper_;
56  const Entity &entity_;
57  Functor functor_;
58  };
59 
60 
61  // makeRowFunctor
62  // --------------
63 
64  template< class Mapper, class Entity, class Functor >
65  PairFunctor< Mapper, Entity, Functor > makePairFunctor ( const Mapper &mapper, const Entity &entity, Functor functor )
66  {
67  return PairFunctor< Mapper, Entity, Functor >( mapper, entity, std::move( functor ) );
68  }
69 
70  } // namespace Fem
71 
72 } // namespace Dune
73 
74 #endif // #ifndef DUNE_FEM_OPERATOR_MATRIX_FUNCTOR_HH
void operator()(const int localKey, const GlobalKey &globalKey)
Definition: operator/matrix/functor.hh:26
Definition: operator/matrix/functor.hh:17
constexpr IndexFunctor(Functor functor, int localIndex, Index globalIndex)
Definition: operator/matrix/functor.hh:19
PairFunctor(const Mapper &mapper, const Entity &entity, Functor functor)
Definition: operator/matrix/functor.hh:44
Definition: coordinate.hh:4
STL namespace.
Definition: operator/matrix/functor.hh:42
PairFunctor< Mapper, Entity, Functor > makePairFunctor(const Mapper &mapper, const Entity &entity, Functor functor)
Definition: operator/matrix/functor.hh:65
void move(ArrayInterface< T > &array, const unsigned int oldOffset, const unsigned int newOffset, const unsigned int length)
Definition: array_inline.hh:38