DUNE-FEM (unstable)

functor.hh
1#ifndef DUNE_FEM_FUNCTION_TUPLEDISCRETEFUNCTION_FUNCTOR_HH
2#define DUNE_FEM_FUNCTION_TUPLEDISCRETEFUNCTION_FUNCTOR_HH
3
4#include <dune/fem/function/common/functor.hh>
5#include <dune/fem/function/tuplediscretefunction/dofvector.hh>
6
7
8namespace Dune
9{
10
11 namespace Fem
12 {
13
14 // DofBlockFunctor
15 // ---------------
16
17 template< class ... DofVectors, class Functor >
18 struct DofBlockFunctor< TupleDofVector< DofVectors ... >, Functor >
19 {
20 typedef TupleDofVector< DofVectors ... > DofVector;
21 DofBlockFunctor ( DofVector &dofVector, Functor functor )
22 : dofVector_( dofVector ), functor_( std::move( functor ) ) {}
23
24 template< class GlobalKey >
25 void operator() ( std::size_t local, const GlobalKey &globalKey ) const
26 {
27 const int localBlockSize
28 = std::decay< decltype( std::get< GlobalKey::component() >( dofVector_ ) ) >::type::blockSize;
29
30 const int index = globalKey.index();
31 functor_( local,
32 std::get< GlobalKey::component() >( dofVector_ ) [ index / localBlockSize ][ index % localBlockSize ] );
33 }
34
35 private:
36 DofVector &dofVector_;
37 Functor functor_;
38 };
39
40
41 // DofBlockFunctor
42 // ---------------
43
44 template< class ... DofVectors, class Functor >
45 struct DofBlockFunctor< const TupleDofVector< DofVectors ... >, Functor >
46 {
47 typedef TupleDofVector< DofVectors ... > DofVector;
48 DofBlockFunctor ( const DofVector &dofVector, Functor functor )
49 : dofVector_( dofVector ), functor_( std::move( functor ) ) {}
50
51 template< class GlobalKey >
52 void operator() ( std::size_t local, const GlobalKey &globalKey ) const
53 {
54 const int localBlockSize
55 = std::decay< decltype( std::get< GlobalKey::component() >( dofVector_ ) ) >::type::blockSize;
56
57 const int index = globalKey.index();
58 functor_( local,
59 std::get< GlobalKey::component() >( dofVector_ ) [ index / localBlockSize ][ index % localBlockSize ] );
60 }
61
62 private:
63 const DofVector &dofVector_;
64 Functor functor_;
65 };
66
67 } // namespace Fem
68
69} // namespace Dune
70
71#endif // #ifndef DUNE_FEM_FUNCTION_TUPLEDISCRETEFUNCTION_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)