dune-fem  2.8-git
gridpart.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_GRIDPART_COMMON_GRIDPART_HH
2 #define DUNE_FEM_GRIDPART_COMMON_GRIDPART_HH
3 
4 //- dune-common includes
5 #include <dune/common/bartonnackmanifcheck.hh>
6 
7 //- dune-grid includes
8 #include <dune/grid/common/datahandleif.hh>
9 #include <dune/grid/common/entity.hh>
10 #include <dune/grid/common/grid.hh>
11 
12 //- dune-fem includes
18 
19 namespace Dune
20 {
21 
22  namespace Fem
23  {
24 
74  template< class GridPartTraits >
76  : public GridPartPolicies< GridPartTraits >
77  {
79 
81 
82  public:
84  typedef GridPartTraits Traits;
85 
87  typedef typename Traits::GridPartType GridPartType;
88 
90  typedef typename Traits::GridType GridType;
91 
93  typedef typename Traits::IndexSetType IndexSetType;
94 
96  typedef typename Traits::CollectiveCommunicationType CollectiveCommunicationType;
97 
99  typedef typename Traits::TwistUtilityType TwistUtilityType;
100 
102  static const PartitionIteratorType indexSetPartitionType
103  = Traits::indexSetPartitionType;
104  static const InterfaceType indexSetInterfaceType
105  = Traits::indexSetInterfaceType;
106 
108  typedef typename Traits::IntersectionIteratorType IntersectionIteratorType;
109 
111  typedef typename IntersectionIteratorType::Intersection IntersectionType;
112 
113  typedef typename PoliciesType::GridViewType GridViewType;
114 
115  typedef typename GridType::ctype ctype;
116 
117  static const int dimension = GridType::dimension;
118  static const int dimensionworld = GridType::dimensionworld;
119 
120  template< int codim >
121  struct Codim
122  {
123  typedef typename Traits::template Codim< codim >::GeometryType GeometryType;
124  typedef typename Traits::template Codim< codim >::LocalGeometryType LocalGeometryType;
125 
126  typedef typename Traits::template Codim< codim >::EntityType EntityType;
127  typedef typename Traits::template Codim< codim >::EntitySeedType EntitySeedType;
128 
129  template< PartitionIteratorType pitype >
130  struct Partition
131  {
132  typedef typename Traits::template Codim< codim >::template Partition< pitype >::IteratorType
134  };
135 
137  };
138 
140  const GridType &grid () const
141  {
142  CHECK_INTERFACE_IMPLEMENTATION((asImp().grid()));
143  return asImp().grid();
144  }
147  {
148  CHECK_INTERFACE_IMPLEMENTATION((asImp().grid()));
149  return asImp().grid();
150  }
151 
153  const IndexSetType& indexSet() const
154  {
155  CHECK_INTERFACE_IMPLEMENTATION((asImp().indexSet()));
156  return asImp().indexSet();
157  }
158 
163  template< int codim >
165  begin () const
166  {
167  CHECK_INTERFACE_IMPLEMENTATION( (asImp().template begin< codim >()) );
168  return asImp().template begin< codim >();
169  }
170 
176  template< int codim, PartitionIteratorType pitype >
177  typename Codim< codim >::template Partition< pitype >::IteratorType
178  begin () const
179  {
180  CHECK_INTERFACE_IMPLEMENTATION( (asImp().template begin< codim, pitype >()) );
181  return asImp().template begin< codim, pitype >();
182  }
183 
188  template< int codim >
190  end () const
191  {
192  CHECK_INTERFACE_IMPLEMENTATION( (asImp().template end< codim >()) );
193  return asImp().template end< codim >();
194  }
195 
201  template< int codim, PartitionIteratorType pitype >
202  typename Codim< codim >::template Partition< pitype >::IteratorType
203  end () const
204  {
205  CHECK_INTERFACE_IMPLEMENTATION( (asImp().template end< codim, pitype >()) );
206  return asImp().template end< codim, pitype >();
207  }
208 
210  int level () const
211  {
212  CHECK_INTERFACE_IMPLEMENTATION((asImp().level()));
213  return asImp().level();
214  }
215 
218  ibegin ( const typename Codim< 0 >::EntityType &entity ) const
219  {
220  CHECK_INTERFACE_IMPLEMENTATION( (asImp().ibegin( entity )) );
221  return asImp().ibegin( entity );
222  }
223 
226  {
227  CHECK_INTERFACE_IMPLEMENTATION( (asImp().iend( entity )) );
228  return asImp().iend( entity );
229  }
230 
232  int boundaryId ( const IntersectionType &intersection ) const
233  {
234  CHECK_INTERFACE_IMPLEMENTATION( asImp().boundaryId( intersection ) );
235  return asImp().boundaryId( intersection );
236  }
237 
240  {
241  CHECK_INTERFACE_IMPLEMENTATION( asImp().comm() );
242  return asImp().comm();
243  }
244 
246  template< class DataHandleImp, class DataType >
247  void communicate ( CommDataHandleIF< DataHandleImp, DataType > &data,
248  InterfaceType iftype, CommunicationDirection dir ) const
249  {
250  CHECK_AND_CALL_INTERFACE_IMPLEMENTATION( (asImp().communicate( data, iftype, dir )) );
251  }
252 
254  template < class EntitySeed >
256  entity ( const EntitySeed &seed ) const
257  {
258  CHECK_INTERFACE_IMPLEMENTATION( asImp().entity( seed ) );
259  return asImp().entity( seed );
260  }
261 
268  template <class Entity>
269  const Entity& convert( const Entity& entity ) const
270  {
271  CHECK_INTERFACE_IMPLEMENTATION( asImp().convert( entity ) );
272  return asImp().convert( entity );
273  }
274 
278  int sequence () const
279  {
280  CHECK_INTERFACE_IMPLEMENTATION( asImp().sequence() );
281  return asImp().sequence() ;
282  }
283 
284  protected:
286  GridPartInterface () = default;
287 
288  private:
289  GridPartType &asImp () { return static_cast< GridPartType & >( *this ); }
290  const GridPartType &asImp () const { return static_cast< const GridPartType & >( *this ); }
291  };
292 
293 
294 
296  template< class GridPartTraits >
298  : public GridPartInterface< GridPartTraits >
299  {
301 
302  public:
304  typedef GridPartTraits Traits;
306  typedef typename Traits::GridType GridType;
308  typedef typename Traits::IndexSetType IndexSetType;
309 
311  typedef typename Traits::IntersectionIteratorType IntersectionIteratorType;
312 
314  typedef typename IntersectionIteratorType::Intersection IntersectionType;
315 
317  typedef typename Traits::CollectiveCommunicationType CollectiveCommunicationType;
318 
321 
324 
325  protected:
328 
331  : grid_( grid ),
332  dofManager_( DofManagerType :: instance( grid_ ) )
333  {}
334 
335  GridPartDefault ( const ThisType &other )
336  : grid_( other.grid_ ),
337  dofManager_( DofManagerType :: instance( grid_ ) )
338  {}
339 
340  public:
342  const GridType &grid () const { return grid_; }
343 
345  GridType &grid () { return grid_; }
346 
349  {
350  return grid().comm();
351  }
352 
360  template < class EntitySeed >
361  typename Traits::template Codim< EntitySeed::codimension >::EntityType
362  entity ( const EntitySeed &seed ) const
363  {
364  return grid().entity( seed );
365  }
366 
371  template <class Entity>
372  const Entity& convert( const Entity& entity ) const
373  {
374  return entity;
375  }
376 
381  int sequence () const
382  {
383  return dofManager_.sequence();
384  }
385 
387  int boundaryId ( const IntersectionType &intersection ) const
388  {
389  return BoundaryIdProviderType::boundaryId( intersection );
390  }
391  };
392 
395  template< class Entity >
397 
398  template< int codim, int dim, class Grid, template< int, int, class > class EntityImpl >
399  struct GridEntityAccess< Dune::Entity< codim, dim, Grid, EntityImpl > >
400  {
401  typedef Dune::Entity< codim, dim, Grid, EntityImpl > EntityType;
402  typedef Dune::Entity< codim, dim, Grid, EntityImpl > GridEntityType;
403 
404  static const GridEntityType &gridEntity ( const EntityType &entity )
405  {
406  return entity;
407  }
408  };
409 
410  template< class Entity >
411  const typename GridEntityAccess< Entity >::GridEntityType &
412  gridEntity ( const Entity &entity )
413  {
415  }
416 
417  template< class TraitsImp >
418  struct AddGridView
419  {
420  typedef typename TraitsImp :: GridPartType GridPartType;
422  std::shared_ptr<GridViewType> gridViewStorage_;
424  AddGridView ( const GridPartType *gridPart )
425  : gridViewStorage_(new GridViewType(*gridPart))
427  {}
429  : gridViewStorage_(nullptr)
431  {}
432  AddGridView( const AddGridView& other)
434  , gridView_(other.gridView_)
435  {}
436  // use this constructor if it is guaranteed that no gridview is needed
438  : gridViewStorage_(nullptr)
439  , gridView_(nullptr)
440  {}
441  const GridViewType &gridView() const
442  {
443  assert( gridView_ );
444  return *gridView_;
445  }
446  };
447 
448  } // namespace Fem
449 
450 } // namespace Dune
451 
452 #endif // #define DUNE_FEM_GRIDPART_COMMON_GRIDPART_HH
int sequence() const
return number of sequence, if dofmanagers memory was changed by calling some method like resize,...
Definition: dofmanager.hh:981
Definition: bindguard.hh:11
std::tuple_element< i, Tuple >::type & get(Dune::TypeIndexedTuple< Tuple, Types > &tuple)
Definition: typeindexedtuple.hh:122
const GridEntityAccess< Entity >::GridEntityType & gridEntity(const Entity &entity)
Definition: gridpart.hh:412
Interface for the GridPart classes A GridPart class allows to access only a specific subset of a grid...
Definition: gridpart.hh:77
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
corresponding communication method for grid part
Definition: gridpart.hh:247
GridType & grid()
Returns reference to the underlying grid.
Definition: gridpart.hh:146
int sequence() const
return sequence number to update structures depending on the grid part
Definition: gridpart.hh:278
GridPartTraits Traits
Type of the Traits.
Definition: gridpart.hh:84
const IndexSetType & indexSet() const
Returns reference to index set of the underlying grid.
Definition: gridpart.hh:153
PoliciesType::GridViewType GridViewType
Definition: gridpart.hh:113
Codim< codim >::IteratorType end() const
obtain end iterator for the interior-border partition
Definition: gridpart.hh:190
static const int dimensionworld
Definition: gridpart.hh:118
const GridType & grid() const
Returns const reference to the underlying grid.
Definition: gridpart.hh:140
static const int dimension
Definition: gridpart.hh:117
Traits::CollectiveCommunicationType CollectiveCommunicationType
Collective communication.
Definition: gridpart.hh:96
Codim< EntitySeed::codimension >::EntityType entity(const EntitySeed &seed) const
obtain entity pointer from entity seed
Definition: gridpart.hh:256
GridType::ctype ctype
Definition: gridpart.hh:115
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: gridpart.hh:269
Traits::GridType GridType
type of Grid implementation
Definition: gridpart.hh:90
Codim< codim >::IteratorType begin() const
obtain begin iterator for the interior-border partition
Definition: gridpart.hh:165
GridPartInterface()=default
do not create explicit instances of this class
Traits::TwistUtilityType TwistUtilityType
Twist utility type.
Definition: gridpart.hh:99
IntersectionIteratorType::Intersection IntersectionType
type of Intersection
Definition: gridpart.hh:111
static const InterfaceType indexSetInterfaceType
Definition: gridpart.hh:105
Codim< codim >::template Partition< pitype >::IteratorType end() const
obtain end iterator for the given partition
Definition: gridpart.hh:203
const CollectiveCommunicationType & comm() const
obtain collective communication object
Definition: gridpart.hh:239
Codim< codim >::template Partition< pitype >::IteratorType begin() const
obtain begin iterator for the given partition
Definition: gridpart.hh:178
int boundaryId(const IntersectionType &intersection) const
return boundary if given an intersection
Definition: gridpart.hh:232
IntersectionIteratorType iend(const typename Codim< 0 >::EntityType &entity) const
iend of corresponding intersection iterator for given entity
Definition: gridpart.hh:225
static const PartitionIteratorType indexSetPartitionType
Maximum Partition type, the index set provides indices for.
Definition: gridpart.hh:103
Traits::IntersectionIteratorType IntersectionIteratorType
type of IntersectionIterator
Definition: gridpart.hh:108
Traits::GridPartType GridPartType
Type of the implementation.
Definition: gridpart.hh:87
IntersectionIteratorType ibegin(const typename Codim< 0 >::EntityType &entity) const
ibegin of corresponding intersection iterator for given entity
Definition: gridpart.hh:218
Traits::IndexSetType IndexSetType
Index set implementation.
Definition: gridpart.hh:93
int level() const
Level of the grid part.
Definition: gridpart.hh:210
Definition: gridpart.hh:122
Traits::template Codim< codim >::EntityType EntityType
Definition: gridpart.hh:126
Traits::template Codim< codim >::EntitySeedType EntitySeedType
Definition: gridpart.hh:127
Partition< InteriorBorder_Partition >::IteratorType IteratorType
Definition: gridpart.hh:136
Traits::template Codim< codim >::GeometryType GeometryType
Definition: gridpart.hh:123
Traits::template Codim< codim >::LocalGeometryType LocalGeometryType
Definition: gridpart.hh:124
Traits::template Codim< codim >::template Partition< pitype >::IteratorType IteratorType
Definition: gridpart.hh:133
Default implementation for the GridPart classes.
Definition: gridpart.hh:299
DofManagerType & dofManager_
Definition: gridpart.hh:327
GridPartTraits Traits
Type of the Traits.
Definition: gridpart.hh:304
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: gridpart.hh:372
GridType & grid_
Definition: gridpart.hh:326
Traits::template Codim< EntitySeed::codimension >::EntityType entity(const EntitySeed &seed) const
obtain entity pointer from entity seed
Definition: gridpart.hh:362
IntersectionIteratorType::Intersection IntersectionType
type of intersection
Definition: gridpart.hh:314
const GridType & grid() const
Returns const reference to the underlying grid.
Definition: gridpart.hh:342
int boundaryId(const IntersectionType &intersection) const
obtain entity pointer from entity seed
Definition: gridpart.hh:387
GridType & grid()
Returns reference to the underlying grid.
Definition: gridpart.hh:345
Traits::CollectiveCommunicationType CollectiveCommunicationType
Collective communication.
Definition: gridpart.hh:317
const CollectiveCommunicationType & comm() const
obtain collective communication object
Definition: gridpart.hh:348
GridPartDefault(GridType &grid)
constructor
Definition: gridpart.hh:330
int sequence() const
return sequence number to update structures depending on the grid part
Definition: gridpart.hh:381
Traits::IndexSetType IndexSetType
Index set implementation.
Definition: gridpart.hh:308
BoundaryIdProvider< GridType > BoundaryIdProviderType
type of boundary id provider specialized for each grid type
Definition: gridpart.hh:323
DofManager< GridType > DofManagerType
type of DofManager
Definition: gridpart.hh:320
Traits::IntersectionIteratorType IntersectionIteratorType
type of intersection iterator
Definition: gridpart.hh:311
GridPartDefault(const ThisType &other)
Definition: gridpart.hh:335
Traits::GridType GridType
Grid implementation.
Definition: gridpart.hh:306
Definition: gridpart.hh:396
Dune::Entity< codim, dim, Grid, EntityImpl > EntityType
Definition: gridpart.hh:401
static const GridEntityType & gridEntity(const EntityType &entity)
Definition: gridpart.hh:404
Dune::Entity< codim, dim, Grid, EntityImpl > GridEntityType
Definition: gridpart.hh:402
Definition: gridpart.hh:419
TraitsImp ::GridPartType GridPartType
Definition: gridpart.hh:420
GridPart2GridViewImpl< GridPartType > GridViewType
Definition: gridpart.hh:421
AddGridView(const AddGridView &other)
Definition: gridpart.hh:432
AddGridView(const GridViewType *gridView)
Definition: gridpart.hh:428
AddGridView()
Definition: gridpart.hh:437
const GridViewType * gridView_
Definition: gridpart.hh:423
std::shared_ptr< GridViewType > gridViewStorage_
Definition: gridpart.hh:422
const GridViewType & gridView() const
Definition: gridpart.hh:441
AddGridView(const GridPartType *gridPart)
Definition: gridpart.hh:424
Definition: gridpart2gridview.hh:69
Definition: policies.hh:95
Definition: boundaryidprovider.hh:36
Definition: dofmanager.hh:762