1#ifndef DUNE_MULTIDOMAINGRID_ENTITY_HH
2#define DUNE_MULTIDOMAINGRID_ENTITY_HH
4#include <dune/grid/common/entity.hh>
5#include <dune/grid/common/gridenums.hh>
11template<
int codim,
int dim,
typename Gr
idImp>
14template<
typename Gr
idImp>
15class LeafIntersectionIteratorWrapper;
17template<
typename Gr
idImp>
18class LevelIntersectionIteratorWrapper;
20template<
typename Gr
idImp>
21class HierarchicIteratorWrapper;
23template<
typename,
typename>
24class IntersectionIteratorWrapper;
26template<
typename HostGr
id,
typename MDGr
idTraits>
36template<
typename HostES>
37class EntitySeedWrapper
40 typedef HostES HostEntitySeed;
42 template<
typename,
typename>
43 friend class MultiDomainGrid;
45 template<
int,
int,
typename>
46 friend class EntityWrapper;
50 static const std::size_t codimension = HostEntitySeed::codimension;
55 EntitySeedWrapper(
const HostEntitySeed& hostEntitySeed)
56 : _hostEntitySeed(hostEntitySeed)
59 const HostEntitySeed& hostEntitySeed()
const
61 return _hostEntitySeed;
66 return _hostEntitySeed.isValid();
69 HostEntitySeed _hostEntitySeed;
74template<
int codim,
int dim,
typename Gr
idImp>
75class EntityWrapperBase :
76 public EntityDefaultImplementation<codim,dim,GridImp,EntityWrapper>
79 template<
typename,
typename>
80 friend class MultiDomainGrid;
82 typedef typename GridImp::HostGrid::Traits::template Codim<codim>::Entity HostEntity;
86 typedef typename GridImp::template Codim<codim>::Geometry Geometry;
88 typedef EntitySeedWrapper<typename HostEntity::EntitySeed> EntitySeed;
93 explicit EntityWrapperBase(
const HostEntity& e)
97 explicit EntityWrapperBase(HostEntity&& e)
98 : _hostEntity(std::move(e))
102 return _hostEntity.level();
105 PartitionType partitionType()
const {
106 return _hostEntity.partitionType();
109 unsigned int subEntities(
unsigned int codimSubEntitiy)
const {
110 return _hostEntity.subEntities(codimSubEntitiy);
113 Geometry geometry()
const {
114 return Geometry(_hostEntity.geometry());
117 EntitySeed seed()
const {
118 return EntitySeed(_hostEntity.seed());
121 bool equals(
const EntityWrapperBase& other)
const
123 return hostEntity() == other.hostEntity();
128 HostEntity _hostEntity;
132 const HostEntity& hostEntity()
const {
139template<
int codim,
int dim,
typename Gr
idImp>
141 public EntityWrapperBase<codim,dim,GridImp>
144 using Base = EntityWrapperBase<codim,dim,GridImp>;
146 template<
typename,
typename>
147 friend class MultiDomainGrid;
156template<
int dim,
typename Gr
idImp>
157class EntityWrapper<0,dim,GridImp> :
158 public EntityWrapperBase<0,dim,GridImp>
161 using Base = EntityWrapperBase<0,dim,GridImp>;
163 template<
typename,
typename>
164 friend class MultiDomainGrid;
167 friend class LevelGridView;
170 friend class LeafGridView;
172 using Base::hostEntity;
176 using LocalGeometry =
typename GridImp::template Codim<0>::LocalGeometry;
177 using LeafIntersectionIterator =
typename GridImp::Traits::LeafIntersectionIterator;
178 using LevelIntersectionIterator =
typename GridImp::Traits::LevelIntersectionIterator;
179 using HierarchicIterator =
typename GridImp::Traits::HierarchicIterator;
184 unsigned int subEntities(
unsigned int codim)
const {
185 return hostEntity().subEntities(codim);
189 typename GridImp::template Codim<cc>::Entity subEntity(
int i)
const {
190 return {EntityWrapper<cc,dim,GridImp>(hostEntity().
template subEntity<cc>(i))};
193 typename GridImp::template Codim<0>::Entity father()
const {
194 return {EntityWrapper(hostEntity().father())};
197 bool hasFather()
const {
198 return hostEntity().hasFather();
201 bool isLeaf()
const {
202 return hostEntity().isLeaf();
205 bool isRegular()
const {
206 return hostEntity().isRegular();
209 LocalGeometry geometryInFather()
const {
210 return LocalGeometry(hostEntity().geometryInFather());
213 HierarchicIterator hbegin(
int maxLevel)
const {
214 return HierarchicIteratorWrapper<GridImp>(hostEntity().hbegin(maxLevel));
217 HierarchicIterator hend(
int maxLevel)
const {
218 return HierarchicIteratorWrapper<GridImp>(hostEntity().hend(maxLevel));
221 LevelIntersectionIterator ilevelbegin()
const {
222 return IntersectionIteratorWrapper<
224 typename GridImp::HostGrid::LevelGridView::IntersectionIterator
226 hostEntity().ilevelbegin()
230 LevelIntersectionIterator ilevelend()
const {
231 return IntersectionIteratorWrapper<
233 typename GridImp::HostGrid::LevelGridView::IntersectionIterator
235 hostEntity().ilevelend()
239 LeafIntersectionIterator ileafbegin()
const {
240 return IntersectionIteratorWrapper<
242 typename GridImp::HostGrid::LeafGridView::IntersectionIterator
244 hostEntity().ileafbegin()
248 LeafIntersectionIterator ileafend()
const {
249 return IntersectionIteratorWrapper<
251 typename GridImp::HostGrid::LeafGridView::IntersectionIterator
253 hostEntity().ileafend()
258 return hostEntity().isNew();
261 bool mightVanish()
const {
262 return hostEntity().mightVanish();
265 bool hasBoundaryIntersections ()
const
267 return hostEntity().hasBoundaryIntersections();