dune-fem  2.8-git
idgridpart/entity.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_GRIDPART_IDGRIDPART_ENTITY_HH
2 #define DUNE_FEM_GRIDPART_IDGRIDPART_ENTITY_HH
3 
4 #include <type_traits>
5 #include <utility>
6 
7 //- dune-grid includes
8 #include <dune/grid/common/entity.hh>
9 #include <dune/grid/common/gridenums.hh>
10 
11 //- dune-fem includes
14 
15 namespace Dune
16 {
17  namespace Fem {
18 
19  // IdEntityBasic
20  // -------------
21 
22  template< int codim, int dim, class GridFamily >
24  : public DefaultGridPartEntity < codim, dim, GridFamily >
25  {
26  protected:
27  typedef typename std::remove_const< GridFamily >::type::Traits Traits;
28 
29  public:
34  static const int codimension = codim;
36  static const int dimension = std::remove_const< GridFamily >::type::dimension;
38  static const int mydimension = dimension - codimension;
40  static const int dimensionworld = std::remove_const< GridFamily >::type::dimensionworld;
41 
48  typedef typename std::remove_const< GridFamily >::type::ctype ctype;
49 
51  typedef typename GridFamily::template Codim< codimension >::EntitySeed EntitySeedType;
53  typedef typename Traits::template Codim< codimension >::Geometry Geometry;
54 
57  protected:
58  // type of the host grid
59  typedef typename Traits::HostGridPartType HostGridPartType;
60 
61  // type of extra data, e.g. a pointer to grid (here empty)
62  typedef typename Traits::ExtraData ExtraData;
63 
64  public:
69  typedef typename HostGridPartType::template Codim< codimension >::EntityType HostEntityType;
70 
77  IdEntityBasic () = default;
78 
84  : data_( std::move( data ) ),
85  hostEntity_( std::move( hostEntity ) )
86  {}
87 
97  GeometryType type () const
98  {
99  return hostEntity().type();
100  }
101 
103  int level () const
104  {
105  return hostEntity().level();
106  }
107 
109  PartitionType partitionType () const
110  {
111  return hostEntity().partitionType();
112  }
113 
116  {
117  return Geometry( hostEntity().geometry() );
118  }
119 
121  EntitySeedType seed () const { return hostEntity().seed(); }
122 
124  bool equals ( const IdEntityBasic &rhs ) const
125  {
126  return hostEntity() == rhs.hostEntity();
127  }
128 
135  const HostEntityType &hostEntity () const
136  {
137  return hostEntity_;
138  }
139 
140  const ExtraData &data () const { return data_; }
141 
144  protected:
147  };
148 
149 
150 
151  // IdGridEntity
152  // ------------
153 
154  template< int codim, int dim, class GridFamily >
155  class IdEntity : public IdEntityBasic< codim, dim, GridFamily >
156  {
158  protected:
159  typedef typename std::remove_const< GridFamily >::type::Traits Traits;
160 
161  protected:
162  // type of the host grid
163  typedef typename Traits::HostGridPartType HostGridPartType;
164 
165  // type of extra data, e.g. a pointer to grid (here empty)
166  typedef typename Traits::ExtraData ExtraData;
167 
168  public:
170 
175  typedef typename HostGridPartType::template Codim< codimension >::EntityType HostEntityType;
179  IdEntity () = default;
180 
182  : BaseType( data, hostEntity )
183  {}
184  };
185 
186 
187  // IdGridEntity for codimension 0
188  // ----------------------------------
189 
194  template< int dim, class GridFamily >
195  class IdEntity< 0, dim, GridFamily > : public IdEntityBasic< 0, dim, GridFamily >
196  {
198  protected:
199  typedef typename BaseType::Traits Traits;
201 
202  // type of extra data, e.g. a pointer to grid (here empty)
203  typedef typename BaseType::ExtraData ExtraData;
204 
205  public:
206  using BaseType::codimension ;
207  using BaseType::data ;
208  using BaseType::hostEntity ;
213  typedef typename HostGridPartType::template Codim< codimension >::EntityType HostEntityType;
216  public:
221  typedef typename Traits::template Codim< codimension >::LocalGeometry LocalGeometry;
222 
231  IdEntity () = default;
232 
239  : BaseType( data, hostEntity )
240  {}
241 
244  unsigned int subEntities( const unsigned int codim ) const
245  {
246  return hostEntity().subEntities( codim );
247  }
248 
249  template< int codim >
250  int count () const
251  {
252  return hostEntity().template count< codim >();
253  }
254 
255  template< int codim >
256  typename Traits::template Codim< codim >::Entity
257  subEntity ( int i ) const
258  {
259  typedef typename Traits::template Codim< codim >::Entity::Implementation EntityImpl;
260  return EntityImpl( data(), hostEntity().template subEntity< codim >( i ) );
261  }
262 
264  {
265  return hostEntity().hasBoundaryIntersections();
266  }
267 
270  };
271 
272  } // namespace Fem
273 
274 } // namespace Dune
275 
276 #endif // #ifndef DUNE_IDGRID_ENTITY_HH
Definition: bindguard.hh:11
Definition: defaultgridpartentity.hh:22
Definition: idgridpart/entity.hh:25
int level() const
obtain the level of this entity
Definition: idgridpart/entity.hh:103
ExtraData data_
Definition: idgridpart/entity.hh:145
Traits::HostGridPartType HostGridPartType
Definition: idgridpart/entity.hh:59
static const int dimension
dimension of the grid
Definition: idgridpart/entity.hh:36
Geometry geometry() const
Definition: idgridpart/entity.hh:115
static const int mydimension
dimension of the entity
Definition: idgridpart/entity.hh:38
Traits::template Codim< codimension >::Geometry Geometry
type of corresponding geometry
Definition: idgridpart/entity.hh:53
bool equals(const IdEntityBasic &rhs) const
check for equality
Definition: idgridpart/entity.hh:124
const HostEntityType & hostEntity() const
Definition: idgridpart/entity.hh:135
static const int codimension
codimensioon of the entity
Definition: idgridpart/entity.hh:34
IdEntityBasic()=default
construct a null entity
const ExtraData & data() const
Definition: idgridpart/entity.hh:140
EntitySeedType seed() const
return EntitySeed of host grid entity
Definition: idgridpart/entity.hh:121
PartitionType partitionType() const
obtain the partition type of this entity
Definition: idgridpart/entity.hh:109
std::remove_const< GridFamily >::type::ctype ctype
coordinate type of the grid
Definition: idgridpart/entity.hh:48
static const int dimensionworld
dimension of the world
Definition: idgridpart/entity.hh:40
HostGridPartType::template Codim< codimension >::EntityType HostEntityType
type of corresponding host entity
Definition: idgridpart/entity.hh:69
HostEntityType hostEntity_
Definition: idgridpart/entity.hh:146
GridFamily::template Codim< codimension >::EntitySeed EntitySeedType
type of corresponding entity seed
Definition: idgridpart/entity.hh:51
Traits::ExtraData ExtraData
Definition: idgridpart/entity.hh:62
std::remove_const< GridFamily >::type::Traits Traits
Definition: idgridpart/entity.hh:27
GeometryType type() const
obtain the name of the corresponding reference element
Definition: idgridpart/entity.hh:97
IdEntityBasic(ExtraData data, HostEntityType hostEntity)
construct an initialized entity
Definition: idgridpart/entity.hh:83
Definition: idgridpart/entity.hh:156
IdEntity(ExtraData data, HostEntityType hostEntity)
Definition: idgridpart/entity.hh:181
HostGridPartType::template Codim< codimension >::EntityType HostEntityType
type of corresponding host entity
Definition: idgridpart/entity.hh:175
std::remove_const< GridFamily >::type::Traits Traits
Definition: idgridpart/entity.hh:159
IdEntity()=default
construct a null entity
Traits::ExtraData ExtraData
Definition: idgridpart/entity.hh:166
Traits::HostGridPartType HostGridPartType
Definition: idgridpart/entity.hh:163
Traits::template Codim< codim >::Entity subEntity(int i) const
Definition: idgridpart/entity.hh:257
BaseType::ExtraData ExtraData
Definition: idgridpart/entity.hh:203
BaseType::Traits Traits
Definition: idgridpart/entity.hh:199
bool hasBoundaryIntersections() const
Definition: idgridpart/entity.hh:263
unsigned int subEntities(const unsigned int codim) const
Definition: idgridpart/entity.hh:244
IdEntity()=default
construct a null entity
BaseType::HostGridPartType HostGridPartType
Definition: idgridpart/entity.hh:200
Traits::template Codim< codimension >::LocalGeometry LocalGeometry
type of corresponding local geometry
Definition: idgridpart/entity.hh:221
HostGridPartType::template Codim< codimension >::EntityType HostEntityType
type of corresponding host entity
Definition: idgridpart/entity.hh:213
IdEntity(ExtraData data, HostEntityType hostEntity)
construct an initialized entity
Definition: idgridpart/entity.hh:238
int count() const
Definition: idgridpart/entity.hh:250