dune-fem 2.12-git
Loading...
Searching...
No Matches
filteredgridpart.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_GRIDPART_FILTEREDGRIDPART_HH
2#define DUNE_FEM_GRIDPART_FILTEREDGRIDPART_HH
3
4//- system includes
5#include <cassert>
6#include <memory>
7
8//- dune-grid includes
10#include <dune/grid/common/gridview.hh>
11
12//- dune-fem includes
22
23namespace Dune
24{
25
26 namespace Fem
27 {
28
29 // Forward declarations
30 // --------------------
31
32 template< class HostGridPartImp, class FilterImp, bool useFilteredIndexSet = false >
33 class FilteredGridPart;
34
35
36
37 // FilteredGridPartIndexSetSelector
38 // --------------------------------
39
40 template < class FilteredGP, class HostGP, bool useFilteredIndexSet >
42 {
44
45 static IndexSetType *create(const FilteredGP &gridPart)
46 {
47 return new IndexSetType( gridPart );
48 }
49
50 template < class IndexSetPtr >
51 static const IndexSetType&
52 indexSet ( const FilteredGP &gridPart, const std::unique_ptr< IndexSetPtr >& idxSetPtr )
53 {
54 assert( idxSetPtr );
55 return *idxSetPtr;
56 }
57 };
58
59
60 // FilteredGridPartIndexSetSelector
61 // specialization for non-filtered index set,
62 // i.e. host index set
63 // -----------------------------------------
64
65 template< class FilteredGP, class HostGP >
66 struct FilteredGridPartIndexSetSelector< FilteredGP, HostGP, false >
67 {
68 typedef typename HostGP::IndexSetType IndexSetType;
69
70 static IndexSetType *create(const FilteredGP &gridPart)
71 {
72 return nullptr;
73 }
74
75 template < class IndexSetPtr >
76 static const IndexSetType&
77 indexSet ( const FilteredGP &gridPart, const std::unique_ptr< IndexSetPtr >& )
78 {
79 return gridPart.hostGridPart().indexSet();
80 }
81 };
82
83
84
85 // EntityGridTypeGetter
86 // --------------------
87
88 template< class Entity >
90
91 template< int codim, int dim, class Grid, template< int, int, class > class Impl >
92 struct EntityGridTypeGetter< Dune::Entity< codim, dim, Grid, Impl > >
93 {
94 typedef Grid Type;
95 };
96
97 template< class Entity >
99 {
101 };
102
103
104
105 // FilteredGridPartTraits
106 // ----------------------
107
108 template< class HostGridPartImp, class FilterImp, bool useFilteredIndexSet >
110 {
113
115 {
116 typedef FilterImp Filter;
117 typedef HostGridPartImp HostGridPart;
118
119 static const int dimension = HostGridPart::dimension;
120 static const int dimensionworld = HostGridPart::dimensionworld;
121
122 typedef typename HostGridPart::ctype ctype;
123
126
129
130 template< int codim >
131 struct Codim : public HostGridPart::template Codim< codim >
132 {
133 };
134 };
135
137 typedef HostGridPartImp HostGridPartType;
138
140 typedef typename HostGridPartType::GridType GridType;
142 typedef GridType Grid;
143
146
148 typedef FilterImp FilterType;
149
151 typedef typename FilterType::EntityType EntityType;
152
155
158
160 typedef typename HostGridPartType::Traits::IntersectionIteratorType HostIntersectionIteratorType;
161
164
167
169 template< int codim >
170 struct Codim : public HostGridPartType::template Codim< codim >
171 {
172 template< PartitionIteratorType pitype >
178
181 };
182
183 typedef typename HostGridPartType::CommunicationType CommunicationType;
185
187 static const PartitionIteratorType indexSetPartitionType = HostGridPartType::indexSetPartitionType;
188
189 static const InterfaceType indexSetInterfaceType = HostGridPartType::indexSetInterfaceType;
190
192 static const bool conforming = HostGridPartType::Traits::conforming;
193 };
194
195
196
197 //***************************************************************************
198 //
199 // FilteredGridPart
200 //
218 template< class HostGridPartImp, class FilterImp, bool useFilteredIndexSet >
220 : public GridPartDefault< FilteredGridPartTraits< HostGridPartImp, FilterImp, useFilteredIndexSet > >
221 {
222 // type of this
225
226 public:
227 //- Public typedefs and enums
230
232 typedef FilterImp FilterType;
233
234 // type of host grid part
236
238 typedef typename Traits::GridType GridType;
239
242
245
248
250
252
254 template< int codim >
255 struct Codim : public Traits :: template Codim< codim >
256 {};
257
258 private:
260
261 typedef typename Codim< 0 >::EntityType EntityType;
262
263 public:
264 //- Public methods
268 hostGridPart_( &hostGridPart ),
269 filter_( new FilterType(filter) ),
270 indexSetPtr_( IndexSetSelectorType::create( *this ) )
271 {
272 }
273
276 : BaseType( other ),
277 hostGridPart_( other.hostGridPart_ ),
278 filter_( new FilterType( other.filter()) ),
279 indexSetPtr_ ( IndexSetSelectorType::create( *this ) )
280 { }
281
283 {
284 BaseType::operator=( other );
285 hostGridPart_ = other.hostGridPart_;
286 filter_.reset( new FilterType( other.filter() ) );
287 indexSetPtr_.reset( IndexSetSelectorType::create( *this ) );
288 return *this;
289 }
290
292 // if IndexSetType is from host grid part the original index set is returned
293 const IndexSetType &indexSet() const
294 {
295 return IndexSetSelectorType::indexSet( *this, indexSetPtr_ );
296 }
297
299 template< int codim >
301 {
302 return begin< codim, InteriorBorder_Partition >();
303 }
304
306 template< int codim, PartitionIteratorType pitype >
307 typename Codim< codim >::template Partition< pitype >::IteratorType begin () const
308 {
309 typedef typename Codim< codim >::template Partition< pitype >::IteratorType IteratorType;
311 return IteratorType( IteratorImpl( *this, hostGridPart().template begin< codim, pitype >() ) );
312 }
313
315 template< int codim >
317 {
318 return end< codim, InteriorBorder_Partition >();
319 }
320
322 template< int codim, PartitionIteratorType pitype >
323 typename Codim< codim >::template Partition< pitype >::IteratorType end () const
324 {
325 typedef typename Codim< codim >::template Partition< pitype >::IteratorType IteratorType;
327 return IteratorType( IteratorImpl( *this, hostGridPart().template end< codim, pitype >() ) );
328 }
329
331 int level () const
332 {
333 return hostGridPart().level();
334 }
335
337 IntersectionIteratorType ibegin ( const EntityType &entity ) const
338 {
339 typedef typename IntersectionIteratorType::Implementation IntersectionIteratorImpl;
340 return IntersectionIteratorType( IntersectionIteratorImpl( filter(), hostGridPart().ibegin( entity ) ) );
341 }
342
344 IntersectionIteratorType iend ( const EntityType &entity ) const
345 {
346 typedef typename IntersectionIteratorType::Implementation IntersectionIteratorImpl;
347 return IntersectionIteratorType( IntersectionIteratorImpl( filter(), hostGridPart().iend( entity ) ) );
348 }
349
351 template < class DataHandleImp, class DataType >
353 InterfaceType iftype, CommunicationDirection dir ) const
354 {
355 typedef CommDataHandleIF< DataHandleImp, DataType > HostHandleType;
356 FilteredGridPartDataHandle< HostHandleType, ThisType > handleWrapper( dataHandle, *this );
357 hostGridPart().communicate( handleWrapper, iftype, dir );
358 }
359
361 template < class EntitySeed >
363 entity ( const EntitySeed &seed ) const
364 {
365 return hostGridPart().entity( seed );
366 }
367
369 const FilterType &filter () const
370 {
371 return *filter_;
372 }
373
376 {
377 return *filter_;
378 }
379
380 template< class Entity >
381 bool contains ( const Entity &entity ) const
382 {
383 return filter().contains( entity );
384 }
385
387 {
388 assert( hostGridPart_ );
389 return *hostGridPart_;
390 }
391
393 {
394 assert( hostGridPart_ );
395 return *hostGridPart_;
396 }
397
399 template <class Entity>
400 const Entity& convert ( const Entity &entity ) const
401 {
402 return hostGridPart().convert( entity );
403 }
404
405 private:
406 HostGridPartType *hostGridPart_;
409 };
410
411 template< class GridPartFamily >
412 struct GridIntersectionAccess< Dune::Intersection< const GridPartFamily, typename GridPartFamily::IntersectionImpl > >
413 {
416 typedef typename HostAccessType::GridIntersectionType GridIntersectionType;
417
418 static const typename HostAccessType::GridIntersectionType &gridIntersection ( const IntersectionType &intersection )
419 {
420 return HostAccessType::gridIntersection( intersection.impl().hostIntersection() );
421 }
422 };
423
424 template< class HostGridPartImp, class FilterImp, bool useFilteredIndexSet >
425 struct HasBoundaryIntersection< FilteredGridPart<HostGridPartImp,FilterImp,useFilteredIndexSet> >
426 {
428 using EntityType = typename GridPartType::template Codim<0>::EntityType;
429 static bool apply(const EntityType &entity)
430 {
431 return true;
432 }
433 };
434
435 } // namespace Fem
436
437} // namespace Dune
438
439#endif // #ifndef DUNE_FEM_GRIDPART_FILTEREDGRIDPART_HH
static type * create(const M &mat, bool verbose, bool reusevector)
void seed(const Vertex &vertex)
PartitionIteratorType
CommunicationDirection
InterfaceType
Implementation & impl()
IntersectionIteratorImp Implementation
consecutive, persistent index set for the leaf level based on the grid's hierarchy index set
Definition adaptiveleafindexset.hh:1357
Default implementation for the GridPart classes.
Definition gridpart.hh:372
const GridType & grid() const
Returns const reference to the underlying grid.
Definition gridpart.hh:423
GridPartDefault & operator=(const ThisType &other)
Definition gridpart.hh:414
MetaTwistUtility forwards the twist calls to the TwistUtility of the underlying HostTwistUtility.
Definition metatwistutility.hh:22
A FilteredGridPart allows to extract a set of entities from a grid satisfying a given constrainted de...
Definition filteredgridpart.hh:221
FilteredGridPart & operator=(const FilteredGridPart &other)
Definition filteredgridpart.hh:282
FilteredGridPart(HostGridPartType &hostGridPart, const FilterType &filter)
constructor
Definition filteredgridpart.hh:266
Codim< codim >::template Partition< pitype >::IteratorType end() const
End iterator on the leaf level.
Definition filteredgridpart.hh:323
IntersectionIteratorType ibegin(const EntityType &entity) const
ibegin of corresponding intersection iterator for given entity
Definition filteredgridpart.hh:337
Codim< codim >::IteratorType end() const
Begin iterator on the leaf level.
Definition filteredgridpart.hh:316
ThisType GridViewType
Definition filteredgridpart.hh:251
Traits::GridType GridType
grid type
Definition filteredgridpart.hh:238
Traits::IndexSetType IndexSetType
index set type
Definition filteredgridpart.hh:241
int level() const
Returns maxlevel of the grid.
Definition filteredgridpart.hh:331
Traits::IntersectionIteratorType IntersectionIteratorType
intersection iterator type
Definition filteredgridpart.hh:244
Codim< codim >::template Partition< pitype >::IteratorType begin() const
Begin iterator on the leaf level.
Definition filteredgridpart.hh:307
Codim< codim >::IteratorType begin() const
Begin iterator on the leaf level.
Definition filteredgridpart.hh:300
Traits::CommunicationType CommunicationType
Definition filteredgridpart.hh:249
const HostGridPartType & hostGridPart() const
Definition filteredgridpart.hh:392
FilterType & filter()
return reference to filter
Definition filteredgridpart.hh:375
const Entity & convert(const Entity &entity) const
convert the grid's entity to a grid part entity Usually the parameter is GridType :: Codim< codim > :...
Definition filteredgridpart.hh:400
bool contains(const Entity &entity) const
Definition filteredgridpart.hh:381
HostGridPartType & hostGridPart()
Definition filteredgridpart.hh:386
FilteredGridPart(const FilteredGridPart &other)
copy constructor
Definition filteredgridpart.hh:275
Codim< EntitySeed::codimension >::EntityType entity(const EntitySeed &seed) const
obtain entity pointer from entity seed
Definition filteredgridpart.hh:363
FilteredGridPartTraits< HostGridPartImp, FilterImp, useFilteredIndexSet > Traits
traits class
Definition filteredgridpart.hh:229
FilterImp FilterType
type of filter
Definition filteredgridpart.hh:232
Traits::HostGridPartType HostGridPartType
Definition filteredgridpart.hh:235
const IndexSetType & indexSet() const
return index set of this grid part
Definition filteredgridpart.hh:293
const FilterType & filter() const
return reference to filter
Definition filteredgridpart.hh:369
void communicate(CommDataHandleIF< DataHandleImp, DataType > &dataHandle, InterfaceType iftype, CommunicationDirection dir) const
corresponding communication method for this grid part
Definition filteredgridpart.hh:352
IntersectionIteratorType iend(const EntityType &entity) const
iend of corresponding intersection iterator for given entity
Definition filteredgridpart.hh:344
IntersectionIteratorType::Intersection IntersectionType
intersection type
Definition filteredgridpart.hh:247
Definition filteredgridpart.hh:42
static IndexSetType * create(const FilteredGP &gridPart)
Definition filteredgridpart.hh:45
AdaptiveLeafIndexSet< FilteredGP > IndexSetType
Definition filteredgridpart.hh:43
static const IndexSetType & indexSet(const FilteredGP &gridPart, const std::unique_ptr< IndexSetPtr > &idxSetPtr)
Definition filteredgridpart.hh:52
static IndexSetType * create(const FilteredGP &gridPart)
Definition filteredgridpart.hh:70
static const IndexSetType & indexSet(const FilteredGP &gridPart, const std::unique_ptr< IndexSetPtr > &)
Definition filteredgridpart.hh:77
HostGP::IndexSetType IndexSetType
Definition filteredgridpart.hh:68
Definition filteredgridpart.hh:89
EntityGridTypeGetter< Entity >::Type Type
Definition filteredgridpart.hh:100
Definition filteredgridpart.hh:110
CommunicationType Communication
Definition filteredgridpart.hh:184
HostGridPartImp HostGridPartType
grid part imp
Definition filteredgridpart.hh:137
FilterType::EntityType EntityType
type of entity
Definition filteredgridpart.hh:151
HostGridPartType::Traits::IntersectionIteratorType HostIntersectionIteratorType
of host grid part intersection iterator type
Definition filteredgridpart.hh:160
GridPartFamily::Intersection IntersectionType
type of intersection
Definition filteredgridpart.hh:166
IndexSetSelectorType::IndexSetType IndexSetType
index set use in this gridpart
Definition filteredgridpart.hh:157
FilteredGridPartIndexSetSelector< GridPartType, HostGridPartType, useFilteredIndexSet > IndexSetSelectorType
index set use in this gridpart
Definition filteredgridpart.hh:154
FilteredGridPart< HostGridPartImp, FilterImp, useFilteredIndexSet > GridPartType
type of grid part
Definition filteredgridpart.hh:112
static const bool conforming
is true if grid on this view only has conforming intersections
Definition filteredgridpart.hh:192
MetaTwistUtility< typename HostGridPartType ::TwistUtilityType > TwistUtilityType
The type of the corresponding TwistUtility.
Definition filteredgridpart.hh:145
static const InterfaceType indexSetInterfaceType
Definition filteredgridpart.hh:189
HostGridPartType::CommunicationType CommunicationType
Definition filteredgridpart.hh:183
GridType Grid
type of grid
Definition filteredgridpart.hh:142
static const PartitionIteratorType indexSetPartitionType
maximum partition type, the index set provides indices for
Definition filteredgridpart.hh:187
HostGridPartType::GridType GridType
type of grid
Definition filteredgridpart.hh:140
GridPartFamily::IntersectionIterator IntersectionIteratorType
type of intersection iterator
Definition filteredgridpart.hh:163
FilterImp FilterType
export filter type
Definition filteredgridpart.hh:148
Definition filteredgridpart.hh:115
Dune::Intersection< const GridPartFamily, IntersectionImpl > Intersection
Definition filteredgridpart.hh:128
HostGridPart::ctype ctype
Definition filteredgridpart.hh:122
HostGridPartImp HostGridPart
Definition filteredgridpart.hh:117
static const int dimension
Definition filteredgridpart.hh:119
FilterImp Filter
Definition filteredgridpart.hh:116
FilteredGridPartIntersectionIterator< const GridPartFamily > IntersectionIteratorImpl
Definition filteredgridpart.hh:124
FilteredGridPartIntersection< Filter, typename HostGridPart::IntersectionType > IntersectionImpl
Definition filteredgridpart.hh:125
static const int dimensionworld
Definition filteredgridpart.hh:120
Dune::IntersectionIterator< const GridPartFamily, IntersectionIteratorImpl, IntersectionImpl > IntersectionIterator
Definition filteredgridpart.hh:127
struct providing types of the iterators on codimension cd
Definition filteredgridpart.hh:171
Partition< InteriorBorder_Partition >::IteratorType IteratorType
Definition filteredgridpart.hh:179
IteratorType Iterator
Definition filteredgridpart.hh:180
Definition filteredgridpart.hh:174
Dune::EntityIterator< codim, typename EntityGridTypeGetter< EntityType >::Type, FilteredGridPartIterator< codim, pitype, GridPartType > > IteratorType
Definition filteredgridpart.hh:175
IteratorType Iterator
Definition filteredgridpart.hh:176
grid part typedefs, use those of traits
Definition filteredgridpart.hh:256
GridIntersectionAccess< typename IntersectionType::Implementation::HostIntersectionType > HostAccessType
Definition filteredgridpart.hh:415
static const HostAccessType::GridIntersectionType & gridIntersection(const IntersectionType &intersection)
Definition filteredgridpart.hh:418
Dune::Intersection< const GridPartFamily, typename GridPartFamily::IntersectionImpl > IntersectionType
Definition filteredgridpart.hh:414
static bool apply(const EntityType &entity)
Definition filteredgridpart.hh:429
typename GridPartType::template Codim< 0 >::EntityType EntityType
Definition filteredgridpart.hh:428
Definition gridpart/filteredgridpart/datahandle.hh:31
Definition filteredgridpart/intersection.hh:21
Definition filteredgridpart/intersectioniterator.hh:24
Definition filteredgridpart/iterator.hh:21
Definition hasboundaryintersection.hh:11
Definition twistutility.hh:22
T reset(T... args)