diff --git a/dune/subgrid/subgrid/subgridindexstorage.hh b/dune/subgrid/subgrid/subgridindexstorage.hh index a63387ed07fdaad3290bf38a9dde6cf7b7128d68..f7fc6f0999fae65c9c374a60bce9ed04a47a231a 100644 --- a/dune/subgrid/subgrid/subgridindexstorage.hh +++ b/dune/subgrid/subgrid/subgridindexstorage.hh @@ -76,6 +76,8 @@ class SubGridIndexStorageBase using ctype = typename GridType::ctype; public: + template <int codim> + using GridEntity = typename std::remove_const<GridType>::type::template Codim<codim>::Entity; typedef typename std::remove_const<GridType>::type::HostGridType HostGridType; typedef typename HostGridType::Traits::GlobalIdSet HostIdSet; @@ -208,7 +210,7 @@ class SubGridIndexStorageBase //! get geometry type of given subentity template <int cc> - GeometryType getSubGeometryType(const typename std::remove_const<GridType>::type::template Codim<cc>::Entity& e, int i, unsigned int codim) const + GeometryType getSubGeometryType(const GridEntity<cc>& e, int i, unsigned int codim) const { return Dune::ReferenceElements<ctype,dim>::general(e.type()).type(i,codim); } @@ -216,7 +218,7 @@ class SubGridIndexStorageBase //! get level index of host grid entity encapsulated in given entity template <int codim> - int getHostLevelIndex(int level, const typename std::remove_const<GridType>::type::template Codim<codim>::Entity& e) const + int getHostLevelIndex(int level, const GridEntity<codim>& e) const { return hostgrid.levelIndexSet(level).index(grid.getRealImplementation(e).hostEntity()); } @@ -224,7 +226,7 @@ class SubGridIndexStorageBase //! get level index of host grid subentity encapsulated in given subentity template <int cc> - int getHostLevelSubIndex(int level, const typename std::remove_const<GridType>::type::template Codim<cc>::Entity& e, int i, unsigned int codim) const + int getHostLevelSubIndex(int level, const GridEntity<cc>& e, int i, unsigned int codim) const { return hostgrid.levelIndexSet(level).subIndex(grid.getRealImplementation(e).hostEntity(), i, codim+CodimInHostGrid); } @@ -232,14 +234,14 @@ class SubGridIndexStorageBase //! get id of host grid entity encapsulated in given entity template <int codim> - HostIdType getHostId(const typename std::remove_const<GridType>::type::template Codim<codim>::Entity& e) const + HostIdType getHostId(const GridEntity<codim>& e) const { return hostgrid.globalIdSet().id(grid.getRealImplementation(e).hostEntity()); } //! get id of host grid subentity encapsulated in given subentity - HostIdType getHostSubId(const typename std::remove_const<GridType>::type::template Codim<0>::Entity& e, int i, unsigned int codim) const + HostIdType getHostSubId(const GridEntity<0>& e, int i, unsigned int codim) const { return hostgrid.globalIdSet().subId(grid.getRealImplementation(e).hostEntity(), i, codim); } @@ -591,6 +593,10 @@ class SubGridMapIndexStorage : template <class GridImp_, int EntityDim> friend class SubGridMapSubindexSetter; + using Base = SubGridIndexStorageBase<GridType>; + + template <int codim> + using GridEntity = typename Base::template GridEntity<codim>; public: typedef typename std::remove_const<GridType>::type::HostGridType HostGridType; @@ -645,7 +651,7 @@ class SubGridMapIndexStorage : //! \todo Please doc me ! template <int codim> - bool isLeaf(const typename std::remove_const<GridType>::type::template Codim<codim>::Entity& e) const + bool isLeaf(const GridEntity<codim>& e) const { HostIdType id = grid.globalIdSet().id(e); typename GlobalToIndexMap::const_iterator it = indices[codim].find(id); @@ -669,7 +675,7 @@ class SubGridMapIndexStorage : //! \todo Please doc me ! template <int codim> - int levelIndex(const typename std::remove_const<GridType>::type::template Codim<codim>::Entity& e, int level) const + int levelIndex(const GridEntity<codim>& e, int level) const { HostIdType id = grid.globalIdSet().id(e); typename GlobalToIndexMap::const_iterator it = indices[codim].find(id); @@ -681,7 +687,7 @@ class SubGridMapIndexStorage : //! \todo Please doc me ! template <int cc> - int levelSubIndex(const typename std::remove_const<GridType>::type::template Codim<cc>::Entity& e, int i, int level, unsigned int codim) const + int levelSubIndex(const GridEntity<cc>& e, int i, int level, unsigned int codim) const { int result = -1; Hybrid::ifElse(Std::bool_constant<cc==0>(),[&](auto id) @@ -702,7 +708,7 @@ class SubGridMapIndexStorage : //! \todo Please doc me ! template <int codim> - int leafIndex(const typename std::remove_const<GridType>::type::template Codim<codim>::Entity& e) const + int leafIndex(const GridEntity<codim>& e) const { HostIdType id = grid.globalIdSet().id(e); typename GlobalToIndexMap::const_iterator it = indices[codim].find(id); @@ -714,7 +720,7 @@ class SubGridMapIndexStorage : //! \todo Please doc me ! template <int cc> - int leafSubIndex(const typename std::remove_const<GridType>::type::template Codim<cc>::Entity& e, int i, unsigned int codim) const + int leafSubIndex(const GridEntity<cc>& e, int i, unsigned int codim) const { int result = -1; Hybrid::ifElse(Std::bool_constant<cc==0>(),[&](auto id) @@ -737,7 +743,7 @@ class SubGridMapIndexStorage : // this should only be called by update //! \todo Please doc me ! - void insert(const typename std::remove_const<GridType>::type::template Codim<0>::Entity& e, bool isLeaf, int level) + void insert(const GridEntity<0>& e, bool isLeaf, int level) { // get index storage of entity HostIdType id = this->template getHostId<0>(e); @@ -971,6 +977,8 @@ class SubGridVectorIndexStorage : using Base = SubGridIndexStorageBase<GridType>; + template <int codim> + using GridEntity = typename Base::template GridEntity<codim>; public: typedef typename std::remove_const<GridType>::type::HostGridType HostGridType; @@ -1160,7 +1168,7 @@ class SubGridVectorIndexStorage : //! \todo Please doc me ! template <int codim> - int levelIndex(const typename std::remove_const<GridType>::type::template Codim<codim>::Entity& e, int level) const + int levelIndex(const GridEntity<codim>& e, int level) const { return levelIndices[level][GlobalGeometryTypeIndex::index(e.type())][this->template getHostLevelIndex<codim>(level, e)]; } @@ -1168,7 +1176,7 @@ class SubGridVectorIndexStorage : //! \todo Please doc me ! template <int cc> - int levelSubIndex(const typename std::remove_const<GridType>::type::template Codim<cc>::Entity& e, int i, int level, unsigned int codim) const + int levelSubIndex(const GridEntity<cc>& e, int i, int level, unsigned int codim) const { if (cc!=0) DUNE_THROW( NotImplemented, "levelSubIndex for higher codimension entity not implemented for SubGrid." ); @@ -1178,7 +1186,7 @@ class SubGridVectorIndexStorage : //! \todo Please doc me ! template <int codim> - int leafIndex(const typename std::remove_const<GridType>::type::template Codim<codim>::Entity& e) const + int leafIndex(const GridEntity<codim>& e) const { int level = e.level(); int gtIndex = GlobalGeometryTypeIndex::index(e.type()); @@ -1195,7 +1203,7 @@ class SubGridVectorIndexStorage : //! \todo Please doc me ! template <int cc> - int leafSubIndex(const typename std::remove_const<GridType>::type::template Codim<cc>::Entity& e, int i, unsigned int codim) const + int leafSubIndex(const GridEntity<cc>& e, int i, unsigned int codim) const { if (cc!=0) DUNE_THROW( NotImplemented, "leafSubIndex for higher codimension entity not implemented for SubGrid." ); @@ -1253,7 +1261,7 @@ class SubGridVectorIndexStorage : // this should only be called by update //! \todo Please doc me ! - void insert(const typename std::remove_const<GridType>::type::template Codim<0>::Entity& e, bool isLeaf, int level) + void insert(const GridEntity<0>& e, bool isLeaf, int level) { // get host index and GeometryType index of entity int hostIndex = this->template getHostLevelIndex<0>(level, e);