Add strongly typed dynamic codim and subentity indentifiers
We already have Codim<i>
to statically wrap a codimension into a type because
this makes code much more readable. However, there are several places where a
codimension or a subentity (codimension+index) is specified dynamically
(e.g. in ReferenceElement
, IndexSet
). All these places suffer from
readability because they use plane indices, e.g. referenceElement::subEntity(i,j,k,l)
.
Code using this functionality would be much more readable and less error prone, if we use strong types to encode dynamic codimension or subentity information. A quick (but functional) prototype is attached, where all functionality is provided by global functions: referenceelementutility.hh
The prototype also contains a helper that returns a range with the result of ReferenceElement::subEntity(i,j,k,l)
for fixed i,j,l
and all suitable i
(guess what i
is ;-) ). This is IMHO a big improvement because you normally need the whole range anyway. Being able to ask for individual values gives the false impression of subsubentity consistency of the grid and the reference elements. This misconception leads to many discussions and people continue to ask for this or report (false) bugs.
As an example, marking all boundary vertices using this prototype could be implemented as follows:
const auto& indexSet = gridView.indexSet();
for(const auto& element: elements(gridView))
for(const auto& intersection: intersections(gridView, element))
if (intersection.boundary())
for(const auto& vertex: subVertices(referenceElement(element), insideFacet(intersection)))
isBoundary[subIndex(indexSet, element, vertex)] = true;