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