// CelerisLab – operators/collision_srt.cuh
// SRT (BGK) collision operator.
//   f_out[i] = (1 - ω) f[i] + ω feq[i] + Fin[i]
// ============================================================================

#ifndef CELERIS_OPERATORS_COLLISION_SRT_CUH
#define CELERIS_OPERATORS_COLLISION_SRT_CUH

__device__ __forceinline__ void collide_srt(float* __restrict__ f,
                                            const float* __restrict__ feq,
                                            const float* __restrict__ Fin,
                                            float omega)
{
    // Pre-compute forcing prefactor (1 - ω/2) for Guo scheme
    const float c_tau = 1.0f - 0.5f * omega;

    #pragma unroll
    for (int i = 0; i < NQ; i++) {
        f[i] = fmaf(1.0f - omega, f[i],
                     fmaf(omega, feq[i], c_tau * Fin[i]));
    }
}

// Variant without forcing (Fin = 0)
__device__ __forceinline__ void collide_srt_no_force(float* __restrict__ f,
                                                     const float* __restrict__ feq,
                                                     float omega)
{
    #pragma unroll
    for (int i = 0; i < NQ; i++) {
        f[i] = fmaf(1.0f - omega, f[i], omega * feq[i]);
    }
}

#endif // CELERIS_OPERATORS_COLLISION_SRT_CUH
