Draft: Step 2 of redesign of quadrature rules
Summary
The classes QuadratureRule
, QuadratureRules
and QuadratureRuleFactory
are cleaned up in style, using static map for storing rules and modern enum classes. The quadrature rules are put into a common programming style, e.g. no intermediate point/weight construction, but directly storing coefficients in the quadrature rule.
Details
Four major changes are introduced in this MR:
- Quadrature rules (points and weights) are constructed directly and not via an intermediate c-array.
- The quadrature rules are stored in a cache in form of a
thread_local std::map
. This allows to easily extend the key types (currently to topology-id, the quadrature order and quadrature type). In some initial tests there was no performance different measurable. It could be discussed whether it would be better to use astatic std::map
+ locking, or whether another map, like anstd::unordered_map
would be the better choice. - The
QuadratureType
enum is now anenum class
. This might be a breaking change in some use-code, if the quadrature type is stored somewhere. Needed changes in user code: replaceDune::QuadratureType::Enum
byDune::QuadratureType
. - Instead of repeating all quarature points and weights for flating-point numbers and for string construction, a utility function/macro
DUNE_NUMBER -> Dune::Impl::number
is introduced to cover both cases at once. The macro takes a type and a floating-point literal and expands the latter into adouble
and aconst char*
. In theDune::Impl::number
template, it is then decided whether to construct from a string or returning the double value directly.
Motivation
This is the second step of a cleanup and redesign of the quadrature rules: 1.) put all rules into a similar structure. 2.) cleanup of the classes QuadratureRules and QuadratureFactory, 3.) Automatically generate coefficients for all rules with higher precision
The implementation intends to establish a common style that can be generated automatically in step 3 from a database.
Remarks
The simplexquadraturerule is transform from the old code using the attached python convert_rule.py and some postprocessing.