dune-fem 2.12-git
Loading...
Searching...
No Matches
persistentindexset.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_GRIDPART_TEST_PERSISTENTINDEXSET_HH
2#define DUNE_FEM_GRIDPART_TEST_PERSISTENTINDEXSET_HH
3
4#include <type_traits>
5#include <utility>
6
11
12namespace Dune
13{
14
15 namespace Fem
16 {
17
18 // Internal forward declaration
19 // ----------------------------
20
21 template< class Traits >
22 class PersistentConsecutiveIndexSet;
23 template< class Traits >
24 class PersistentAdaptiveIndexSet;
25
26
27
28 // PersistentIndexSetInterface
29 // ---------------------------
30
35 {
37
39 virtual void addBackupRestore () = 0;
40
42 virtual void removeBackupRestore () = 0;
43 };
44
45
46
47 namespace Capabilities
48 {
49
50 // isPersistentIndexSet
51 // --------------------
52
53#ifndef DOXYGEN
54
55 template< class IndexSet, bool value = std::is_base_of< PersistentIndexSetInterface, IndexSet >::type::value >
56 struct __isPersistentIndexSet;
57
58 template< class IndexSet >
59 struct __isPersistentIndexSet< IndexSet, true >
60 {
61 static const bool v = true;
62
63 static constexpr PersistentIndexSetInterface* map ( IndexSet &indexSet )
64 {
65 return static_cast< PersistentIndexSetInterface * >( &indexSet );
66 }
67 };
68
69 template< class IndexSet >
70 struct __isPersistentIndexSet< IndexSet, false >
71 {
72 static const bool v = false;
73
74 static constexpr PersistentIndexSetInterface* map ( IndexSet & ) noexcept
75 {
76 return nullptr;
77 }
78 };
79
80#endif // #ifndef DOXYGEN
81
89 template< class IndexSet >
91 : public __isPersistentIndexSet< IndexSet >
92 {
93 private:
94 typedef __isPersistentIndexSet< IndexSet > BaseType;
95
96 public:
98 static const bool v = BaseType::v;
99
101 static constexpr PersistentIndexSetInterface* map ( IndexSet &indexSet ) noexcept
102 {
103 return BaseType::map( indexSet );
104 }
105 };
106
107#ifndef DOXYGEN
108
109 template< class IndexSet >
110 struct isPersistentIndexSet< const IndexSet >
111 : public isPersistentIndexSet< IndexSet >
112 {};
113
114#endif // #ifndef DOXYGEN
115
116 } // namespace Capabilities
117
118
119
120 // PersistentIndexSet
121 // ------------------
122
128 template< class Traits, template< class > class Base >
130 : public Base< Traits >,
132 {
133 typedef Base< Traits > BaseType;
134
135 protected:
136 using BaseType::impl;
137
139 typedef typename Traits::GridType GridType;
142
143 explicit PersistentIndexSet ( const GridType &grid )
144 : grid_( grid ),
145 dofManager_( DofManagerType::instance( grid ) ),
146 counter_( 0 )
147 {
148 dofManager_.addIndexSet( impl() );
149 }
150
151 public:
152 using BaseType::read;
153 using BaseType::write;
154
156 {
157 dofManager_.removeIndexSet( impl() );
158 }
159
161 const GridType& grid () const
162 {
163 return grid_;
164 }
165
167 void backup () const
168 {
169 if( needsBackupRestore() )
171 }
172
174 void restore ()
175 {
176 if( needsBackupRestore() )
178 }
179
181 void addBackupRestore () override final { ++counter_; }
182
184 void removeBackupRestore () override final { --counter_; }
185
186 private:
187 bool needsBackupRestore () const { return counter_ > 0; }
188
189 protected:
192
193 private:
194 int counter_ ;
195 };
196
197
198
199 // PersistentConsecutiveIndexSet
200 // -----------------------------
201
202 template< class Traits >
204 : public PersistentIndexSet< Traits, ConsecutiveIndexSet >
205 {
207
208 protected:
210 : BaseType( grid )
211 {}
212 };
213
214
215
216 // PersistentAdaptiveIndexSet
217 // --------------------------
218
219 template< class Traits >
221 : public PersistentIndexSet< Traits, AdaptiveIndexSet >
222 {
224
225 protected:
227 : BaseType( grid )
228 {}
229 };
230
231 } // namespace Fem
232
233} // namespace Dune
234
235#endif // #ifndef DUNE_FEM_GRIDPART_TEST_PERSISTENTINDEXSET_HH
void removeIndexSet(const IndexSetType &iset)
removed index set from dof manager's list of index sets
Definition dofmanager.hh:1331
void addIndexSet(const IndexSetType &iset)
add index set to dof manager's list of index sets
Definition dofmanager.hh:1296
interface documentation for (grid part) index sets
Definition common/indexset.hh:123
Definition persistentindexset.hh:205
PersistentConsecutiveIndexSet(const typename BaseType::GridType &grid)
Definition persistentindexset.hh:209
Definition persistentindexset.hh:222
PersistentAdaptiveIndexSet(const typename BaseType::GridType &grid)
Definition persistentindexset.hh:226
virtual base class for persistent index sets
Definition persistentindexset.hh:35
virtual void addBackupRestore()=0
please doc me
virtual void removeBackupRestore()=0
please doc me
virtual ~PersistentIndexSetInterface()
Definition persistentindexset.hh:36
capability for persistent index sets
Definition persistentindexset.hh:92
static constexpr PersistentIndexSetInterface * map(IndexSet &indexSet) noexcept
please doc me
Definition persistentindexset.hh:101
static const bool v
please doc me
Definition persistentindexset.hh:98
please doc me
Definition persistentindexset.hh:132
Traits::GridType GridType
grid type
Definition persistentindexset.hh:139
DofManagerType & dofManager_
Definition persistentindexset.hh:191
const GridType & grid_
Definition persistentindexset.hh:190
PersistentIndexSet(const GridType &grid)
Definition persistentindexset.hh:143
void backup() const
please doc me
Definition persistentindexset.hh:167
const GridType & grid() const
return const reference to the grid
Definition persistentindexset.hh:161
~PersistentIndexSet()
Definition persistentindexset.hh:155
void restore()
please doc me
Definition persistentindexset.hh:174
void removeBackupRestore() override final
please doc me
Definition persistentindexset.hh:184
void addBackupRestore() override final
please doc me
Definition persistentindexset.hh:181
DofManager< GridType > DofManagerType
dof manager type
Definition persistentindexset.hh:141
static BackupStreamType & backupStream()
Definition persistencemanager.hh:349
static RestoreStreamType & restoreStream()
Definition persistencemanager.hh:354
Definition dofmanager.hh:786