DUNE-FEM (unstable)

threaditeratorstorage.hh
1#ifndef DUNE_FEM_THREADITERATORSTORAGE_HH
2#define DUNE_FEM_THREADITERATORSTORAGE_HH
3
4#include <vector>
5
7
8#include <dune/fem/space/common/dofmanager.hh>
9#include <dune/fem/gridpart/filteredgridpart.hh>
10
11#ifdef USE_SMP_PARALLEL
12#include <dune/fem/misc/threads/threadpartitioner.hh>
13#endif
14
15namespace Dune {
16
17 namespace Fem {
18
20 template < class ThreadIterator >
22 {
23 public:
25 typedef typename ThreadIterator :: GridPartType GridPartType;
26 typedef typename GridPartType :: IndexSetType IndexSetType;
27
28 typedef typename ThreadIteratorType :: FilterType FilterType ;
29 typedef typename ThreadIteratorType :: IteratorType IteratorType;
30
31 typedef typename IteratorType :: Entity EntityType ;
32
33 static const PartitionIteratorType pitype = ThreadIteratorType :: pitype ;
34
35 private:
36 struct IteratorFactory
37 {
38 struct Key
39 {
40 const GridPartType& gridPart_;
41 const IndexSetType& indexSet_;
42 static const PartitionIteratorType ptype = pitype ;
43 Key(const GridPartType& gridPart)
44 : gridPart_( gridPart ),
45 indexSet_( gridPart_.indexSet() )
46 {}
47
48 bool operator ==( const Key& other ) const
49 {
50 // compare grid pointers
51 return (&indexSet_) == (& other.indexSet_ ) && ( ptype == other.ptype );
52 }
53 const GridPartType& gridPart() const { return gridPart_; }
54 };
55
56 typedef ThreadIteratorType ObjectType;
57 typedef Key KeyType;
58
59 inline static ObjectType *createObject ( const KeyType &key )
60 {
61 return new ObjectType( key.gridPart() );
62 }
63
64 inline static void deleteObject ( ObjectType *object )
65 {
66 delete object;
67 }
68 };
69
70
71 typedef typename IteratorFactory :: KeyType KeyType;
72 typedef SingletonList< KeyType,
74
75 protected:
76 std::unique_ptr< ThreadIteratorType, typename IteratorProviderType::Deleter> iterators_;
77
78 public:
80 explicit ThreadIteratorStorageBase( const GridPartType& gridPart )
81 : iterators_( &IteratorProviderType::getObject( KeyType( gridPart ) ) )
82 {
83 update();
84 }
85
86 ThreadIteratorType& iterators () const { assert( iterators_ ); return *iterators_; }
87
89 const FilterType& filter( const int thread ) const
90 {
91 return iterators().filter( thread );
92 }
93
95 void update()
96 {
97 iterators().update();
98 }
99
101 void setMasterRatio( const double ratio )
102 {
103 iterators().setMasterRatio( ratio );
104 }
105
107 IteratorType begin() const
108 {
109 return iterators().begin();
110 }
111
113 IteratorType end() const
114 {
115 return iterators().end();
116 }
117
119 int index(const EntityType& entity ) const
120 {
121 return iterators().index( entity );
122 }
123
125 int thread(const EntityType& entity ) const
126 {
127 return iterators().thread( entity );
128 }
129 };
130 } // end namespace Fem
131} // end namespace Dune
132
133#endif // #ifndef DUNE_FEM_DG_DOMAINTHREADITERATOR_HH
consecutive, persistent index set for the leaf level based on the grid's hierarchy index set
Definition: adaptiveleafindexset.hh:1351
Singleton list for key/object pairs.
Definition: singletonlist.hh:53
Storage of thread iterators using domain decomposition.
Definition: threaditeratorstorage.hh:22
void setMasterRatio(const double ratio)
set ratio between master thread and other threads in comp time
Definition: threaditeratorstorage.hh:101
int thread(const EntityType &entity) const
return thread number this entity belongs to
Definition: threaditeratorstorage.hh:125
IteratorType end() const
return end iterator for current thread
Definition: threaditeratorstorage.hh:113
int index(const EntityType &entity) const
return thread number this entity belongs to
Definition: threaditeratorstorage.hh:119
const FilterType & filter(const int thread) const
return filter for given thread
Definition: threaditeratorstorage.hh:89
void update()
update internal list of iterators
Definition: threaditeratorstorage.hh:95
ThreadIteratorStorageBase(const GridPartType &gridPart)
contructor creating thread iterators
Definition: threaditeratorstorage.hh:80
IteratorType begin() const
return begin iterator for current thread
Definition: threaditeratorstorage.hh:107
Thread iterators.
Definition: threaditerator.hh:24
int thread(const EntityType &entity) const
return thread number this entity belongs to
Definition: threaditerator.hh:253
IteratorType end() const
return end iterator for current thread
Definition: threaditerator.hh:221
void update()
update internal list of iterators
Definition: threaditerator.hh:93
void setMasterRatio(const double ratio)
set ratio between master thread and other threads in comp time
Definition: threaditerator.hh:268
IteratorType begin() const
return begin iterator for current thread
Definition: threaditerator.hh:202
const FilterType & filter(const unsigned int thread) const
return filter for given thread
Definition: threaditerator.hh:86
int index(const EntityType &entity) const
return thread number this entity belongs to
Definition: threaditerator.hh:240
A few common exception classes.
PartitionIteratorType
Parameter to be used for the parallel level- and leaf iterators.
Definition: gridenums.hh:136
EnableIfInterOperable< T1, T2, bool >::type operator==(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for equality.
Definition: iteratorfacades.hh:238
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 13, 23:29, 2024)