Dune Core Modules (2.3.1)

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// $Id$
4
5#ifndef DUNE_SCSGMAPPER_HH
6#define DUNE_SCSGMAPPER_HH
7
8#include <iostream>
9#include "mapper.hh"
10
12
19namespace Dune
20{
39 template <typename GV, int c>
41 public Mapper<typename GV::Grid,SingleCodimSingleGeomTypeMapper<GV,c> >
42 {
43 public:
44
47 using Mapper< typename GV::Grid, SingleCodimSingleGeomTypeMapper >::map;
48 using Mapper< typename GV::Grid, SingleCodimSingleGeomTypeMapper >::contains;
49
54 SingleCodimSingleGeomTypeMapper (const GV& gridView);
55
61 template<class EntityType>
62 int map (const EntityType& e) const;
63
71 int map (const typename GV::template Codim<0>::Entity& e,
72 int i, unsigned int codim) const;
73
82 int size () const;
83
90 template<class EntityType>
91 bool contains (const EntityType& e, int& result) const;
92
101 bool contains (const typename GV::template Codim<0>::Entity& e, int i, int cc, int& result) const;
102
105 void update ()
106 { // nothing to do here
107 }
108
109 private:
110 const typename GV::IndexSet& is;
111 };
112
115 template <typename GV, int c>
117 : is(gridView.indexSet())
118 {
119 // check that grid has only a single geometry type
120 if (is.geomTypes(c).size() != 1)
121 DUNE_THROW(GridError, "mapper treats only a single codim and a single geometry type");
122 }
123
124 template <typename GV, int c>
125 template<class EntityType>
126 inline int SingleCodimSingleGeomTypeMapper<GV,c>::map (const EntityType& e) const
127 {
128 enum { cc = EntityType::codimension };
129 dune_static_assert(cc == c, "Entity of wrong codim passed to SingleCodimSingleGeomTypeMapper");
130 return is.index(e);
131 }
132
133 template <typename GV, int c>
134 inline int SingleCodimSingleGeomTypeMapper<GV,c>::map (const typename GV::template Codim<0>::Entity& e, int i, unsigned int codim) const
135 {
136 if (codim != c)
137 DUNE_THROW(GridError, "Id of wrong codim requested from SingleCodimSingleGeomTypeMapper");
138 return is.subIndex(e,i,codim);
139 }
140
141 template <typename GV, int c>
143 {
144 return is.size(c);
145 }
146
147 template <typename GV, int c>
148 template<class EntityType>
149 inline bool SingleCodimSingleGeomTypeMapper<GV,c>::contains (const EntityType& e, int& result) const
150 {
151 result = map(e);
152 return true;
153 }
154
155 template <typename GV, int c>
156 inline bool SingleCodimSingleGeomTypeMapper<GV,c>::contains (const typename GV::template Codim<0>::Entity& e, int i, int cc, int& result) const
157 {
158 result = this->map(e,i,cc);
159 return true;
160 }
161
180 template <typename G, int c>
181 class LeafSingleCodimSingleGeomTypeMapper : public SingleCodimSingleGeomTypeMapper<typename G::LeafGridView,c> {
182 public:
183 /* @brief The constructor
184 @param grid A reference to a grid.
185 */
188 {}
189 };
190
204 template <typename G, int c>
205 class LevelSingleCodimSingleGeomTypeMapper : public SingleCodimSingleGeomTypeMapper<typename G::LevelGridView,c> {
206 public:
207 /* @brief The constructor
208 @param grid A reference to a grid.
209 @param level A valid level of the grid.
210 */
211 LevelSingleCodimSingleGeomTypeMapper (const G& grid, int level)
213 {}
214 };
215
217}
218#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:181
Single codim and single geometry type mapper for entities of one level.
Definition: scsgmapper.hh:205
Mapper interface.
Definition: mapper.hh:110
Implementation class for a single codim and single geometry type mapper.
Definition: scsgmapper.hh:42
bool contains(const typename GV::template Codim< 0 >::Entity &e, int i, int cc, int &result) const
Returns true if the entity is contained in the index set.
Definition: scsgmapper.hh:156
int map(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:134
int map(const EntityType &e) const
Map entity to array index.
Definition: scsgmapper.hh:126
SingleCodimSingleGeomTypeMapper(const GV &gridView)
Construct mapper from grid and one of its index sets.
Definition: scsgmapper.hh:116
bool contains(const EntityType &e, int &result) const
Returns true if the entity is contained in the index set.
Definition: scsgmapper.hh:149
void update()
Recalculates map after mesh adaptation.
Definition: scsgmapper.hh:105
int size() const
Return total number of entities in the entity set managed by the mapper.
Definition: scsgmapper.hh:142
Different resources needed by all grid implementations.
#define dune_static_assert(COND, MSG)
Helper template so that compilation fails if condition is not true.
Definition: static_assert.hh:79
#define DUNE_THROW(E, m)
Definition: exceptions.hh:244
Provides classes with basic mappers which are used to attach data to a grid.
Dune namespace.
Definition: alignment.hh:14
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)