Dune Core Modules (unstable)

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>
24  : public IndexSet< GridImp, YaspIndexSet< GridImp, isLeafIndexSet >, unsigned int, std::array<GeometryType, 1> >
25  {
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
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
Index Set Interface base class.
Definition: indexidset.hh:78
IndexType subIndex(const typename Traits::template Codim< cc >::Entity &e, int i, unsigned int codim) const
Map a subentity to an index.
Definition: indexidset.hh:153
IndexTypeImp IndexType
The type used for the indices.
Definition: indexidset.hh:92
Implementation of Level- and LeafIndexSets for YaspGrid.
Definition: yaspgridindexsets.hh:25
YaspIndexSet(const GridImp &g)
Level grid view constructor stores reference to a grid and level.
Definition: yaspgridindexsets.hh:43
YaspIndexSet(const GridImp &g, int l)
Level grid view constructor stores reference to a grid and level.
Definition: yaspgridindexsets.hh:35
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
bool contains(const EntityType &e) const
return true if the given entity is contained in .
Definition: yaspgridindexsets.hh:82
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
std::size_t size(int codim) const
return size of set for a given codim
Definition: yaspgridindexsets.hh:73
static constexpr std::array< GeometryType, 1 > types(int codim)
obtain all geometry types of entities in domain
Definition: yaspgridindexsets.hh:90
constexpr GeometryType cube(unsigned int dim)
Returns a GeometryType representing a hypercube of dimension dim.
Definition: type.hh:462
Dune namespace.
Definition: alignedallocator.hh:13
Static tag representing a codimension.
Definition: dimension.hh:24
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 1, 22:29, 2024)