BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
concrete_entity.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_entity_hpp
22 #define bempp_concrete_entity_hpp
23 
24 #include "../common/common.hpp"
25 
26 #include "concrete_entity_decl.hpp"
27 #include "concrete_entity_pointer.hpp"
28 #include "concrete_range_entity_iterator.hpp"
29 #include "concrete_subentity_iterator.hpp"
30 
31 namespace Bempp
32 {
33 
34 template<typename DuneEntity>
35 template<int codimSub>
36 inline typename boost::disable_if_c<(codimSub <= DuneEntity::dimension), std::auto_ptr<EntityIterator<codimSub> > >::type
37 ConcreteEntity<0, DuneEntity>::subEntityCodimNIterator() const
38 {
39  throw std::logic_error("Entity::subEntityIterator(): invalid subentity codimension");
40 }
41 
42 template<typename DuneEntity>
43 template<int codimSub>
44 inline typename boost::enable_if_c<(codimSub <= DuneEntity::dimension), std::auto_ptr<EntityIterator<codimSub> > >::type
45 ConcreteEntity<0, DuneEntity>::subEntityCodimNIterator() const
46 {
47  typedef ConcreteSubentityIterator<DuneEntity, codimSub> ConcIterator;
48  return std::auto_ptr<EntityIterator<codimSub> >(
49  new ConcIterator(m_dune_entity, m_domain_index));
50 }
51 
52 template<typename DuneEntity>
53 std::auto_ptr<EntityPointer<0> > ConcreteEntity<0, DuneEntity>::father() const
54 {
56  if (m_dune_entity->hasFather())
57  return std::auto_ptr<EntityPointer<0> >(
58  new ConcPointer(m_dune_entity->father(), m_domain_index));
59  else
60  return std::auto_ptr<EntityPointer<0> >(0);
61 }
62 
63 template<typename DuneEntity>
64 std::auto_ptr<EntityIterator<0> > ConcreteEntity<0, DuneEntity>::sonIterator(
65  int maxlevel) const
66 {
67  typedef typename DuneEntity::HierarchicIterator DuneIterator;
68  typedef typename DuneEntity::EntityPointer DuneEntityPointer;
70  return std::auto_ptr<EntityIterator<0> >(
71  new ConcIterator(m_dune_entity->hbegin(maxlevel),
72  m_dune_entity->hend(maxlevel),
73  m_domain_index));
74 }
75 
76 } // namespace Bempp
77 
78 #endif
Abstract base class for an object providing read-only access to an entity of codimension codim...
Definition: entity_pointer.hpp:42
Wrapper of a Dune entity pointer of type DuneEntityPointer.
Definition: concrete_entity_pointer.hpp:37
Iterator over entities referenced by a range of Dune iterators of type DuneEntityIt.
Definition: concrete_range_entity_iterator.hpp:43
Wrapper of a Dune entity of type DuneEntity and codimension codim.
Definition: concrete_entity_decl.hpp:46