Dune Core Modules (2.4.2)

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 
17 namespace Dune
18 {
37  template <typename GV, int c>
39  public Mapper<typename GV::Grid,SingleCodimSingleGeomTypeMapper<GV,c>, typename GV::IndexSet::IndexType >
40  {
41  public:
42 
44  typedef typename GV::IndexSet::IndexType Index;
45 
50  SingleCodimSingleGeomTypeMapper (const GV& gridView)
51  : is(gridView.indexSet())
52  {
53  // check that grid has only a single geometry type
54  if (is.types(c).size() != 1)
55  DUNE_THROW(GridError, "mapper treats only a single codim and a single geometry type");
56  }
57 
63  template<class EntityType>
64  Index DUNE_DEPRECATED_MSG("Will be removed after dune-grid-2.4. Use method 'index' instead!") map (const EntityType& e) const
65  {
66  static_assert(EntityType::codimension == c, "Entity of wrong codim passed to SingleCodimSingleGeomTypeMapper");
67  return is.index(e);
68  }
69 
75  template<class EntityType>
76  Index index (const EntityType& e) const
77  {
78  static_assert(EntityType::codimension == c, "Entity of wrong codim passed to SingleCodimSingleGeomTypeMapper");
79  return is.index(e);
80  }
81 
89  Index DUNE_DEPRECATED_MSG("Will be removed after dune-grid-2.4. Use method 'subIndex' instead!") map (const typename GV::template Codim<0>::Entity& e,
90  int i, unsigned int codim) const
91  {
92  if (codim != c)
93  DUNE_THROW(GridError, "Id of wrong codim requested from SingleCodimSingleGeomTypeMapper");
94  return is.subIndex(e,i,codim);
95  }
96 
104  Index subIndex (const typename GV::template Codim<0>::Entity& e,
105  int i, unsigned int codim) const
106  {
107  if (codim != c)
108  DUNE_THROW(GridError, "Id of wrong codim requested from SingleCodimSingleGeomTypeMapper");
109  return is.subIndex(e,i,codim);
110  }
111 
120  int size () const
121  {
122  return is.size(c);
123  }
124 
131  template<class EntityType>
132  bool contains (const EntityType& e, Index& result) const
133  {
134  result = index(e);
135  return true;
136  }
137 
146  bool contains (const typename GV::template Codim<0>::Entity& e, int i, int cc, Index& result) const
147  {
148  result = subIndex(e,i,cc);
149  return true;
150  }
151 
154  void update ()
155  { // nothing to do here
156  }
157 
158  private:
159  const typename GV::IndexSet& is;
160  };
161 
180  template <typename G, int c>
181  class LeafSingleCodimSingleGeomTypeMapper : public SingleCodimSingleGeomTypeMapper<typename G::LeafGridView,c> {
182  public:
187  : SingleCodimSingleGeomTypeMapper<typename G::LeafGridView,c>(grid.leafGridView())
188  {}
189  };
190 
202  template <typename G, int c>
203  class LevelSingleCodimSingleGeomTypeMapper : public SingleCodimSingleGeomTypeMapper<typename G::LevelGridView,c> {
204  public:
205  /* @brief The constructor
206  @param grid A reference to a grid.
207  @param level A valid level of the grid.
208  */
209  LevelSingleCodimSingleGeomTypeMapper (const G& grid, int level)
211  {}
212  };
213 
215 }
216 #endif
Wrapper class for entities.
Definition: entity.hh:62
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
LeafSingleCodimSingleGeomTypeMapper(const G &grid)
The constructor.
Definition: scsgmapper.hh:186
Single codim and single geometry type mapper for entities of one level.
Definition: scsgmapper.hh:203
Mapper interface.
Definition: mapper.hh:108
Implementation class for a single codim and single geometry type mapper.
Definition: scsgmapper.hh:40
GV::IndexSet::IndexType Index
Number type used for indices.
Definition: scsgmapper.hh:44
Index index(const EntityType &e) const
Map entity to array index.
Definition: scsgmapper.hh:76
SingleCodimSingleGeomTypeMapper(const GV &gridView)
Construct mapper from grid and one of its index sets.
Definition: scsgmapper.hh:50
Index DUNE_DEPRECATED_MSG("Will be removed after dune-grid-2.4. Use method 'index' instead!") map(const EntityType &e) const
Map entity to array index.
Definition: scsgmapper.hh:64
Index DUNE_DEPRECATED_MSG("Will be removed after dune-grid-2.4. Use method 'subIndex' instead!") map(const typename GV
Map subentity of codim 0 entity to array index.
Definition: scsgmapper.hh:89
Different resources needed by all grid implementations.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:243
Provides classes with basic mappers which are used to attach data to a grid.
Dune namespace.
Definition: alignment.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.80.0 (May 16, 22:29, 2024)