Dune Core Modules (2.9.1)

yaspgridindexsets.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 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
14namespace Dune {
15
22 template<class GridImp, bool isLeafIndexSet>
24 : public IndexSet< GridImp, YaspIndexSet< GridImp, isLeafIndexSet >, unsigned int >
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 // contains a single element type;
42 for (int codim=0; codim<=GridImp::dimension; codim++)
43 mytypes[codim].push_back(GeometryTypes::cube(GridImp::dimension-codim));
44 }
45
47 YaspIndexSet ( const GridImp &g )
48 : grid( g )
49 {
50 assert(isLeafIndexSet);
51
52 // contains a single element type;
53 for (int codim=0; codim<=GridImp::dimension; codim++)
54 mytypes[codim].push_back(GeometryTypes::cube(GridImp::dimension-codim));
55 }
56
58 template<int cc>
59 IndexType index (const typename std::remove_const<GridImp>::type::Traits::template Codim<cc>::Entity& e) const
60 {
61 return e.impl().compressedIndex();
62 }
63
65 template< int cc >
66 IndexType subIndex ( const typename std::remove_const< GridImp >::type::Traits::template Codim< cc >::Entity &e,
67 int i, unsigned int codim ) const
68 {
69 return e.impl().subCompressedIndex(i, codim);
70 }
71
73 std::size_t size (GeometryType type) const
74 {
75 return (isLeafIndexSet)
76 ? grid.size( type )
77 : grid.size( level, type );
78 }
79
81 std::size_t size (int codim) const
82 {
83 return (isLeafIndexSet)
84 ? grid.size( codim )
85 : grid.size( level, codim );
86 }
87
89 template<class EntityType>
90 bool contains (const EntityType& e) const
91 {
92 return (isLeafIndexSet)
93 ? e.level() == grid.maxLevel()
94 : e.level() == level;
95 }
96
97 std::vector< GeometryType > types ( int codim ) const { return mytypes[ codim ]; }
98
100 const std::vector<GeometryType>& geomTypes (int codim) const
101 {
102 return mytypes[codim];
103 }
104
105 private:
106 const GridImp& grid;
107 int level;
108 std::vector<GeometryType> mytypes[std::remove_const<GridImp>::type::dimension+1];
109 };
110
111} // namespace Dune
112
113#endif // DUNE_GRID_YASPGRIDINDEXSET_HH
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:126
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
const std::vector< GeometryType > & geomTypes(int codim) const
deliver all geometry types used in this grid
Definition: yaspgridindexsets.hh:100
YaspIndexSet(const GridImp &g)
Level grid view constructor stores reference to a grid and level.
Definition: yaspgridindexsets.hh:47
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:59
bool contains(const EntityType &e) const
return true if the given entity is contained in .
Definition: yaspgridindexsets.hh:90
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:73
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:66
std::size_t size(int codim) const
return size of set for a given codim
Definition: yaspgridindexsets.hh:81
constexpr GeometryType cube(unsigned int dim)
Returns a GeometryType representing a hypercube of dimension dim.
Definition: type.hh:473
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.111.3 (Nov 21, 23:30, 2024)