Skip to content

Permit contextual type casts. Reintroduce flag_cond as bit_conditional.

Frederik Hennig requested to merge fhennig/bit-conditional into v2.0-dev

This MR extends PsCast to permit automatic inference of the cast's target type by the typifier, renames bit_masks.flag_cond to sympyextensions.bit_conditional, and reimplements code generation for that function using contextual type casts.

  • Permit the target_type argument to PsCast to be None, in which case it will be inferred during typification. This allows us to use type casts in contexts of yet-unknown type.

  • The function flag_cond, used primarily by LBM mesh refinement in waLBerla, is moved to the sympyextensions module and reimplemented as bit_conditional. Its implementation is emitted by FreezeExpressions using bitwise operations and a contextual type cast. The implementation fixes a bug present in the original where the pure XOR operation in the else branch was not sufficient to invert the selected bit.

  • Add to documentation

Edited by Frederik Hennig

Merge request reports