1#ifndef DUNE_FEM_GRIDPART_GEOGRIDPART_ENTITY_HH
2#define DUNE_FEM_GRIDPART_GEOGRIDPART_ENTITY_HH
7#include <dune/grid/common/entity.hh>
8#include <dune/grid/common/gridenums.hh>
10#include <dune/fem/gridpart/common/defaultgridpartentity.hh>
11#include <dune/fem/gridpart/geogridpart/cornerstorage.hh>
22 template<
int codim,
int dim,
class Gr
idFamily >
24 :
public DefaultGridPartEntity < codim, dim, GridFamily >
26 typedef typename std::remove_const< GridFamily >::type::Traits Traits;
29 static const int codimension = codim;
30 static const int dimension = std::remove_const< GridFamily >::type::dimension;
31 static const int mydimension = dimension - codimension;
32 static const int dimensionworld = std::remove_const< GridFamily >::type::dimensionworld;
34 typedef typename std::remove_const< GridFamily >::type::ctype ctype;
36 typedef typename Traits::template Codim< codimension >::EntitySeed EntitySeed;
37 typedef typename Traits::template Codim< codimension >::Geometry Geometry;
39 typedef typename Traits::HostGridPartType HostGridPartType;
42 typedef typename Traits::CoordFunctionType CoordFunctionType;
46 typedef GeoCoordVector< mydimension, GridFamily > CoordVectorType;
49 typedef typename HostGridPartType::template Codim< codimension >::EntityType HostEntityType;
51 GeoEntity () =
default;
53 GeoEntity (
const CoordFunctionType &coordFunction, HostEntityType hostEntity )
54 : coordFunction_( &coordFunction ),
55 hostEntity_(
std::move( hostEntity ) )
60 return hostEntity().type();
65 return hostEntity().partitionType();
68 Geometry geometry ()
const
72 CoordVectorType coords( coordFunction(), hostEntity() );
73 geo_ = GeometryImplType( type(), coords );
75 return Geometry( geo_ );
78 EntitySeed seed ()
const {
return EntitySeed( hostEntity().seed() ); }
80 bool equals (
const GeoEntity &rhs )
const
82 return hostEntity() == rhs.hostEntity();
85 const CoordFunctionType &coordFunction ()
const
87 assert( coordFunction_ );
88 return *coordFunction_;
91 const HostEntityType &hostEntity ()
const
96 unsigned int subEntities (
unsigned int cdim )
const {
return hostEntity().subEntities( cdim ); }
99 const CoordFunctionType *coordFunction_ =
nullptr;
100 HostEntityType hostEntity_;
102 mutable GeometryImplType geo_;
110 template<
int dim,
class Gr
idFamily >
111 class GeoEntity< 0, dim, GridFamily >
112 :
public DefaultGridPartEntity < 0, dim, GridFamily >
114 typedef typename std::remove_const< GridFamily >::type::Traits Traits;
117 static const int codimension = 0;
118 static const int dimension = std::remove_const< GridFamily >::type::dimension;
119 static const int mydimension = dimension - codimension;
120 static const int dimensionworld = std::remove_const< GridFamily >::type::dimensionworld;
122 typedef typename std::remove_const< GridFamily >::type::ctype ctype;
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;
128 typedef typename Traits::HierarchicIterator HierarchicIterator;
129 typedef typename Traits::LeafIntersectionIterator LeafIntersectionIterator;
130 typedef typename Traits::LevelIntersectionIterator LevelIntersectionIterator;
132 typedef typename Traits::HostGridPartType HostGridPartType;
135 typedef typename Traits::CoordFunctionType CoordFunctionType;
139 typedef GeoCoordVector< mydimension, GridFamily > CoordVectorType;
142 typedef typename HostGridPartType::template Codim< codimension >::EntityType HostEntityType;
144 GeoEntity () =
default;
146 GeoEntity (
const CoordFunctionType &coordFunction, HostEntityType hostEntity )
147 : coordFunction_( &coordFunction ),
148 hostEntity_(
std::move( hostEntity ) )
151 template<
class LocalFunction >
152 GeoEntity (
const GeoEntity &other,
const LocalFunction &localCoordFunction )
153 : coordFunction_( other.coordFunction_ ),
154 hostEntity_( other.hostEntity_ )
156 GeoLocalCoordVector< mydimension, GridFamily, LocalFunction > coords( localCoordFunction );
157 geo_ = GeometryImplType( type(), coords );
162 return hostEntity().type();
167 return hostEntity().partitionType();
170 Geometry geometry ()
const
174 CoordVectorType coords( coordFunction(), hostEntity() );
175 geo_ = GeometryImplType( type(), coords );
177 return Geometry( geo_ );
180 EntitySeed seed ()
const {
return EntitySeed( hostEntity().seed() ); }
182 template<
int codim >
185 return hostEntity().template count< codim >();
188 unsigned int subEntities (
unsigned int codim )
const {
return hostEntity().subEntities( codim ); }
190 template<
int codim >
191 typename Traits::template Codim< codim >::Entity
192 subEntity (
int i )
const
194 typedef typename Traits::template Codim< codim >::Entity::Implementation EntityImpl;
195 return EntityImpl( *coordFunction_, hostEntity().
template subEntity< codim >( i ) );
198 bool hasBoundaryIntersections ()
const
200 return hostEntity().hasBoundaryIntersections();
203 bool equals (
const GeoEntity &rhs )
const
205 return hostEntity() == rhs.hostEntity();
208 const CoordFunctionType &coordFunction ()
const
210 assert( coordFunction_ );
211 return *coordFunction_;
214 const HostEntityType &hostEntity ()
const
219 void setHostEntity (
const HostEntityType &hostEntity )
221 hostEntity_ = &hostEntity;
225 const CoordFunctionType *coordFunction_ =
nullptr;
226 HostEntityType hostEntity_;
228 mutable GeometryImplType geo_;
GeometryImp< mydim, cdim, GridImp > Implementation
type of underlying implementation
Definition: geometry.hh:78
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
constexpr auto equals(T1 &&t1, T2 &&t2)
Equality comparison.
Definition: hybridutilities.hh:587
Dune namespace.
Definition: alignedallocator.hh:13