Dune Core Modules (2.6.0)

universalmapper.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_UNIVERSALMAPPER_HH
4#define DUNE_GRID_COMMON_UNIVERSALMAPPER_HH
5
6#include <iostream>
7#include <map>
8
10
11#include "mapper.hh"
12
13#warning "<dune/grid/common/universalmapper.hh> is deprecated in DUNE 2.6"
14
21namespace Dune
22{
40 template <typename G, typename IDS, typename IndexType=int>
42 public Mapper<G,UniversalMapper<G,IDS> >
43 {
44 typedef typename IDS::IdType IdType;
45 public:
46
48 typedef IndexType Index;
49
56 DUNE_DEPRECATED_MSG("UniversalMapper is deprecated in DUNE 2.6")
57 UniversalMapper (const G& grid, const IDS& idset)
58 : g(grid), ids(idset), index_()
59 {
60 n=0; // zero data elements
61 }
62
70 template<class EntityType>
71 Index index (const EntityType& e) const
72 {
73 IdType id = ids.id(e); // get id
74 typename std::map<IdType,Index>::iterator it = index_.find(id); // look up in map
75 if (it!=index_.end()) return it->second; // return index if found
76 index_[id] = n++; // put next index in map
77 return n-1; // and return it
78 }
79
89 Index subIndex (const typename G::Traits::template Codim<0>::Entity& e, int i, int cc) const
90 {
91 IdType id = ids.subId(e,i,cc); // get id
92 typename std::map<IdType,Index>::iterator it = index_.find(id); // look up in map
93 if (it!=index_.end()) return it->second; // return index if found
94 index_[id] = n++; // put next index in map
95 return n-1; // and return it
96 }
97
106 int size () const
107 {
108 return n;
109 }
110
119 template<class EntityType>
120 bool contains (const EntityType& e, Index& result) const
121 {
122 IdType id = ids.id(e); // get id
123 typename std::map<IdType,Index>::iterator it = index_.find(id); // look up in map
124 if (it!=index_.end())
125 {
126 result = it->second;
127 return true;
128 }
129 else
130 return false;
131 }
132
141 bool contains (const typename G::Traits::template Codim<0>::Entity& e, int i, int cc, Index& result) const
142 {
143 IdType id = ids.subId(e,i,cc); // get id
144 typename std::map<IdType,Index>::iterator it = index_.find(id); // look up in map
145 if (it!=index_.end())
146 {
147 result = it->second;
148 return true;
149 }
150 else
151 return false;
152 }
153
156 void update ()
157 { // nothing to do here
158 }
159
160 // clear the mapper
161 void clear ()
162 {
163 index_.clear();
164 n = 0;
165 }
166
167 private:
168 mutable int n; // number of data elements required
169 const G& g;
170 const IDS& ids;
171 mutable std::map<IdType,Index> index_;
172 };
173
174
175
176
183 template <typename G>
184 class GlobalUniversalMapper : public UniversalMapper<G,typename G::Traits::GlobalIdSet>
185 {
186 public:
187 /* @brief The constructor
188 @param grid A reference to a grid.
189 */
190 DUNE_DEPRECATED_MSG("GlobalUniversalMapper is deprecated in DUNE 2.6")
191 GlobalUniversalMapper (const G& grid)
192 : UniversalMapper<G,typename G::Traits::GlobalIdSet>(grid,grid.globalIdSet())
193 {}
194 };
195
202 template <typename G>
203 class LocalUniversalMapper : public UniversalMapper<G,typename G::Traits::LocalIdSet>
204 {
205 public:
210 DUNE_DEPRECATED_MSG("LocalUniversalMapper is deprecated in DUNE 2.6")
211 LocalUniversalMapper (const G& grid)
212 : UniversalMapper<G,typename G::Traits::LocalIdSet>(grid,grid.localIdSet())
213 {}
214 };
215
216
218}
219#endif
Universal mapper based on global ids.
Definition: universalmapper.hh:185
Universal mapper based on local ids.
Definition: universalmapper.hh:204
Mapper interface.
Definition: mapper.hh:107
Implements a mapper for an arbitrary subset of entities.
Definition: universalmapper.hh:43
bool contains(const EntityType &e, Index &result) const
Returns true if the entity is contained in the index set.
Definition: universalmapper.hh:120
Index subIndex(const typename G::Traits::template Codim< 0 >::Entity &e, int i, int cc) const
Map subentity of codim 0 entity to array index.
Definition: universalmapper.hh:89
bool contains(const typename G::Traits::template Codim< 0 >::Entity &e, int i, int cc, Index &result) const
Returns true if the entity is contained in the index set.
Definition: universalmapper.hh:141
IndexType Index
Number type used for indices.
Definition: universalmapper.hh:48
Index index(const EntityType &e) const
Map entity to array index.
Definition: universalmapper.hh:71
int size() const
Return total number of entities in the entity set managed by the mapper.
Definition: universalmapper.hh:106
void update()
Recalculates map after mesh adaptation.
Definition: universalmapper.hh:156
Definition of the DUNE_DEPRECATED macro for the case that config.h is not available.
#define DUNE_DEPRECATED_MSG(text)
Mark some entity as deprecated.
Definition: deprecated.hh:169
Provides classes with basic mappers which are used to attach data to a grid.
Dune namespace.
Definition: alignedallocator.hh:10
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 24, 23:30, 2024)