Skip to content

Use BOOST_PP to generate switch statement in MatrixFreeOps to allow ability to secify range

Spencer Sherwin requested to merge feature/Boost_PP_Switch into master

Issue/feature addressed

The switch statements in SwitchPoints.h and SwitchNodePoints.h are used to force compilation of templated versions and to get hold of these versions when calling the MatrixFree coded versions. The switch statements were manually set meaning that we could not increase or decrease the range of these switch statement. For example to improve compilation time (smaller range) or allow for polynomial/quadrature orderrs that were not in the switch statement.

Proposed solution

use BOOST_PP (boost preprocessing) to set up the switch loops where the max and min values of the switch cases can be defined outside of the switch.


Primarily used BOOST_PP_FOR which requies a test, update and a macro for each level of the switch statement. For the case where an nested switch statement was reuqired I also had to use BOOST_PP_FOR_r (recursive).


To test the code I compied with a verbose option and then for each shape used the --precompile c++ option to get a unpacked code and compared it against the origina.

Suggested reviewers

Chris, Dave, Jacque


  • Functions and classes, or changes to them, are documented.
  • [ ] User guide/documentation is updated.
  • Changelog is updated.
  • [ ] Suitable tests added for new functionality.
  • Contributed code is correctly formatted. (See the contributing guidelines).
  • [ ] License added to any new files.
  • No extraneous files have been added (e.g. compiler output or test data files).
Edited by Spencer Sherwin

Merge request reports