dune-fem 2.12-git
Loading...
Searching...
No Matches
geometrygridpart/entity.hh
Go to the documentation of this file.
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>
9
11
12namespace Dune
13{
14
15 namespace Fem
16 {
17
18 // GeometryGridPartEntity
19 // ----------------------
20
21 template< int codim, int dim, class GridFamily >
23 : public DefaultGridPartEntity < codim, dim, GridFamily >
24 {
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;
34 static const int mydimension = dimension - codimension;
36
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
50
52 : hostEntity_( std::move( hostEntity ) ), gridFunction_( &gridFunction )
53 {}
54
56 {
57 return hostEntity().type();
58 }
59
61 {
62 return hostEntity().partitionType();
63 }
64
65 unsigned int subEntities ( unsigned int c ) const { return hostEntity().subEntities( c ); }
66
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;
110 static const int mydimension = dimension - codimension;
112
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
131
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
143 {
144 return hostEntity().type();
145 }
146
148 {
149 return hostEntity().partitionType();
150 }
151
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
178 {
179 return hostEntity().hasBoundaryIntersections();
180 }
181
182 bool equals ( const GeometryGridPartEntity &rhs ) const
183 {
184 return hostEntity() == rhs.hostEntity();
185 }
186
187 bool isLeaf () const
188 {
189 return hostEntity().isLeaf();
190 }
191
192 int level () const
193 {
194 return hostEntity().level();
195 }
196
198 {
199 return hostEntity_;
200 }
201
203 {
204 hostEntity_ = &hostEntity;
205 }
206
207 const GridFunctionType &gridFunction () const
208 {
209 assert( gridFunction_ );
210 return *gridFunction_;
211 }
212 private:
213 HostEntityType hostEntity_;
214 const GridFunctionType *gridFunction_ = nullptr;
215 };
216
217 } // namespace Fem
218
219} // namespace Dune
220
221#endif // #ifndef DUNE_FEM_GRIDPART_GEOMETRYGRIDPART_ENTITY_HH
Y & rhs()
size_type dim() const
#define DUNE_THROW(E,...)
PartitionType
STL namespace.
GeometryImp< mydim, cdim, GridImp > Implementation
interface for local functions
Definition localfunction.hh:77
Definition defaultgridpartentity.hh:22
Definition geometrygridpart/entity.hh:24
PartitionType partitionType() const
Definition geometrygridpart/entity.hh:60
Traits::template Codim< codimension >::Geometry Geometry
Definition geometrygridpart/entity.hh:40
HostGridPartType::template Codim< codimension >::EntityType HostEntityType
Definition geometrygridpart/entity.hh:47
static const int codimension
Definition geometrygridpart/entity.hh:32
EntitySeed seed() const
Definition geometrygridpart/entity.hh:72
Traits::template Codim< codimension >::EntitySeed EntitySeed
Definition geometrygridpart/entity.hh:39
std::remove_const< GridFamily >::type::ctype ctype
Definition geometrygridpart/entity.hh:37
Geometry geometry() const
Definition geometrygridpart/entity.hh:67
static const int mydimension
Definition geometrygridpart/entity.hh:34
const HostEntityType & hostEntity() const
Definition geometrygridpart/entity.hh:79
GeometryGridPartEntity(const GridFunctionType &gridFunction, HostEntityType hostEntity)
Definition geometrygridpart/entity.hh:51
static const int dimension
Definition geometrygridpart/entity.hh:33
Traits::HostGridPartType HostGridPartType
Definition geometrygridpart/entity.hh:42
bool equals(const GeometryGridPartEntity &rhs) const
Definition geometrygridpart/entity.hh:74
GeometryType type() const
Definition geometrygridpart/entity.hh:55
static const int dimensionworld
Definition geometrygridpart/entity.hh:35
const GridFunctionType & gridFunction() const
Definition geometrygridpart/entity.hh:84
unsigned int subEntities(unsigned int c) const
Definition geometrygridpart/entity.hh:65
Traits::LeafIntersectionIterator LeafIntersectionIterator
Definition geometrygridpart/entity.hh:120
PartitionType partitionType() const
Definition geometrygridpart/entity.hh:147
bool hasBoundaryIntersections() const
Definition geometrygridpart/entity.hh:177
std::remove_const< GridFamily >::type::ctype ctype
Definition geometrygridpart/entity.hh:113
Traits::template Codim< codimension >::Geometry Geometry
Definition geometrygridpart/entity.hh:116
Traits::HierarchicIterator HierarchicIterator
Definition geometrygridpart/entity.hh:119
bool equals(const GeometryGridPartEntity &rhs) const
Definition geometrygridpart/entity.hh:182
Traits::HostGridPartType HostGridPartType
Definition geometrygridpart/entity.hh:123
Traits::template Codim< codimension >::LocalGeometry LocalGeometry
Definition geometrygridpart/entity.hh:117
const HostEntityType & hostEntity() const
Definition geometrygridpart/entity.hh:197
Traits::LevelIntersectionIterator LevelIntersectionIterator
Definition geometrygridpart/entity.hh:121
const GridFunctionType & gridFunction() const
Definition geometrygridpart/entity.hh:207
bool isLeaf() const
Definition geometrygridpart/entity.hh:187
Traits::template Codim< codim >::Entity subEntity(int i) const
Definition geometrygridpart/entity.hh:171
void setHostEntity(const HostEntityType &hostEntity)
Definition geometrygridpart/entity.hh:202
GeometryGridPartEntity(const GeometryGridPartEntity &other, const LocalFunction &localGridFunction)
Definition geometrygridpart/entity.hh:137
GeometryGridPartEntity(const GridFunctionType &gridFunction, HostEntityType hostEntity)
Definition geometrygridpart/entity.hh:132
Geometry geometry() const
Definition geometrygridpart/entity.hh:152
Traits::template Codim< codimension >::EntitySeed EntitySeed
Definition geometrygridpart/entity.hh:115
unsigned int subEntities(unsigned int codim) const
Definition geometrygridpart/entity.hh:168
HostGridPartType::template Codim< codimension >::EntityType HostEntityType
Definition geometrygridpart/entity.hh:128
int level() const
Definition geometrygridpart/entity.hh:192
EntitySeed seed() const
Definition geometrygridpart/entity.hh:160
int count() const
Definition geometrygridpart/entity.hh:163
GeometryType type() const
Definition geometrygridpart/entity.hh:142