DUNE-FEM (unstable)

entity.hh
1#ifndef DUNE_FEM_GRIDPART_GEOMETRYGRIDPART_ENTITY_HH
2#define DUNE_FEM_GRIDPART_GEOMETRYGRIDPART_ENTITY_HH
3
4#include <type_traits>
5#include <utility>
6
7#include <dune/grid/common/entity.hh>
8#include <dune/grid/common/gridenums.hh>
9
10#include <dune/fem/gridpart/common/defaultgridpartentity.hh>
11
12namespace Dune
13{
14
15 namespace Fem
16 {
17
18 // GeometryGridPartEntity
19 // ----------------------
20
21 template< int codim, int dim, class GridFamily >
22 class GeometryGridPartEntity
23 : public DefaultGridPartEntity < codim, dim, GridFamily >
24 {
25 typedef typename std::remove_const< GridFamily >::type::Traits Traits;
26 typedef typename Traits::GridFunctionType GridFunctionType;
27
28 //typedef typename GridFamily::GridType GridType;
29 //typedef typename GridType::template Codim<codim>::Entity GridEntityType;
30
31 public:
32 static const int codimension = codim;
33 static const int dimension = std::remove_const< GridFamily >::type::dimension;
34 static const int mydimension = dimension - codimension;
35 static const int dimensionworld = std::remove_const< GridFamily >::type::dimensionworld;
36
37 typedef typename std::remove_const< GridFamily >::type::ctype ctype;
38
39 typedef typename Traits::template Codim< codimension >::EntitySeed EntitySeed;
40 typedef typename Traits::template Codim< codimension >::Geometry Geometry;
41
42 typedef typename Traits::HostGridPartType HostGridPartType;
43 private:
44 typedef typename Geometry::Implementation GeometryImplType;
45
46 public:
47 typedef typename HostGridPartType::template Codim< codimension >::EntityType HostEntityType;
48
49 GeometryGridPartEntity () = default;
50
51 GeometryGridPartEntity ( const GridFunctionType &gridFunction, HostEntityType hostEntity )
52 : hostEntity_( std::move( hostEntity ) ), gridFunction_( &gridFunction )
53 {}
54
55 GeometryType type () const
56 {
57 return hostEntity().type();
58 }
59
60 PartitionType partitionType () const
61 {
62 return hostEntity().partitionType();
63 }
64
65 unsigned int subEntities ( unsigned int c ) const { return hostEntity().subEntities( c ); }
66
67 Geometry geometry () const
68 {
69 DUNE_THROW( NotImplemented, "GeometryGridPart only implements the geometry for entities of codimension 0." );
70 }
71
72 EntitySeed seed () const { return EntitySeed( hostEntity().seed() ); }
73
74 bool equals ( const GeometryGridPartEntity &rhs ) const
75 {
76 return hostEntity() == rhs.hostEntity();
77 }
78
79 const HostEntityType &hostEntity () const
80 {
81 return hostEntity_;
82 }
83
84 const GridFunctionType &gridFunction () const
85 {
86 assert( gridFunction_ );
87 return *gridFunction_;
88 }
89
90 private:
91 HostEntityType hostEntity_;
92 const GridFunctionType *gridFunction_ = nullptr;
93 };
94
95
96
97 // GeometryGridPartEntity for codimension 0
98 // ----------------------------------------
99
100 template< int dim, class GridFamily >
101 class GeometryGridPartEntity< 0, dim, GridFamily >
102 : public DefaultGridPartEntity < 0, dim, GridFamily >
103 {
104 typedef typename std::remove_const< GridFamily >::type::Traits Traits;
105 typedef typename Traits::GridFunctionType GridFunctionType;
106
107 public:
108 static const int codimension = 0;
109 static const int dimension = std::remove_const< GridFamily >::type::dimension;
110 static const int mydimension = dimension - codimension;
111 static const int dimensionworld = std::remove_const< GridFamily >::type::dimensionworld;
112
113 typedef typename std::remove_const< GridFamily >::type::ctype ctype;
114
115 typedef typename Traits::template Codim< codimension >::EntitySeed EntitySeed;
116 typedef typename Traits::template Codim< codimension >::Geometry Geometry;
117 typedef typename Traits::template Codim< codimension >::LocalGeometry LocalGeometry;
118
119 typedef typename Traits::HierarchicIterator HierarchicIterator;
120 typedef typename Traits::LeafIntersectionIterator LeafIntersectionIterator;
121 typedef typename Traits::LevelIntersectionIterator LevelIntersectionIterator;
122
123 typedef typename Traits::HostGridPartType HostGridPartType;
124 private:
125 typedef typename HostGridPartType::GridType GridType;
126
127 public:
128 typedef typename HostGridPartType::template Codim< codimension >::EntityType HostEntityType;
129
130 GeometryGridPartEntity () = default;
131
132 GeometryGridPartEntity ( const GridFunctionType &gridFunction, HostEntityType hostEntity )
133 : hostEntity_( std::move( hostEntity ) ), gridFunction_( &gridFunction )
134 {}
135
136 template< class LocalFunction >
137 GeometryGridPartEntity ( const GeometryGridPartEntity &other, const LocalFunction &localGridFunction )
138 : hostEntity_( other.hostEntity_ ), gridFunction_( other.gridFunction_ )
139 {
140 }
141
142 GeometryType type () const
143 {
144 return hostEntity().type();
145 }
146
147 PartitionType partitionType () const
148 {
149 return hostEntity().partitionType();
150 }
151
152 Geometry geometry () const
153 {
154 typedef typename Geometry::Implementation Impl;
155 Impl impl( gridFunction() );
156 impl.impl().bind( hostEntity() );
157 return Geometry( impl );
158 }
159
160 EntitySeed seed () const { return EntitySeed( hostEntity().seed() ); }
161
162 template< int codim >
163 int count () const
164 {
165 return hostEntity().template count< codim >();
166 }
167
168 unsigned int subEntities ( unsigned int codim ) const { return hostEntity().subEntities( codim ); }
169
170 template< int codim >
171 typename Traits::template Codim< codim >::Entity subEntity ( int i ) const
172 {
173 typedef typename Traits::template Codim< codim >::Entity::Implementation EntityImpl;
174 return EntityImpl( *gridFunction_, hostEntity().template subEntity< codim >( i ) );
175 }
176
177 bool hasBoundaryIntersections () const
178 {
179 return hostEntity().hasBoundaryIntersections();
180 }
181
182 bool equals ( const GeometryGridPartEntity &rhs ) const
183 {
184 return hostEntity() == rhs.hostEntity();
185 }
186
187 const HostEntityType &hostEntity () const
188 {
189 return hostEntity_;
190 }
191
192 void setHostEntity ( const HostEntityType &hostEntity )
193 {
194 hostEntity_ = &hostEntity;
195 }
196
197 const GridFunctionType &gridFunction () const
198 {
199 assert( gridFunction_ );
200 return *gridFunction_;
201 }
202 private:
203 HostEntityType hostEntity_;
204 const GridFunctionType *gridFunction_ = nullptr;
205 };
206
207 } // namespace Fem
208
209} // namespace Dune
210
211#endif // #ifndef DUNE_FEM_GRIDPART_GEOMETRYGRIDPART_ENTITY_HH
GeometryImp< mydim, cdim, GridImp > Implementation
type of underlying implementation
Definition: geometry.hh:78
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:30
constexpr auto equals(T1 &&t1, T2 &&t2)
Equality comparison.
Definition: hybridutilities.hh:587
Dune namespace.
Definition: alignedallocator.hh:13
STL namespace.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 13, 23:29, 2024)