Skip to content

WIP: Make geometry type handling more flexible

Carsten Gräser requested to merge feature/flexible-geometrytype into master

This implements three features: StaticGeometryType, LagrangeFiniteElementCache, and GeometryTypeProviders. Together they allow to avoid the polymorphic local finite element interface if either the grid only supports a single geometry type, or if you explicitly know that it only contains a single geometry type.

StaticGeometryType

This encodes all the information of a GeometryType as template parameters. Some remarks on the implementation:

  • This may be a solution for using geometry types a template paremters and is thus a candidate for dune-geometry
  • All methods in Dune::GeometryTypes:: have analogues in Dune::Functions::StaticGeometryTypes:: and additional template aliases for parametrized types. Hence you can e.g. use Simplex.
  • There is LocalHybridGeometryTypeIndex which works like LocalGeometryTypeIndex but supports GeometryType and StaticGeometryType.
  • Some topologyIds are different: If you want to overload for specific StaticGeometryTypes, you must be sure that the same geometry type leads to the same type. Hence topologyIds are normalize to have 0 in the first bit.
  • One may consider using uniqueTopologyId = (topologyId >> 1) as template parameter instead to get rid of the nasty non-uniqueness.

LagrangeFiniteElementCache

This works like PQkFiniteElementCache in dune-localfunctions but also allows to obtain raw fe-implemenations without polymorphic wrapper if the geometry type is provided statically as StaticGeometryType. This allows to seamlessly switch between the polymorphic and non-polymorphic version by using GeometryType or StaticGeometryType.

GeometryTypeProviders

These allow to map an entity to its geometry type. Depending on the selected provider and grid view, this is encoded as GeometryType or StaticGeometryType. There are several implementations:

  • MixedGeometryTypeProvider will always act like a mixed element grid and simply forward the dynamic GeometryType. You'd normally not want to use this one.
  • AutoGeometryTypeProvider will use a StaticGeometryType if the grid satisfies hasSingleGeometryType(). Otherwise GeometryType is used. This is the default choise which should work always.
  • SimplexGeometryTypeProvider and CubeGeometryTypeProvider will always provide the corresponding StaticGeometryType. This can be used to avoid the costly polymorphic interface if your grid supports mixed elements, but you know, that there are only simplices or cubes.

Merge request reports