In UGGrid: EntitySeed of Entities with codim=1 not possible
Using UGGrid, a simple code that attempts to extract entity-seeds for sub-entities of elements, fails to compile:
UGGrid<2> grid(...); // initialize grid
for (auto const& e : edges(grid.leafGridView())) {
auto s = e.seed();
}
Error message (in g++-5.4):
uggridentity.hh:301:57: error: no matching function for call to 'EntitySeed<const UGGrid<2>, UGGridEntitySeed<1, const UGGrid<2> > >::EntitySeed(const UGEdgeEntity<2, const UGGrid<2> >&)
The problem lies in the class hierarchy of UGGridEntity
and UGEdgeEntity
, i.e.
template<class GridImp>
class UGGridEntity<1,2,GridImp> : public UGEdgeEntity<2,GridImp> {...}
and an UGGridEntitySeed
that expects an UGGridEntity
:
template<int codim, class GridImp>
class UGGridEntitySeed
{
UGGridEntitySeed(const UGGridEntity<codim, GridImp::dimension, GridImp>& entity) {...}
};
Maybe a solution could be to replace the class hierarchy by something like a typedef:
template<int codim, int dim, class GridImp>
class UGGridEntityDefault {...};
template<int dim, class GridImp>
class UGEdgeEntity {...};
namespace aux {
template<int codim, int dim, class GridImp>
struct UGGridEntity {
using type = UGGridEntityDefault<codim,dim,GridImp>;
};
template<class GridImp>
struct UGGridEntity<1,2,GridImp> {
using type = UGEdgeEntity<2,GridImp>;
};
} // end namespace aux
template<int codim, int dim, class GridImp>
using UGGridEntity = typename aux::UGGridEntity<codim, dim, GridImp>::type;
(but I do not seed possible implications of such a change)