Dune Core Modules (2.4.1)

indexsets.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_ALU2DGRIDINDEXSETS_HH
4#define DUNE_ALU2DGRIDINDEXSETS_HH
5
6//- System includes
7#include <vector>
8
9//- Dune includes
12
15
16
17//- Local includes
18#include "alu2dinclude.hh"
19
20namespace Dune
21{
22
23 // External Forward Declarations
24 // -----------------------------
25
26 template< int dim, int dimworld, ALU2DSPACE ElementType eltype >
27 class ALU2dGrid;
28
29 template<int cd, int dim, class GridImp>
30 class ALU2dGridEntity;
31
32
33
34 // ALU2dGridHierarchicIndexSet
35 // ---------------------------
36
38 template <int dim, int dimworld, ALU2DSPACE ElementType eltype>
40 public IndexSet< ALU2dGrid< dim, dimworld, eltype >,
41 ALU2dGridHierarchicIndexSet< dim, dimworld, eltype >, int >
42 {
44
46 enum { numCodim = dim+1 }; // i.e. 3
47
48 friend class ALU2dGrid< dim, dimworld, eltype >;
49
51 : grid_( grid )
52 {}
53
54 public:
55 typedef typename GridType::Traits::template Codim<0>::Entity EntityCodim0Type;
56
58 template< int codim >
59 int index ( const typename GridType::Traits::template Codim< codim >::Entity &entity ) const
60 {
61 return GridType::getRealImplementation( entity ).getIndex();
62 }
63
65 template< class Entity >
66 int index ( const Entity &entity ) const
67 {
68 return GridType::getRealImplementation( entity ).getIndex();
69 }
70
72 int subIndex ( const EntityCodim0Type &e, int i, unsigned int codim ) const
73 {
74 return grid_.getRealImplementation( e ).subIndex( i, codim);
75 }
76
79 int size ( GeometryType type ) const
80 {
81 const int codim = dim-type.dim();
82 assert( grid_.geomTypes(codim).size() == 1 );
83 if( type != grid_.geomTypes(codim)[0] ) return 0;
84 // return size of hierarchic index set
85 return grid_.hierSetSize(codim);
86 }
87
89 int size ( int codim ) const
90 {
91 // return size of hierarchic index set
92 return grid_.hierSetSize(codim);
93 }
94
96 const std::vector<GeometryType>& geomTypes (int codim) const
97 {
98 return grid_.geomTypes(codim);
99 }
100
102 template <class EntityType>
103 bool contains (const EntityType &) const { return true; }
104
105 private:
106 // our Grid
107 const GridType & grid_;
108 };
109
110 //***********************************************************
111 //
112 // --LocalIdSet
113 //
114 //***********************************************************
115
117 template <int dim, int dimworld, ALU2DSPACE ElementType eltype>
119 public IdSet < ALU2dGrid< dim, dimworld, eltype >,
120 ALU2dGridLocalIdSet< dim, dimworld, eltype >, int >
121 {
124
125 friend class ALU2dGrid< dim, dimworld, eltype >;
126
127 // this means that only up to 300000000 entities are allowed
128 enum { codimMultiplier = 300000000 };
129 typedef typename GridType::Traits::template Codim<0>::Entity EntityCodim0Type;
130
131 // create local id set , only for the grid allowed
132 ALU2dGridLocalIdSet(const GridType & grid) : hset_(grid.hierarchicIndexSet())
133 {
134 for(int i=0; i<dim+1; i++)
135 codimStart_[i] = i*codimMultiplier;
136 }
137
138 // fake method to have the same method like GlobalIdSet
139 void updateIdSet() {}
140
141 public:
143 typedef int IdType;
144
148
150 template <class EntityType>
151 int id (const EntityType & ep) const
152 {
153 enum { cd = EntityType :: codimension };
154 assert( hset_.size(cd) < codimMultiplier );
155 return codimStart_[cd] + hset_.index(ep);
156 }
157
159 template <int codim>
160 int id (const typename GridType:: template Codim<codim> :: Entity & ep) const
161 {
162 //enum { cd = EntityType :: codimension };
163 assert( hset_.size(codim) < codimMultiplier );
164 return codimStart_[codim] + hset_.index(ep);
165 }
166
168 int subId ( const EntityCodim0Type &e, int i, unsigned int codim ) const
169 {
170 assert( hset_.size( codim ) < codimMultiplier );
171 return codimStart_[ codim ] + hset_.subIndex( e, i, codim );
172 }
173
174 private:
175 // our HierarchicIndexSet
176 const HierarchicIndexSetType & hset_;
177
178 // store start of each codim numbers
179 int codimStart_[dim+1];
180 };
181
182} // end namespace Dune
183
184#endif
Portable very large unsigned integers.
hierarchic index set of ALU2dGrid
Definition: indexsets.hh:42
const std::vector< GeometryType > & geomTypes(int codim) const
deliver all geometry types used in this grid
Definition: indexsets.hh:96
int size(GeometryType type) const
Definition: indexsets.hh:79
int index(const typename GridType::Traits::template Codim< codim >::Entity &entity) const
return hierarchic index of given entity
Definition: indexsets.hh:59
int index(const Entity &entity) const
return hierarchic index of given entity
Definition: indexsets.hh:66
int subIndex(const EntityCodim0Type &e, int i, unsigned int codim) const
return subIndex of given entity for codim sub entity
Definition: indexsets.hh:72
int size(int codim) const
return size of indexset, i.e. maxindex+1
Definition: indexsets.hh:89
bool contains(const EntityType &) const
return true because all entities are contained in this set
Definition: indexsets.hh:103
hierarchic index set of ALU3dGrid
Definition: indexsets.hh:121
int id(const EntityType &ep) const
return global id of given entity
Definition: indexsets.hh:151
int id(const typename GridType::template Codim< codim > ::Entity &ep) const
return global id of given entity
Definition: indexsets.hh:160
int subId(const EntityCodim0Type &e, int i, unsigned int codim) const
return subId of given entity
Definition: indexsets.hh:168
int IdType
export type of id
Definition: indexsets.hh:143
[ provides Dune::Grid ]
Definition: grid.hh:212
const HierarchicIndexSet & hierarchicIndexSet() const
get hierarchic index set of the grid
ALU2dGridHierarchicIndexSet< dim, dimworld, elementType > HierarchicIndexSet
Type of the hierarchic index set.
Definition: grid.hh:275
const std::vector< GeometryType > & geomTypes(int codim) const
deliver all geometry types used in this grid
Definition: grid.hh:441
int hierSetSize(int cd) const
number of grid entities in the entire grid for given codim
Wrapper class for entities.
Definition: entity.hh:62
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:25
unsigned int dim() const
Return dimension of the type.
Definition: type.hh:321
static std::conditional< std::is_reference< InterfaceType >::value, typenamestd::add_lvalue_reference< typenameReturnImplementationType< typenamestd::remove_reference< InterfaceType >::type >::ImplementationType >::type, typenamestd::remove_const< typenameReturnImplementationType< typenamestd::remove_reference< InterfaceType >::type >::ImplementationType >::type >::type getRealImplementation(InterfaceType &&i)
return real implementation of interface class
Definition: grid.hh:1305
Id Set Interface.
Definition: indexidset.hh:414
Index Set Interface base class.
Definition: indexidset.hh:76
Different resources needed by all grid implementations.
Provides base classes for index and id sets.
Dune namespace.
Definition: alignment.hh:10
Standard Dune debug streams.
Static tag representing a codimension.
Definition: dimension.hh:22
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)