Dune Core Modules (2.5.0)

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{
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
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 index (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
77 Index subIndex (const typename GV::template Codim<0>::Entity& e,
78 int i, unsigned int codim) const
79 {
80 if (codim != c)
81 DUNE_THROW(GridError, "Id of wrong codim requested from SingleCodimSingleGeomTypeMapper");
82 return is.subIndex(e,i,codim);
83 }
84
93 int size () const
94 {
95 return is.size(c);
96 }
97
104 template<class EntityType>
105 bool contains (const EntityType& e, Index& result) const
106 {
107 result = index(e);
108 return true;
109 }
110
119 bool contains (const typename GV::template Codim<0>::Entity& e, int i, int cc, Index& result) const
120 {
121 result = subIndex(e,i,cc);
122 return true;
123 }
124
127 void update ()
128 { // nothing to do here
129 }
130
131 private:
132 const typename GV::IndexSet& is;
133 };
134
153 template <typename G, int c>
154 class LeafSingleCodimSingleGeomTypeMapper : public SingleCodimSingleGeomTypeMapper<typename G::LeafGridView,c> {
155 public:
160 : SingleCodimSingleGeomTypeMapper<typename G::LeafGridView,c>(grid.leafGridView())
161 {}
162 };
163
175 template <typename G, int c>
176 class LevelSingleCodimSingleGeomTypeMapper : public SingleCodimSingleGeomTypeMapper<typename G::LevelGridView,c> {
177 public:
178 /* @brief The constructor
179 @param grid A reference to a grid.
180 @param level A valid level of the grid.
181 */
182 LevelSingleCodimSingleGeomTypeMapper (const G& grid, int level)
184 {}
185 };
186
188}
189#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:154
LeafSingleCodimSingleGeomTypeMapper(const G &grid)
The constructor.
Definition: scsgmapper.hh:159
Single codim and single geometry type mapper for entities of one level.
Definition: scsgmapper.hh:176
Mapper interface.
Definition: mapper.hh:107
Implementation class for a single codim and single geometry type mapper.
Definition: scsgmapper.hh:40
bool contains(const EntityType &e, Index &result) const
Returns true if the entity is contained in the index set.
Definition: scsgmapper.hh:105
GV::IndexSet::IndexType Index
Number type used for indices.
Definition: scsgmapper.hh:44
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:119
Index index(const EntityType &e) const
Map entity to array index.
Definition: scsgmapper.hh:64
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:77
SingleCodimSingleGeomTypeMapper(const GV &gridView)
Construct mapper from grid and one of its index sets.
Definition: scsgmapper.hh:50
void update()
Recalculates map after mesh adaptation.
Definition: scsgmapper.hh:127
int size() const
Return total number of entities in the entity set managed by the mapper.
Definition: scsgmapper.hh:93
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:874
Provides classes with basic mappers which are used to attach data to a grid.
Dune namespace.
Definition: alignment.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 (Nov 23, 23:29, 2024)