BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
concrete_element_mapper.hpp
1 // Copyright (C) 2011-2012 by the BEM++ Authors
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 // THE SOFTWARE.
20 
21 #ifndef bempp_concrete_element_mapper_hpp
22 #define bempp_concrete_element_mapper_hpp
23 
24 #include "../common/common.hpp"
25 
26 #include "mapper.hpp"
27 
28 #include <dune/grid/common/mcmgmapper.hh>
29 
30 namespace Bempp
31 {
32 
36 template <typename DuneGridView>
38 {
39 private:
40  Dune::MultipleCodimMultipleGeomTypeMapper<DuneGridView,
41  Dune::MCMGElementLayout > m_dune_mapper;
42 
43 public:
44  ConcreteElementMapper(const DuneGridView& dune_gv) :
45  m_dune_mapper(dune_gv,
46  Dune::MCMGElementLayout<DuneGridView::dimension>())
47  {}
48 
49  virtual size_t size() const {
50  return m_dune_mapper.size();
51  }
52 
53  virtual size_t entityIndex(const Entity<0>& e) const {
54  typedef typename DuneGridView::template Codim<0>::Entity DuneEntity;
55  typedef ConcreteEntity<0, DuneEntity> ConcEntity;
56  const ConcEntity& ce = dynamic_cast<const ConcEntity&>(e);
57  return m_dune_mapper.map(ce.duneEntity());
58  }
59 
60  virtual size_t entityIndex(const Entity<1>& e) const {
61  throw std::logic_error("ConcreteElementMapper::entityIndex(): "
62  "entities of codimension 1 do not belong to the "
63  "managed set.");
64  }
65 
66  virtual size_t entityIndex(const Entity<2>& e) const {
67  throw std::logic_error("ConcreteElementMapper::entityIndex(): "
68  "entities of codimension 2 do not belong to the "
69  "managed set.");
70  }
71 
72  virtual size_t entityIndex(const Entity<3>& e) const {
73  throw std::logic_error("ConcreteElementMapper::entityIndex(): "
74  "entities of codimension 2 do not belong to the "
75  "managed set.");
76  }
77 
78  virtual size_t subEntityIndex(const Entity<0>& e, size_t i,
79  int codimSub) const {
80  typedef typename DuneGridView::template Codim<0>::Entity DuneEntity;
81  typedef ConcreteEntity<0, DuneEntity> ConcEntity;
82  const ConcEntity& ce = dynamic_cast<const ConcEntity&>(e);
83  return m_dune_mapper.map(ce.duneEntity(), i, codimSub);
84  }
85 };
86 
87 } // namespace Bempp
88 
89 #endif
Abstract wrapper of an entity of codimension codim.
Definition: entity.hpp:46
virtual size_t entityIndex(const Entity< 1 > &e) const
Index of the entity of codimension 1.
Definition: concrete_element_mapper.hpp:60
Wrapper of a Dune entity of type DuneEntity and codimension 0.
Definition: concrete_entity_decl.hpp:117
virtual size_t entityIndex(const Entity< 2 > &e) const
Index of the entity of codimension 2.
Definition: concrete_element_mapper.hpp:66
An injective mapping from the full set of codimension-0 entities (&quot;elements&quot;) of a grid to the intege...
Definition: concrete_element_mapper.hpp:37
virtual size_t size() const
Total number of entities in the entity set managed by the mapper.
Definition: concrete_element_mapper.hpp:49
virtual size_t subEntityIndex(const Entity< 0 > &e, size_t i, int codimSub) const
Index of i&#39;th subentity of codimension codimSub of entity e of codimension 0.
Definition: concrete_element_mapper.hpp:78
virtual size_t entityIndex(const Entity< 0 > &e) const
Index of the entity of codimension 0.
Definition: concrete_element_mapper.hpp:53
virtual size_t entityIndex(const Entity< 3 > &e) const
Index of the entity of codimension 3.
Definition: concrete_element_mapper.hpp:72
Abstract wrapper of an entity of codimension 0.
Definition: entity.hpp:81
Abstract mapper class.
Definition: mapper.hpp:39