dune-fem 2.8.0
Loading...
Searching...
No Matches
geogridpart/entity.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_GRIDPART_GEOGRIDPART_ENTITY_HH
2#define DUNE_FEM_GRIDPART_GEOGRIDPART_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
12
13namespace Dune
14{
15
16 namespace Fem
17 {
18
19 // GeoEntity
20 // ---------
21
22 template< int codim, int dim, class GridFamily >
24 : public DefaultGridPartEntity < codim, dim, GridFamily >
25 {
26 typedef typename std::remove_const< GridFamily >::type::Traits Traits;
27
28 public:
29 static const int codimension = codim;
30 static const int dimension = std::remove_const< GridFamily >::type::dimension;
31 static const int mydimension = dimension - codimension;
32 static const int dimensionworld = std::remove_const< GridFamily >::type::dimensionworld;
33
34 typedef typename std::remove_const< GridFamily >::type::ctype ctype;
35
36 typedef typename Traits::template Codim< codimension >::EntitySeed EntitySeed;
37 typedef typename Traits::template Codim< codimension >::Geometry Geometry;
38
39 private:
40 typedef typename Traits::HostGridPartType HostGridPartType;
41 typedef typename Traits::CoordFunctionType CoordFunctionType;
42
43 typedef typename Geometry::Implementation GeometryImplType;
44
46
47 public:
48 typedef typename HostGridPartType::template Codim< codimension >::EntityType HostEntityType;
49
50 GeoEntity () = default;
51
52 GeoEntity ( const CoordFunctionType &coordFunction, HostEntityType hostEntity )
53 : coordFunction_( &coordFunction ),
54 hostEntity_( std::move( hostEntity ) )
55 {}
56
57 GeometryType type () const
58 {
59 return hostEntity().type();
60 }
61
62 PartitionType partitionType () const
63 {
64 return hostEntity().partitionType();
65 }
66
68 {
69 if( !geo_ )
70 {
72 geo_ = GeometryImplType( type(), coords );
73 }
74 return Geometry( geo_ );
75 }
76
77 EntitySeed seed () const { return EntitySeed( hostEntity().seed() ); }
78
79 bool equals ( const GeoEntity &rhs ) const
80 {
81 return hostEntity() == rhs.hostEntity();
82 }
83
84 const CoordFunctionType &coordFunction () const
85 {
86 assert( coordFunction_ );
87 return *coordFunction_;
88 }
89
90 const HostEntityType &hostEntity () const
91 {
92 return hostEntity_;
93 }
94
95 unsigned int subEntities ( unsigned int cdim ) const { return hostEntity().subEntities( cdim ); }
96
97 private:
98 const CoordFunctionType *coordFunction_ = nullptr;
99 HostEntityType hostEntity_;
100
101 mutable GeometryImplType geo_;
102 };
103
104
105
106 // GeoEntity for codimension 0
107 // ---------------------------
108
109 template< int dim, class GridFamily >
110 class GeoEntity< 0, dim, GridFamily >
111 : public DefaultGridPartEntity < 0, dim, GridFamily >
112 {
113 typedef typename std::remove_const< GridFamily >::type::Traits Traits;
114
115 public:
116 static const int codimension = 0;
117 static const int dimension = std::remove_const< GridFamily >::type::dimension;
118 static const int mydimension = dimension - codimension;
119 static const int dimensionworld = std::remove_const< GridFamily >::type::dimensionworld;
120
121 typedef typename std::remove_const< GridFamily >::type::ctype ctype;
122
123 typedef typename Traits::template Codim< codimension >::EntitySeed EntitySeed;
124 typedef typename Traits::template Codim< codimension >::Geometry Geometry;
125 typedef typename Traits::template Codim< codimension >::LocalGeometry LocalGeometry;
126
127 typedef typename Traits::HierarchicIterator HierarchicIterator;
128 typedef typename Traits::LeafIntersectionIterator LeafIntersectionIterator;
129 typedef typename Traits::LevelIntersectionIterator LevelIntersectionIterator;
130
131 private:
132 typedef typename Traits::HostGridPartType HostGridPartType;
133 typedef typename Traits::CoordFunctionType CoordFunctionType;
134
135 typedef typename Geometry::Implementation GeometryImplType;
136
138
139 public:
140 typedef typename HostGridPartType::template Codim< codimension >::EntityType HostEntityType;
141
142 GeoEntity () = default;
143
144 GeoEntity ( const CoordFunctionType &coordFunction, HostEntityType hostEntity )
145 : coordFunction_( &coordFunction ),
146 hostEntity_( std::move( hostEntity ) )
147 {}
148
149 template< class LocalFunction >
150 GeoEntity ( const GeoEntity &other, const LocalFunction &localCoordFunction )
151 : coordFunction_( other.coordFunction_ ),
152 hostEntity_( other.hostEntity_ )
153 {
155 geo_ = GeometryImplType( type(), coords );
156 }
157
158 GeometryType type () const
159 {
160 return hostEntity().type();
161 }
162
163 PartitionType partitionType () const
164 {
165 return hostEntity().partitionType();
166 }
167
169 {
170 if( !geo_ )
171 {
173 geo_ = GeometryImplType( type(), coords );
174 }
175 return Geometry( geo_ );
176 }
177
178 EntitySeed seed () const { return EntitySeed( hostEntity().seed() ); }
179
180 template< int codim >
181 int count () const
182 {
183 return hostEntity().template count< codim >();
184 }
185
186 unsigned int subEntities ( unsigned int codim ) const { return hostEntity().subEntities( codim ); }
187
188 template< int codim >
189 typename Traits::template Codim< codim >::Entity
190 subEntity ( int i ) const
191 {
192 typedef typename Traits::template Codim< codim >::Entity::Implementation EntityImpl;
193 return EntityImpl( *coordFunction_, hostEntity().template subEntity< codim >( i ) );
194 }
195
197 {
198 return hostEntity().hasBoundaryIntersections();
199 }
200
201 bool equals ( const GeoEntity &rhs ) const
202 {
203 return hostEntity() == rhs.hostEntity();
204 }
205
206 const CoordFunctionType &coordFunction () const
207 {
208 assert( coordFunction_ );
209 return *coordFunction_;
210 }
211
213 {
214 return hostEntity_;
215 }
216
218 {
219 hostEntity_ = &hostEntity;
220 }
221
222 private:
223 const CoordFunctionType *coordFunction_ = nullptr;
224 HostEntityType hostEntity_;
225
226 mutable GeometryImplType geo_;
227 };
228
229 } // namespace Fem
230
231} // namespace Dune
232
233#endif // #ifndef DUNE_FEM_GRIDPART_GEOGRIDPART_ENTITY_HH
STL namespace.
Definition: bindguard.hh:11
interface for local functions
Definition: localfunction.hh:77
Definition: defaultgridpartentity.hh:22
Definition: cornerstorage.hh:145
Definition: cornerstorage.hh:189
Definition: geogridpart/entity.hh:25
Traits::template Codim< codimension >::Geometry Geometry
Definition: geogridpart/entity.hh:37
static const int codimension
Definition: geogridpart/entity.hh:29
static const int mydimension
Definition: geogridpart/entity.hh:31
GeoEntity(const CoordFunctionType &coordFunction, HostEntityType hostEntity)
Definition: geogridpart/entity.hh:52
static const int dimension
Definition: geogridpart/entity.hh:30
const HostEntityType & hostEntity() const
Definition: geogridpart/entity.hh:90
Traits::template Codim< codimension >::EntitySeed EntitySeed
Definition: geogridpart/entity.hh:36
static const int dimensionworld
Definition: geogridpart/entity.hh:32
bool equals(const GeoEntity &rhs) const
Definition: geogridpart/entity.hh:79
GeometryType type() const
Definition: geogridpart/entity.hh:57
const CoordFunctionType & coordFunction() const
Definition: geogridpart/entity.hh:84
std::remove_const< GridFamily >::type::ctype ctype
Definition: geogridpart/entity.hh:34
unsigned int subEntities(unsigned int cdim) const
Definition: geogridpart/entity.hh:95
PartitionType partitionType() const
Definition: geogridpart/entity.hh:62
EntitySeed seed() const
Definition: geogridpart/entity.hh:77
Geometry geometry() const
Definition: geogridpart/entity.hh:67
HostGridPartType::template Codim< codimension >::EntityType HostEntityType
Definition: geogridpart/entity.hh:48
Geometry geometry() const
Definition: geogridpart/entity.hh:168
void setHostEntity(const HostEntityType &hostEntity)
Definition: geogridpart/entity.hh:217
Traits::template Codim< codimension >::Geometry Geometry
Definition: geogridpart/entity.hh:124
const CoordFunctionType & coordFunction() const
Definition: geogridpart/entity.hh:206
EntitySeed seed() const
Definition: geogridpart/entity.hh:178
Traits::template Codim< codimension >::LocalGeometry LocalGeometry
Definition: geogridpart/entity.hh:125
int count() const
Definition: geogridpart/entity.hh:181
GeoEntity(const GeoEntity &other, const LocalFunction &localCoordFunction)
Definition: geogridpart/entity.hh:150
Traits::HierarchicIterator HierarchicIterator
Definition: geogridpart/entity.hh:127
GeometryType type() const
Definition: geogridpart/entity.hh:158
HostGridPartType::template Codim< codimension >::EntityType HostEntityType
Definition: geogridpart/entity.hh:140
Traits::template Codim< codim >::Entity subEntity(int i) const
Definition: geogridpart/entity.hh:190
bool hasBoundaryIntersections() const
Definition: geogridpart/entity.hh:196
unsigned int subEntities(unsigned int codim) const
Definition: geogridpart/entity.hh:186
GeoEntity(const CoordFunctionType &coordFunction, HostEntityType hostEntity)
Definition: geogridpart/entity.hh:144
std::remove_const< GridFamily >::type::ctype ctype
Definition: geogridpart/entity.hh:121
bool equals(const GeoEntity &rhs) const
Definition: geogridpart/entity.hh:201
Traits::template Codim< codimension >::EntitySeed EntitySeed
Definition: geogridpart/entity.hh:123
Traits::LeafIntersectionIterator LeafIntersectionIterator
Definition: geogridpart/entity.hh:128
PartitionType partitionType() const
Definition: geogridpart/entity.hh:163
Traits::LevelIntersectionIterator LevelIntersectionIterator
Definition: geogridpart/entity.hh:129
const HostEntityType & hostEntity() const
Definition: geogridpart/entity.hh:212