1#ifndef DUNE_MULTIDOMAINGRID_SUBDOMAINGRID_ENTITY_HH
2#define DUNE_MULTIDOMAINGRID_SUBDOMAINGRID_ENTITY_HH
6#include <dune/grid/common/entity.hh>
7#include <dune/grid/common/gridenums.hh>
13template<
typename,
typename>
18template<
int codim,
int dim,
typename Gr
idImp>
21template<
typename,
typename,
typename>
22class IntersectionIteratorWrapper;
24template<
typename Gr
idImp>
25class HierarchicIteratorWrapper;
27template<
typename MDGr
id>
36template<
typename HostES>
37class EntitySeedWrapper
40 typedef HostES HostEntitySeed;
43 friend class SubDomainGrid;
45 template<
typename,
typename>
46 friend class ::Dune::mdgrid::MultiDomainGrid;
48 template<
int,
int,
typename>
49 friend class EntityWrapper;
53 static const std::size_t codimension = HostEntitySeed::codimension;
58 EntitySeedWrapper(
const HostEntitySeed& hostEntitySeed)
59 : _hostEntitySeed(hostEntitySeed)
62 const HostEntitySeed& hostEntitySeed()
const
64 return _hostEntitySeed;
69 return _hostEntitySeed.isValid();
72 HostEntitySeed _hostEntitySeed;
76template<
int codim,
int dim,
typename Gr
idImp>
77class EntityWrapperBase
78 :
public EntityDefaultImplementation<codim,dim,GridImp,EntityWrapper>
83 using MultiDomainEntity =
typename GridImp::MultiDomainGrid::Traits::template Codim<codim>::Entity;
84 using HostEntity =
typename GridImp::HostGrid::Traits::template Codim<codim>::Entity;
88 using EntitySeed = EntitySeedWrapper<typename HostEntity::EntitySeed>;
89 using Geometry =
typename GridImp::template Codim<codim>::Geometry;
95 EntityWrapperBase(
const GridImp* grid,
const MultiDomainEntity& e)
97 , _multiDomainEntity(e)
100 EntityWrapperBase(
const GridImp* grid, MultiDomainEntity&& e)
102 , _multiDomainEntity(std::move(e))
106 return multiDomainEntity().level();
109 PartitionType partitionType()
const {
110 return multiDomainEntity().partitionType();
113 unsigned int subEntities(
unsigned int codimSubEntitiy)
const {
114 return multiDomainEntity().subEntities(codimSubEntitiy);
117 Geometry geometry()
const {
118 return Geometry(hostEntity().geometry());
121 EntitySeed seed()
const {
122 return EntitySeed(hostEntity().seed());
125 bool equals(
const EntityWrapperBase& other)
const
127 return grid() == other.grid() && multiDomainEntity() == other.multiDomainEntity();
132 const GridImp* _grid;
133 MultiDomainEntity _multiDomainEntity;
137 const MultiDomainEntity& multiDomainEntity()
const {
138 return _multiDomainEntity;
141 const HostEntity& hostEntity()
const {
142 return grid()._grid.hostEntity(_multiDomainEntity);
145 const GridImp& grid()
const
154template<
int codim,
int dim,
typename Gr
idImp>
156 :
public EntityWrapperBase<codim,dim,GridImp>
159 using Base = EntityWrapperBase<codim,dim,GridImp>;
162 friend class SubDomainGrid;
164 template<
typename,
typename>
167 template<
int,
int,
typename,
template<
int,
int,
typename>
class>
178template<
int dim,
typename Gr
idImp>
179class EntityWrapper<0,dim,GridImp>
180 :
public EntityWrapperBase<0,dim,GridImp>
183 using Base = EntityWrapperBase<0,dim,GridImp>;
186 friend class SubDomainGrid;
188 template<
typename,
typename>
191 template<
int,
int,
typename,
template<
int,
int,
typename>
class>
195 friend class LevelGridView;
198 friend class LeafGridView;
200 using Base::multiDomainEntity;
201 using Base::hostEntity;
206 using LocalGeometry =
typename GridImp::template Codim<0>::LocalGeometry;
207 using LeafIntersectionIterator =
typename GridImp::Traits::LeafIntersectionIterator;
208 using LevelIntersectionIterator =
typename GridImp::Traits::LevelIntersectionIterator;
209 using HierarchicIterator =
typename GridImp::Traits::HierarchicIterator;
214 unsigned int subEntities(
unsigned int codim)
const {
215 return hostEntity().subEntities(codim);
219 typename GridImp::template Codim<cc>::Entity subEntity(
int i)
const {
220 return {EntityWrapper<cc,dim,GridImp>(&grid(),multiDomainEntity().
template subEntity<cc>(i))};
223 typename GridImp::template Codim<0>::Entity father()
const {
224 return {EntityWrapper<0,dim,GridImp>(&grid(),multiDomainEntity().father())};
227 bool hasFather()
const {
228 return multiDomainEntity().hasFather();
231 bool isLeaf()
const {
232 return multiDomainEntity().isLeaf();
235 bool isRegular()
const {
236 return multiDomainEntity().isRegular();
239 LocalGeometry geometryInFather()
const {
240 return LocalGeometry(hostEntity().geometryInFather());
243 HierarchicIterator hbegin(
int maxLevel)
const {
244 return HierarchicIteratorWrapper<GridImp>(
246 multiDomainEntity().hbegin(maxLevel),
247 multiDomainEntity().hend(maxLevel)
251 HierarchicIterator hend(
int maxLevel)
const {
252 return HierarchicIteratorWrapper<GridImp>(
254 multiDomainEntity().hend(maxLevel),
255 multiDomainEntity().hend(maxLevel)
259 LevelIntersectionIterator ilevelbegin()
const {
260 return IntersectionIteratorWrapper<
262 typename GridImp::LevelGridView::IndexSet,
263 typename GridImp::MultiDomainGrid::LevelGridView::IntersectionIterator
265 grid().levelGridView(this->level()).indexSet(),
266 grid()._grid.levelGridView(this->level()).ibegin(multiDomainEntity())
270 LevelIntersectionIterator ilevelend()
const {
271 return IntersectionIteratorWrapper<
273 typename GridImp::LevelGridView::IndexSet,
274 typename GridImp::MultiDomainGrid::LevelGridView::IntersectionIterator
276 grid().levelGridView(this->level()).indexSet(),
277 grid()._grid.levelGridView(this->level()).iend(multiDomainEntity())
281 LeafIntersectionIterator ileafbegin()
const {
282 return IntersectionIteratorWrapper<
284 typename GridImp::LeafGridView::IndexSet,
285 typename GridImp::MultiDomainGrid::LeafGridView::IntersectionIterator
287 grid().leafGridView().indexSet(),
288 grid()._grid.leafGridView().ibegin(multiDomainEntity())
292 LeafIntersectionIterator ileafend()
const {
293 return IntersectionIteratorWrapper<
295 typename GridImp::LeafGridView::IndexSet,
296 typename GridImp::MultiDomainGrid::LeafGridView::IntersectionIterator
298 grid().leafGridView().indexSet(),
299 grid()._grid.leafGridView().iend(multiDomainEntity())
304 return multiDomainEntity().isNew();
307 bool mightVanish()
const {
308 return multiDomainEntity().mightVanish();
311 bool hasBoundaryIntersections ()
const
313 for(
const auto& is : intersections(grid().levelGridView(this->level()),*
this))
320 for(
const auto& is : intersections(grid().leafGridView(),*
this))
A meta grid for dividing an existing DUNE grid into subdomains that can be accessed as a grid in thei...
Definition: multidomaingrid.hh:241