DUNE-FEM (unstable)

extendedentity.hh
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_FEM_GRIDPART_COMMON_ENTITY_HH
4#define DUNE_FEM_GRIDPART_COMMON_ENTITY_HH
5
6#include <dune/grid/common/entity.hh>
7
8namespace Dune
9{
10
21 template<int cd, int dim, class GridImp, template<int,int,class> class EntityImp>
22 class ExtendedEntity : public Dune::Entity< cd, dim, GridImp, EntityImp >
23 {
25 public:
26 using BaseType::BaseType;
27
28 protected:
29 template<typename T>
30 struct ToVoid
31 {
32 typedef void type;
33 };
34
35 template <typename T, typename dummy = void>
36 struct checkHostEntity : std::false_type {};
37
38 template <typename T>
39 struct checkHostEntity<T, typename ToVoid<typename T::HostEntityType>::type > : std::true_type{};
40
41
42 template <class Impl, bool>
43 struct HE {
44 typedef Impl HostEntity;
45 typedef BaseType GridEntity;
46 };
47
48 template <class Impl>
49 struct HE< Impl, true >
50 {
51 private:
52 // type of grid entity
53 typedef typename Impl::HostGridPartType::GridType::template Codim<cd>::Entity __GEType;
54 public:
55 typedef typename Impl::HostEntityType HostEntity;
56 typedef typename
57 std::conditional< std::is_same<HostEntity, __GEType>::value,
58 BaseType, __GEType> :: type GridEntity;
59 };
60
61 public:
62 typedef typename BaseType::Implementation ImplementationType;
63 static constexpr bool hasHostEntity = checkHostEntity< ImplementationType >::value;
64 typedef typename HE< ImplementationType, hasHostEntity >::HostEntity HostEntityType;
66
68 operator const HostEntityType& () const
69 {
70 if constexpr ( hasHostEntity )
71 return this->impl().hostEntity();
72 else
73 return this->impl();
74 }
75
77 operator const GridEntityType& () const
78 {
79 if constexpr ( std::is_same< BaseType, GridEntityType > :: value )
80 return *this;
81 else
82 {
83 return gridEntity(*this);
84 }
85 }
86 };
87
88} // end namespace Dune
89#endif
Wrapper class for entities.
Definition: entity.hh:66
Implementation & impl()
access to the underlying implementation
Definition: entity.hh:80
EntityImp< cd, dim, GridImp > Implementation
type of underlying implementation
Definition: entity.hh:73
GeometryType type() const
Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: entity.hh:146
Wrapper class for wrapped entities added a cast operator to the host entity.
Definition: extendedentity.hh:23
Dune namespace.
Definition: alignedallocator.hh:13
Static tag representing a codimension.
Definition: dimension.hh:24
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)