Expanding 'compute_entropy' in entropy.mako

Nature of bug

When ‘shock-capturing’ == ‘entropy-filter’, it looks like e_func is not defined when expanding the macros for internal and boundary interfaces.

So when entropy.mako gets expanded, e_func is neither ‘numerical’ nor ‘physical’,

In this case, neither line 13 nor 15 is included for calculating entropy.

Here is an example of the generated code:

  // Compute entropy for boundary state
  fpdtype_t p, d, entmin_rhs;
  {
    d = ur[0];
    fpdtype_t rcpd_ = 1.0f/d;
    fpdtype_t E_ = ur[3];

    // Compute the pressure
    p = 0.3999999999999999f*(E_ - 0.5f*rcpd_*(((ur[1])*(ur[1]) + (ur[2])*(ur[2]))));

    // Compute numerical or specific physical entropy
                           <-- empty line, entmin_rhs not calculated
  }

  // Compute face minima (reduce with atomics)
  entmin_lhs = entmin_rhs;

  atomic_min_fpdtype(&entmin_lhs_v[entmin_lhs_vix[X_IDX]], entmin_lhs);

“entmin_rhs” is left uninitialized, and then assigned to “entmin_lhs”.

Changing the [elif] to [else] at

seems to be a quick fix?

PyFR information

  • PyFR version: cloned May 6 2024
  • OS: Windows 11
  • System description: Threadripper + (3 x RTX 3090 Ti)
  • Compiler and version: Visual Studio 2022
  • Backend: cuda 12.1

This seems to be a bug in the BC interface kernels (although not in the internal interface kernels to my knowledge). I pushed a fix to Bug fix in entropy filter functional choice for BCs. by tarikdzanic · Pull Request #417 · PyFR/PyFR · GitHub.

1 Like