1#ifndef DUNE_FEM_GRIDPART_GEOMETRYGRIDPART_ENTITY_HH
2#define DUNE_FEM_GRIDPART_GEOMETRYGRIDPART_ENTITY_HH
7#include <dune/grid/common/entity.hh>
8#include <dune/grid/common/gridenums.hh>
10#include <dune/fem/gridpart/common/defaultgridpartentity.hh>
21 template<
int codim,
int dim,
class Gr
idFamily >
22 class GeometryGridPartEntity
23 :
public DefaultGridPartEntity < codim, dim, GridFamily >
25 typedef typename std::remove_const< GridFamily >::type::Traits Traits;
26 typedef typename Traits::GridFunctionType GridFunctionType;
32 static const int codimension = codim;
33 static const int dimension = std::remove_const< GridFamily >::type::dimension;
34 static const int mydimension = dimension - codimension;
35 static const int dimensionworld = std::remove_const< GridFamily >::type::dimensionworld;
37 typedef typename std::remove_const< GridFamily >::type::ctype ctype;
39 typedef typename Traits::template Codim< codimension >::EntitySeed EntitySeed;
40 typedef typename Traits::template Codim< codimension >::Geometry Geometry;
42 typedef typename Traits::HostGridPartType HostGridPartType;
47 typedef typename HostGridPartType::template Codim< codimension >::EntityType HostEntityType;
49 GeometryGridPartEntity () =
default;
51 GeometryGridPartEntity (
const GridFunctionType &gridFunction, HostEntityType hostEntity )
52 : hostEntity_(
std::move( hostEntity ) ), gridFunction_( &gridFunction )
57 return hostEntity().type();
62 return hostEntity().partitionType();
65 unsigned int subEntities (
unsigned int c )
const {
return hostEntity().subEntities( c ); }
67 Geometry geometry ()
const
69 DUNE_THROW( NotImplemented,
"GeometryGridPart only implements the geometry for entities of codimension 0." );
72 EntitySeed seed ()
const {
return EntitySeed( hostEntity().seed() ); }
74 bool equals (
const GeometryGridPartEntity &rhs )
const
76 return hostEntity() == rhs.hostEntity();
79 const HostEntityType &hostEntity ()
const
84 const GridFunctionType &gridFunction ()
const
86 assert( gridFunction_ );
87 return *gridFunction_;
91 HostEntityType hostEntity_;
92 const GridFunctionType *gridFunction_ =
nullptr;
100 template<
int dim,
class Gr
idFamily >
101 class GeometryGridPartEntity< 0, dim, GridFamily >
102 :
public DefaultGridPartEntity < 0, dim, GridFamily >
104 typedef typename std::remove_const< GridFamily >::type::Traits Traits;
105 typedef typename Traits::GridFunctionType GridFunctionType;
108 static const int codimension = 0;
109 static const int dimension = std::remove_const< GridFamily >::type::dimension;
110 static const int mydimension = dimension - codimension;
111 static const int dimensionworld = std::remove_const< GridFamily >::type::dimensionworld;
113 typedef typename std::remove_const< GridFamily >::type::ctype ctype;
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;
119 typedef typename Traits::HierarchicIterator HierarchicIterator;
120 typedef typename Traits::LeafIntersectionIterator LeafIntersectionIterator;
121 typedef typename Traits::LevelIntersectionIterator LevelIntersectionIterator;
123 typedef typename Traits::HostGridPartType HostGridPartType;
125 typedef typename HostGridPartType::GridType GridType;
128 typedef typename HostGridPartType::template Codim< codimension >::EntityType HostEntityType;
130 GeometryGridPartEntity () =
default;
132 GeometryGridPartEntity (
const GridFunctionType &gridFunction, HostEntityType hostEntity )
133 : hostEntity_(
std::move( hostEntity ) ), gridFunction_( &gridFunction )
136 template<
class LocalFunction >
137 GeometryGridPartEntity (
const GeometryGridPartEntity &other,
const LocalFunction &localGridFunction )
138 : hostEntity_( other.hostEntity_ ), gridFunction_( other.gridFunction_ )
144 return hostEntity().type();
149 return hostEntity().partitionType();
152 Geometry geometry ()
const
155 Impl impl( gridFunction() );
156 impl.impl().bind( hostEntity() );
157 return Geometry( impl );
160 EntitySeed seed ()
const {
return EntitySeed( hostEntity().seed() ); }
162 template<
int codim >
165 return hostEntity().template count< codim >();
168 unsigned int subEntities (
unsigned int codim )
const {
return hostEntity().subEntities( codim ); }
170 template<
int codim >
171 typename Traits::template Codim< codim >::Entity subEntity (
int i )
const
173 typedef typename Traits::template Codim< codim >::Entity::Implementation EntityImpl;
174 return EntityImpl( *gridFunction_, hostEntity().
template subEntity< codim >( i ) );
177 bool hasBoundaryIntersections ()
const
179 return hostEntity().hasBoundaryIntersections();
182 bool equals (
const GeometryGridPartEntity &rhs )
const
184 return hostEntity() == rhs.hostEntity();
187 const HostEntityType &hostEntity ()
const
192 void setHostEntity (
const HostEntityType &hostEntity )
194 hostEntity_ = &hostEntity;
197 const GridFunctionType &gridFunction ()
const
199 assert( gridFunction_ );
200 return *gridFunction_;
203 HostEntityType hostEntity_;
204 const GridFunctionType *gridFunction_ =
nullptr;
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
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
constexpr auto equals(T1 &&t1, T2 &&t2)
Equality comparison.
Definition: hybridutilities.hh:587
Dune namespace.
Definition: alignedallocator.hh:13