Permit contextual type casts. Reintroduce flag_cond as bit_conditional.
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 toPsCast
to beNone
, 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 thesympyextensions
module and reimplemented asbit_conditional
. Its implementation is emitted byFreezeExpressions
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