dune-fem 2.8.0
Loading...
Searching...
No Matches
geometrygridpart/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 // GeometryGridPartEntity
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 typedef typename Traits::GridFunctionType GridFunctionType;
28
29 public:
30 static const int codimension = codim;
31 static const int dimension = std::remove_const< GridFamily >::type::dimension;
32 static const int mydimension = dimension - codimension;
33 static const int dimensionworld = std::remove_const< GridFamily >::type::dimensionworld;
34
35 typedef typename std::remove_const< GridFamily >::type::ctype ctype;
36
37 typedef typename Traits::template Codim< codimension >::EntitySeed EntitySeed;
38 typedef typename Traits::template Codim< codimension >::Geometry Geometry;
39
40 private:
41 typedef typename Traits::HostGridPartType HostGridPartType;
42
43 typedef typename Geometry::Implementation GeometryImplType;
44
45 public:
46 typedef typename HostGridPartType::template Codim< codimension >::EntityType HostEntityType;
47
49
51 : hostEntity_( std::move( hostEntity ) ), gridFunction_( &gridFunction )
52 {}
53
54 GeometryType type () const
55 {
56 return hostEntity().type();
57 }
58
59 PartitionType partitionType () const
60 {
61 return hostEntity().partitionType();
62 }
63
64 unsigned int subEntities ( unsigned int c ) const { return hostEntity().subEntities( c ); }
65
67 {
68 DUNE_THROW( NotImplemented, "GeometryGridPart only implements the geometry for entities of codimension 0." );
69 }
70
71 EntitySeed seed () const { return EntitySeed( hostEntity().seed() ); }
72
73 bool equals ( const GeometryGridPartEntity &rhs ) const
74 {
75 return hostEntity() == rhs.hostEntity();
76 }
77
78 const HostEntityType &hostEntity () const
79 {
80 return hostEntity_;
81 }
82
83 const GridFunctionType &gridFunction () const
84 {
85 assert( gridFunction_ );
86 return *gridFunction_;
87 }
88
89 private:
90 HostEntityType hostEntity_;
91 const GridFunctionType *gridFunction_ = nullptr;
92 };
93
94
95
96 // GeometryGridPartEntity for codimension 0
97 // ----------------------------------------
98
99 template< int dim, class GridFamily >
100 class GeometryGridPartEntity< 0, dim, GridFamily >
101 : public DefaultGridPartEntity < 0, dim, GridFamily >
102 {
103 typedef typename std::remove_const< GridFamily >::type::Traits Traits;
104 typedef typename Traits::GridFunctionType GridFunctionType;
105
106 public:
107 static const int codimension = 0;
108 static const int dimension = std::remove_const< GridFamily >::type::dimension;
109 static const int mydimension = dimension - codimension;
110 static const int dimensionworld = std::remove_const< GridFamily >::type::dimensionworld;
111
112 typedef typename std::remove_const< GridFamily >::type::ctype ctype;
113
114 typedef typename Traits::template Codim< codimension >::EntitySeed EntitySeed;
115 typedef typename Traits::template Codim< codimension >::Geometry Geometry;
116 typedef typename Traits::template Codim< codimension >::LocalGeometry LocalGeometry;
117
118 typedef typename Traits::HierarchicIterator HierarchicIterator;
119 typedef typename Traits::LeafIntersectionIterator LeafIntersectionIterator;
120 typedef typename Traits::LevelIntersectionIterator LevelIntersectionIterator;
121
122 private:
123 typedef typename Traits::HostGridPartType HostGridPartType;
124
125 public:
126 typedef typename HostGridPartType::template Codim< codimension >::EntityType HostEntityType;
127
129
131 : hostEntity_( std::move( hostEntity ) ), gridFunction_( &gridFunction )
132 {}
133
134 template< class LocalFunction >
135 GeometryGridPartEntity ( const GeometryGridPartEntity &other, const LocalFunction &localGridFunction )
136 : hostEntity_( other.hostEntity_ ), gridFunction_( other.gridFunction_ )
137 {
138 }
139
140 GeometryType type () const
141 {
142 return hostEntity().type();
143 }
144
145 PartitionType partitionType () const
146 {
147 return hostEntity().partitionType();
148 }
149
151 {
152 typedef typename Geometry::Implementation Impl;
153 Impl impl( gridFunction() );
154 impl.impl().bind( hostEntity() );
155 return Geometry( impl );
156 }
157
158 EntitySeed seed () const { return EntitySeed( hostEntity().seed() ); }
159
160 template< int codim >
161 int count () const
162 {
163 return hostEntity().template count< codim >();
164 }
165
166 unsigned int subEntities ( unsigned int codim ) const { return hostEntity().subEntities( codim ); }
167
168 template< int codim >
169 typename Traits::template Codim< codim >::Entity subEntity ( int i ) const
170 {
171 typedef typename Traits::template Codim< codim >::Entity::Implementation EntityImpl;
172 return EntityImpl( *gridFunction_, hostEntity().template subEntity< codim >( i ) );
173 }
174
176 {
177 return hostEntity().hasBoundaryIntersections();
178 }
179
180 bool equals ( const GeometryGridPartEntity &rhs ) const
181 {
182 return hostEntity() == rhs.hostEntity();
183 }
184
186 {
187 return hostEntity_;
188 }
189
191 {
192 hostEntity_ = &hostEntity;
193 }
194
195 const GridFunctionType &gridFunction () const
196 {
197 assert( gridFunction_ );
198 return *gridFunction_;
199 }
200 private:
201 HostEntityType hostEntity_;
202 const GridFunctionType *gridFunction_ = nullptr;
203 };
204
205 } // namespace Fem
206
207} // namespace Dune
208
209#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: geometrygridpart/entity.hh:25
PartitionType partitionType() const
Definition: geometrygridpart/entity.hh:59
Traits::template Codim< codimension >::Geometry Geometry
Definition: geometrygridpart/entity.hh:38
HostGridPartType::template Codim< codimension >::EntityType HostEntityType
Definition: geometrygridpart/entity.hh:46
static const int codimension
Definition: geometrygridpart/entity.hh:30
EntitySeed seed() const
Definition: geometrygridpart/entity.hh:71
Traits::template Codim< codimension >::EntitySeed EntitySeed
Definition: geometrygridpart/entity.hh:37
std::remove_const< GridFamily >::type::ctype ctype
Definition: geometrygridpart/entity.hh:35
Geometry geometry() const
Definition: geometrygridpart/entity.hh:66
static const int mydimension
Definition: geometrygridpart/entity.hh:32
const HostEntityType & hostEntity() const
Definition: geometrygridpart/entity.hh:78
GeometryGridPartEntity(const GridFunctionType &gridFunction, HostEntityType hostEntity)
Definition: geometrygridpart/entity.hh:50
static const int dimension
Definition: geometrygridpart/entity.hh:31
bool equals(const GeometryGridPartEntity &rhs) const
Definition: geometrygridpart/entity.hh:73
GeometryType type() const
Definition: geometrygridpart/entity.hh:54
static const int dimensionworld
Definition: geometrygridpart/entity.hh:33
const GridFunctionType & gridFunction() const
Definition: geometrygridpart/entity.hh:83
unsigned int subEntities(unsigned int c) const
Definition: geometrygridpart/entity.hh:64
Traits::LeafIntersectionIterator LeafIntersectionIterator
Definition: geometrygridpart/entity.hh:119
PartitionType partitionType() const
Definition: geometrygridpart/entity.hh:145
bool hasBoundaryIntersections() const
Definition: geometrygridpart/entity.hh:175
std::remove_const< GridFamily >::type::ctype ctype
Definition: geometrygridpart/entity.hh:112
Traits::template Codim< codimension >::Geometry Geometry
Definition: geometrygridpart/entity.hh:115
Traits::HierarchicIterator HierarchicIterator
Definition: geometrygridpart/entity.hh:118
bool equals(const GeometryGridPartEntity &rhs) const
Definition: geometrygridpart/entity.hh:180
Traits::template Codim< codimension >::LocalGeometry LocalGeometry
Definition: geometrygridpart/entity.hh:116
const HostEntityType & hostEntity() const
Definition: geometrygridpart/entity.hh:185
Traits::LevelIntersectionIterator LevelIntersectionIterator
Definition: geometrygridpart/entity.hh:120
const GridFunctionType & gridFunction() const
Definition: geometrygridpart/entity.hh:195
Traits::template Codim< codim >::Entity subEntity(int i) const
Definition: geometrygridpart/entity.hh:169
void setHostEntity(const HostEntityType &hostEntity)
Definition: geometrygridpart/entity.hh:190
GeometryGridPartEntity(const GeometryGridPartEntity &other, const LocalFunction &localGridFunction)
Definition: geometrygridpart/entity.hh:135
GeometryGridPartEntity(const GridFunctionType &gridFunction, HostEntityType hostEntity)
Definition: geometrygridpart/entity.hh:130
Geometry geometry() const
Definition: geometrygridpart/entity.hh:150
Traits::template Codim< codimension >::EntitySeed EntitySeed
Definition: geometrygridpart/entity.hh:114
unsigned int subEntities(unsigned int codim) const
Definition: geometrygridpart/entity.hh:166
HostGridPartType::template Codim< codimension >::EntityType HostEntityType
Definition: geometrygridpart/entity.hh:126
EntitySeed seed() const
Definition: geometrygridpart/entity.hh:158
int count() const
Definition: geometrygridpart/entity.hh:161
GeometryType type() const
Definition: geometrygridpart/entity.hh:140