dune-fem  2.4.1-rc
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-common includes
8 #include <dune/common/nullptr.hh>
9 
10 //- dune-grid includes
11 #include <dune/grid/common/entity.hh>
12 #include <dune/grid/common/gridenums.hh>
13 
14 //- dune-fem includes
18 
19 namespace Dune
20 {
21  namespace Fem {
22 
23  // IdEntityBasic
24  // -------------
25 
26  template< int codim, int dim, class GridFamily >
28  : public DefaultGridPartEntity < codim, dim, GridFamily >
29  {
30  protected:
31  typedef typename std::remove_const< GridFamily >::type::Traits Traits;
32 
33  public:
37  static const int codimension = codim;
40  static const int dimension = std::remove_const< GridFamily >::type::dimension;
42  static const int mydimension = dimension - codimension;
44  static const int dimensionworld = std::remove_const< GridFamily >::type::dimensionworld;
45 
51  typedef typename std::remove_const< GridFamily >::type::ctype ctype;
53 
55  typedef typename GridFamily::template Codim< codimension >::EntitySeed EntitySeedType;
57  typedef typename Traits::template Codim< codimension >::Geometry Geometry;
58 
61  protected:
62  // type of the host grid
63  typedef typename Traits::HostGridPartType HostGridPartType;
64 
65  // type of extra data, e.g. a pointer to grid (here empty)
66  typedef typename Traits::ExtraData ExtraData;
67 
68  public:
72  typedef typename HostGridPartType::template Codim< codimension >::EntityType HostEntityType;
74 
81  IdEntityBasic () = default;
82 
87  IdEntityBasic ( ExtraData data, HostEntityType hostEntity )
88  : data_( std::move( data ) ),
89  hostEntity_( std::move( hostEntity ) )
90  {}
91 
101  GeometryType type () const
102  {
103  return hostEntity().type();
104  }
105 
107  int level () const
108  {
109  return hostEntity().level();
110  }
111 
113  PartitionType partitionType () const
114  {
115  return hostEntity().partitionType();
116  }
117 
119  Geometry geometry () const
120  {
121  return Geometry( hostEntity().geometry() );
122  }
123 
125  EntitySeedType seed () const { return hostEntity().seed(); }
126 
128  bool equals ( const IdEntityBasic &rhs ) const
129  {
130  return hostEntity() == rhs.hostEntity();
131  }
132 
139  const HostEntityType &hostEntity () const
140  {
141  return hostEntity_;
142  }
143 
144  const ExtraData &data () const { return data_; }
145 
148  protected:
149  ExtraData data_;
150  HostEntityType hostEntity_;
151  };
152 
153 
154 
155  // IdGridEntity
156  // ------------
157 
158  template< int codim, int dim, class GridFamily >
159  class IdEntity : public IdEntityBasic< codim, dim, GridFamily >
160  {
162  protected:
163  typedef typename std::remove_const< GridFamily >::type::Traits Traits;
164 
165  protected:
166  // type of the host grid
167  typedef typename Traits::HostGridPartType HostGridPartType;
168 
169  // type of extra data, e.g. a pointer to grid (here empty)
170  typedef typename Traits::ExtraData ExtraData;
171 
172  public:
173  using BaseType :: codimension ;
174 
178  typedef typename HostGridPartType::template Codim< codimension >::EntityType HostEntityType;
183  IdEntity () = default;
184 
185  IdEntity ( ExtraData data, HostEntityType hostEntity )
186  : BaseType( data, hostEntity )
187  {}
188  };
189 
190 
191  // IdGridEntity for codimension 0
192  // ----------------------------------
193 
198  template< int dim, class GridFamily >
199  class IdEntity< 0, dim, GridFamily > : public IdEntityBasic< 0, dim, GridFamily >
200  {
202  protected:
203  typedef typename BaseType::Traits Traits;
205 
206  // type of extra data, e.g. a pointer to grid (here empty)
207  typedef typename BaseType::ExtraData ExtraData;
208 
209  public:
210  using BaseType::codimension ;
211  using BaseType::data ;
212  using BaseType::hostEntity ;
216  typedef typename HostGridPartType::template Codim< codimension >::EntityType HostEntityType;
220  public:
224  typedef typename Traits::template Codim< codimension >::LocalGeometry LocalGeometry;
226 
235  IdEntity () = default;
236 
242  IdEntity ( ExtraData data, HostEntityType hostEntity )
243  : BaseType( data, hostEntity )
244  {}
245 
248  unsigned int subEntities( const unsigned int codim ) const
249  {
250  return hostEntity().subEntities( codim );
251  }
252 
253  template< int codim >
254  int count () const
255  {
256  return hostEntity().template count< codim >();
257  }
258 
259  template< int codim >
260  typename Traits::template Codim< codim >::Entity
261  subEntity ( int i ) const
262  {
263  typedef typename Traits::template Codim< codim >::Entity::Implementation EntityImpl;
264  return EntityImpl( data(), make_entity( hostEntity().template subEntity< codim >( i ) ) );
265  }
266 
268  {
269  return hostEntity().hasBoundaryIntersections();
270  }
271 
274  };
275 
276  } // namespace Fem
277 
278 } // namespace Dune
279 
280 #endif // #ifndef DUNE_IDGRID_ENTITY_HH
std::remove_const< GridFamily >::type::Traits Traits
Definition: idgridpart/entity.hh:163
static const int dimensionworld
dimension of the world
Definition: idgridpart/entity.hh:44
PartitionType partitionType() const
obtain the partition type of this entity
Definition: idgridpart/entity.hh:113
unsigned int subEntities(const unsigned int codim) const
Definition: idgridpart/entity.hh:248
bool hasBoundaryIntersections() const
Definition: idgridpart/entity.hh:267
GeometryType type() const
obtain the name of the corresponding reference element
Definition: idgridpart/entity.hh:101
HostGridPartType::template Codim< codimension >::EntityType HostEntityType
type of corresponding host entity
Definition: idgridpart/entity.hh:73
IdEntityBasic()=default
construct a null entity
int count() const
Definition: idgridpart/entity.hh:254
BaseType::HostGridPartType HostGridPartType
Definition: idgridpart/entity.hh:204
std::remove_const< GridFamily >::type::ctype ctype
coordinate type of the grid
Definition: idgridpart/entity.hh:52
Geometry geometry() const
Definition: idgridpart/entity.hh:119
const HostEntityType & hostEntity() const
Definition: idgridpart/entity.hh:139
BaseType::Traits Traits
Definition: idgridpart/entity.hh:203
EntitySeedType seed() const
return EntitySeed of host grid entity
Definition: idgridpart/entity.hh:125
Traits::ExtraData ExtraData
Definition: idgridpart/entity.hh:170
int level() const
obtain the level of this entity
Definition: idgridpart/entity.hh:107
Dune::EntityPointer< Grid, Implementation >::Entity make_entity(const Dune::EntityPointer< Grid, Implementation > &entityPointer)
Definition: compatibility.hh:23
ExtraData data_
Definition: idgridpart/entity.hh:149
Traits::HostGridPartType HostGridPartType
Definition: idgridpart/entity.hh:63
Definition: coordinate.hh:4
std::remove_const< GridFamily >::type::Traits Traits
Definition: idgridpart/entity.hh:31
BaseType::ExtraData ExtraData
Definition: idgridpart/entity.hh:207
Traits::template Codim< codim >::Entity subEntity(int i) const
Definition: idgridpart/entity.hh:261
Traits::template Codim< codimension >::LocalGeometry LocalGeometry
type of corresponding local geometry
Definition: idgridpart/entity.hh:225
HostEntityType hostEntity_
Definition: idgridpart/entity.hh:150
STL namespace.
static const int dimension
dimension of the grid
Definition: idgridpart/entity.hh:40
IdEntityBasic(ExtraData data, HostEntityType hostEntity)
construct an initialized entity
Definition: idgridpart/entity.hh:87
IdEntity(ExtraData data, HostEntityType hostEntity)
construct an initialized entity
Definition: idgridpart/entity.hh:242
const ExtraData & data() const
Definition: idgridpart/entity.hh:144
Traits::template Codim< codimension >::Geometry Geometry
type of corresponding geometry
Definition: idgridpart/entity.hh:57
void move(ArrayInterface< T > &array, const unsigned int oldOffset, const unsigned int newOffset, const unsigned int length)
Definition: array_inline.hh:38
GridFamily::template Codim< codimension >::EntitySeed EntitySeedType
type of corresponding entity seed
Definition: idgridpart/entity.hh:55
bool equals(const IdEntityBasic &rhs) const
check for equality
Definition: idgridpart/entity.hh:128
Definition: defaultgridpartentity.hh:21
static const int codimension
codimensioon of the entity
Definition: idgridpart/entity.hh:38
Traits::HostGridPartType HostGridPartType
Definition: idgridpart/entity.hh:167
Traits::ExtraData ExtraData
Definition: idgridpart/entity.hh:66
Definition: idgridpart/entity.hh:27
static const int mydimension
dimension of the entity
Definition: idgridpart/entity.hh:42
Definition: idgridpart/entity.hh:159
IdEntity(ExtraData data, HostEntityType hostEntity)
Definition: idgridpart/entity.hh:185