DUNE PDELab (2.8)

scsgmapper.hh
Go to the documentation of this file.
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_GRID_COMMON_SCSGMAPPER_HH
4#define DUNE_GRID_COMMON_SCSGMAPPER_HH
5
6#include <iostream>
7#include "mapper.hh"
8
10
17namespace Dune
18{
35 template <typename GV, int c>
37 public Mapper<typename GV::Grid,SingleCodimSingleGeomTypeMapper<GV,c>, typename GV::IndexSet::IndexType >
38 {
39 public:
40
42 typedef typename GV::IndexSet::IndexType Index;
43
48 using size_type = decltype(std::declval<typename GV::IndexSet>().size(0));
49
55 : gridView_(gridView)
56 , indexSet_(&gridView_.indexSet())
57 {
58 // check that grid has only a single geometry type
59 if (indexSet_->types(c).size() != 1)
60 DUNE_THROW(GridError, "mapper treats only a single codim and a single geometry type");
61 }
62
68 template<class EntityType>
69 Index index (const EntityType& e) const
70 {
71 static_assert(EntityType::codimension == c, "Entity of wrong codim passed to SingleCodimSingleGeomTypeMapper");
72 return indexSet_->index(e);
73 }
74
82 Index subIndex (const typename GV::template Codim<0>::Entity& e,
83 int i, unsigned int codim) const
84 {
85 if (codim != c)
86 DUNE_THROW(GridError, "Id of wrong codim requested from SingleCodimSingleGeomTypeMapper");
87 return indexSet_->subIndex(e,i,codim);
88 }
89
98 size_type size () const
99 {
100 return indexSet_->size(c);
101 }
102
109 template<class EntityType>
110 bool contains (const EntityType& e, Index& result) const
111 {
112 result = index(e);
113 return true;
114 }
115
124 bool contains (const typename GV::template Codim<0>::Entity& e, int i, int cc, Index& result) const
125 {
126 result = subIndex(e,i,cc);
127 return true;
128 }
129
135 void update (const GV& gridView)
136 {
137 gridView_ = gridView;
138 indexSet_ = &gridView_.indexSet();
139 }
140
146 void update (GV&& gridView)
147 {
148 gridView_ = std::move(gridView);
149 indexSet_ = &gridView_.indexSet();
150 }
151
154 [[deprecated("Use update(gridView) instead! Will be removed after release 2.8.")]]
155 void update ()
156 { // nothing to do here
157 }
158
159 private:
160 GV gridView_;
161 const typename GV::IndexSet* indexSet_;
162 };
163
182 template <typename G, int c>
183 class [[deprecated("Use SingleCodimSingleGeomTypeMapper instead! Will be removed after release 2.8.")]]
184 LeafSingleCodimSingleGeomTypeMapper : public SingleCodimSingleGeomTypeMapper<typename G::LeafGridView,c> {
186 public:
191 : Base(grid.leafGridView())
192 , gridPtr_(&grid)
193 {}
194
200 void update ()
201 {
202 Base::update(gridPtr_->leafGridView());
203 }
204
205 private:
206 const G* gridPtr_;
207 };
208
220 template <typename G, int c>
221 class [[deprecated("Use SingleCodimSingleGeomTypeMapper instead! Will be removed after release 2.8.")]]
222 LevelSingleCodimSingleGeomTypeMapper : public SingleCodimSingleGeomTypeMapper<typename G::LevelGridView,c> {
224 public:
225 /* @brief The constructor
226 @param grid A reference to a grid.
227 @param level A valid level of the grid.
228 */
229 LevelSingleCodimSingleGeomTypeMapper (const G& grid, int level)
230 : Base(grid.levelGridView(level))
231 , gridPtr_(&grid)
232 , level_(level)
233 {}
234
240 void update ()
241 {
242 Base::update(gridPtr_->levelGridView(level_));
243 }
244
245 private:
246 const G* gridPtr_;
247 int level_;
248 };
249
251}
252#endif
Base class for exceptions in Dune grid modules.
Definition: exceptions.hh:18
Single codim and single geometry type mapper for leaf entities.
Definition: scsgmapper.hh:184
LeafSingleCodimSingleGeomTypeMapper(const G &grid)
The constructor.
Definition: scsgmapper.hh:190
void update()
Recalculates indices after grid adaptation.
Definition: scsgmapper.hh:200
Single codim and single geometry type mapper for entities of one level.
Definition: scsgmapper.hh:222
void update()
Recalculates indices after grid adaptation.
Definition: scsgmapper.hh:240
Mapper interface.
Definition: mapper.hh:108
Implementation class for a single codim and single geometry type mapper.
Definition: scsgmapper.hh:38
bool contains(const EntityType &e, Index &result) const
Returns true if the entity is contained in the index set.
Definition: scsgmapper.hh:110
GV::IndexSet::IndexType Index
Number type used for indices.
Definition: scsgmapper.hh:42
bool contains(const typename GV::template Codim< 0 >::Entity &e, int i, int cc, Index &result) const
Returns true if the entity is contained in the index set.
Definition: scsgmapper.hh:124
decltype(std::declval< typename GV::IndexSet >().size(0)) size_type
Number type used for the overall size (the return value of the 'size' method)
Definition: scsgmapper.hh:48
Index index(const EntityType &e) const
Map entity to array index.
Definition: scsgmapper.hh:69
Index subIndex(const typename GV::template Codim< 0 >::Entity &e, int i, unsigned int codim) const
Map subentity of codim 0 entity to array index.
Definition: scsgmapper.hh:82
SingleCodimSingleGeomTypeMapper(const GV &gridView)
Construct mapper from grid and one of its index sets.
Definition: scsgmapper.hh:54
void update(GV &&gridView)
Recalculates indices after grid adaptation.
Definition: scsgmapper.hh:146
size_type size() const
Return total number of entities in the entity set managed by the mapper.
Definition: scsgmapper.hh:98
void update()
Recalculates indices after grid adaptation.
Definition: scsgmapper.hh:155
void update(const GV &gridView)
Recalculates indices after grid adaptation.
Definition: scsgmapper.hh:135
Different resources needed by all grid implementations.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
Grid< dim, dimworld, ct, GridFamily >::LeafGridView leafGridView(const Grid< dim, dimworld, ct, GridFamily > &grid)
leaf grid view for the given grid
Definition: grid.hh:808
Provides classes with basic mappers which are used to attach data to a grid.
Dune namespace.
Definition: alignedallocator.hh:11
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 (Dec 21, 23:30, 2024)