dune-grid  2.11
yaspgridindexsets.hh
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2 // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4 // vi: set et ts=4 sw=2 sts=2:
5 #ifndef DUNE_GRID_YASPGRIDINDEXSET_HH
6 #define DUNE_GRID_YASPGRIDINDEXSET_HH
7 
14 namespace Dune {
15 
22  template<class GridImp, bool isLeafIndexSet>
23  class YaspIndexSet
24  : public IndexSet< GridImp, YaspIndexSet< GridImp, isLeafIndexSet >, unsigned int, std::array<GeometryType, 1> >
25  {
26  typedef YaspIndexSet< GridImp, isLeafIndexSet > This;
27  typedef IndexSet< GridImp, This, unsigned int, std::array<GeometryType, 1> > Base;
28 
29  public:
30  typedef typename Base::IndexType IndexType;
31 
32  using Base::subIndex;
33 
35  YaspIndexSet ( const GridImp &g, int l )
36  : grid( g ),
37  level( l )
38  {
39  assert(not isLeafIndexSet);
40  }
41 
43  YaspIndexSet ( const GridImp &g )
44  : grid( g )
45  {
46  assert(isLeafIndexSet);
47  }
48 
50  template<int cc>
51  IndexType index (const typename std::remove_const<GridImp>::type::Traits::template Codim<cc>::Entity& e) const
52  {
53  return e.impl().compressedIndex();
54  }
55 
57  template< int cc >
58  IndexType subIndex ( const typename std::remove_const< GridImp >::type::Traits::template Codim< cc >::Entity &e,
59  int i, unsigned int codim ) const
60  {
61  return e.impl().subCompressedIndex(i, codim);
62  }
63 
65  std::size_t size (GeometryType type) const
66  {
67  return (isLeafIndexSet)
68  ? grid.size( type )
69  : grid.size( level, type );
70  }
71 
73  std::size_t size (int codim) const
74  {
75  return (isLeafIndexSet)
76  ? grid.size( codim )
77  : grid.size( level, codim );
78  }
79 
81  template<class EntityType>
82  bool contains (const EntityType& e) const
83  {
84  return (isLeafIndexSet)
85  ? e.level() == grid.maxLevel()
86  : e.level() == level;
87  }
88 
90  static constexpr std::array<GeometryType, 1> types (int codim)
91  {
92  return { GeometryTypes::cube(GridImp::dimension - codim) };
93  }
94 
95  private:
96  const GridImp& grid;
97  int level;
98  };
99 
100 } // namespace Dune
101 
102 #endif // DUNE_GRID_YASPGRIDINDEXSET_HH
concept Entity
Model of a grid entity.
Definition: concepts/entity.hh:119
static constexpr std::array< GeometryType, 1 > types(int codim)
obtain all geometry types of entities in domain
Definition: yaspgridindexsets.hh:90
IndexType subIndex(const typename Traits::template Codim< cc >::Entity &e, int i, unsigned int codim) const
Map a subentity to an index.
Definition: common/indexidset.hh:153
YaspIndexSet(const GridImp &g)
Level grid view constructor stores reference to a grid and level.
Definition: yaspgridindexsets.hh:43
IndexType index(const typename std::remove_const< GridImp >::type::Traits::template Codim< cc >::Entity &e) const
get index of an entity
Definition: yaspgridindexsets.hh:51
std::size_t size(GeometryType type) const
get number of entities of given type and level (the level is known to the object) ...
Definition: yaspgridindexsets.hh:65
IndexType subIndex(const typename std::remove_const< GridImp >::type::Traits::template Codim< cc >::Entity &e, int i, unsigned int codim) const
get index of subentity of an entity
Definition: yaspgridindexsets.hh:58
bool contains(const EntityType &e) const
return true if the given entity is contained in .
Definition: yaspgridindexsets.hh:82
IndexTypeImp IndexType
The type used for the indices.
Definition: common/indexidset.hh:92
Include standard header files.
Definition: agrid.hh:59
std::size_t size(int codim) const
return size of set for a given codim
Definition: yaspgridindexsets.hh:73
Base::IndexType IndexType
Definition: yaspgridindexsets.hh:30
GeometryType
Type representing VTK&#39;s entity geometry types.
Definition: common.hh:132
YaspIndexSet(const GridImp &g, int l)
Level grid view constructor stores reference to a grid and level.
Definition: yaspgridindexsets.hh:35
concept IndexSet
Model of an index set.
Definition: concepts/indexidset.hh:55