DUNE-FEM (unstable)

functor.hh
1#ifndef DUNE_FEM_OPERATOR_MATRIX_FUNCTOR_HH
2#define DUNE_FEM_OPERATOR_MATRIX_FUNCTOR_HH
3
4#include <utility>
5
6
7namespace Dune
8{
9
10 namespace Fem
11 {
12
13 // IndexFunctor
14 // ------------
15
16 template< class Functor, class LocalIndex, class GlobalIndex >
17 struct IndexFunctor
18 {
19 constexpr IndexFunctor ( Functor functor, const LocalIndex &localIndex, const GlobalIndex &globalIndex )
20 : functor_( functor ),
21 localIndex_( localIndex ),
22 globalIndex_( globalIndex )
23 {}
24
25 template< class LocalKey, class GlobalKey >
26 void operator() ( const LocalKey localKey, const GlobalKey &globalKey ) const
27 {
28 functor_( std::make_pair( localIndex_, localKey ), std::make_pair( globalIndex_, globalKey ) );
29 }
30
31 private:
32 Functor functor_;
33 LocalIndex localIndex_;
34 GlobalIndex 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 LocalKey, class GlobalKey >
49 void operator() ( const LocalKey &localKey, const GlobalKey &globalKey ) const
50 {
51 mapper_.mapEach( entity_, IndexFunctor< Functor, LocalKey, 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
Dune namespace.
Definition: alignedallocator.hh:13
STL namespace.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 13, 23:29, 2024)