Make geometry properties/capabilities static
The Geometry interface defines a method affine()
that can be used to make some optimization decisions, since for example the jacobians and integration elements are constant in the geometry. However, this property is only available as a runtime property, although in several cases it could be provided as a compile-time property. For example, AlbertaGrid has simplex elements only and all AlbertaGeometry
type have a constant bool affine() { return true; }
implemented.
Why would it be useful to have this property also as a static property? First, the optimizations mentioned before can be done at compiletime and we could even write class specializations for these cases. Second, some geometry transformations like chaining of geometries would benefit from that knowledge, e.g. a chaining of two affine geometries is also affine and the Jacobian can be computed just once as a product of two Jacobians.
In the design of the std::mdspan
data structure (and also std::mdarray
), there are some properties provided as static and dynamic properties, e.g. is_unique
and is_always_unique
. I would propose to do something similar also for the geometry interface:
struct Geometry
{
bool affine() const; // a runtime check whether the geometry is affine
static constexpr bool alwaysAffine(); // a compiletime check whether the geometries is guaranteed to always be affine
};
The property alwaysAffine
implied affine
(but not vice versa).
An example for a geometry that is not always affine, but sometimes, is the MultiLinearGeometry
. Examples for always affine geometries are the AffineGeometry
and the AxisAlignedCubeGeometry
and some grid-specific geometries.
Other useful properties could also be multilinear
and axisaligned
. This is not proposed here, but might be a future extension.
Alternative Designs
- We could add
Capabilities
for dune geometries, e.g.Capabilities::IsAffine<Geometry>::v
- We could provide a utility free function
constexpr bool isAffine(Geometry)
that checks whether the methodgeometry.affine()
is static constexpr and if so calls this method, otherwise defaults tofalse
. - Maybe a combination of both.