// CelerisLab – boundary/inlet/equilibrium.cuh
// West velocity inlet source state built from full equilibrium.
//
// This method recovers rho from local west-boundary mass closure and then
// overwrites the full ghost-node state with feq(rho, u_target).
// It is robust for ghost-source architectures because it injects no boundary
// non-equilibrium content.
// ============================================================================

#ifndef CELERIS_BOUNDARY_INLET_EQUILIBRIUM_CUH
#define CELERIS_BOUNDARY_INLET_EQUILIBRIUM_CUH

#if LATTICE_MODEL == LATTICE_D2Q9
__device__ inline void apply_equilibrium_left_velocity_inlet_d2q9(
    float* __restrict__ f,
    float ux_target,
    float uy_target)
{
    const float rho = west_velocity_rho_closure_d2q9(f, ux_target);
    float feq[9];
    compute_feq(rho, ux_target, uy_target, feq);

    #pragma unroll
    for (int i = 0; i < 9; i++) {
        f[i] = feq[i];
    }
}
#endif

#if LATTICE_MODEL == LATTICE_D3Q19
__device__ inline void apply_equilibrium_left_velocity_inlet_d3q19(
    float* __restrict__ f,
    float ux_target,
    float uy_target,
    float uz_target)
{
    const float rho = west_velocity_rho_closure_d3q19(f, ux_target);
    float feq[19];
    compute_feq(rho, ux_target, uy_target, uz_target, feq);

    #pragma unroll
    for (int i = 0; i < 19; i++) {
        f[i] = feq[i];
    }
}
#endif

#endif // CELERIS_BOUNDARY_INLET_EQUILIBRIUM_CUH
