Move hasBoundaryIntersections to GridView
Currently, having intersections with the boundary is a property of an entity. On the other hand, handling intersections between neighboring entities or between entities and the boundary has be delegated to the GridView. This leads to the following type of code snipped:
for( const auto &entity : elements( gridView ) )
{
if( entity.hasBoundaryIntersections() )
for( const auto &intersection : intersections( gridView, entity ) )
{
if( !intersection.boundary() )
continue;
// do something here
}
}
There are two problems with this approach:
- Effectively, this forces the entity to know about the boundary of the domain, e.g., by knowing the grid. This is somewhat counterintuitive.
- The grid might perform an intersection loop to implement
hasBoundaryIntersections
, just to save a loop over all intersections. This is a waste of performance.
To remedy these issues, I suggest to introduce a method
bool GridView::mightHaveBoundaryIntersections( const Entity & ) const
which returns false if and only if the entity does not have an intersection with the boundary on that grid view. Always returning true
is a conforming implementation.
As a side effect, this also allows to write a grid view which introduces internal boundaries without wrapping the Entity and, hence, nearly all classes of the grid interface.