// CelerisLab -- boundary/esopull_curved_helpers.cuh
// Curved-specific EsoPull helpers (target address resolution).
//
// The base semantic helpers (esopull_slot, esopull_src_cell,
// load_physical_dir_esopull et al.) are in streaming/esopull_semantic_helpers.cuh.
// ============================================================================

#ifndef CELERIS_BOUNDARY_ESOPULL_CURVED_HELPERS_CUH
#define CELERIS_BOUNDARY_ESOPULL_CURVED_HELPERS_CUH

#include "../streaming/esopull_semantic_helpers.cuh"

// Compute the cell and slot that the reflected population should be written to.
// For EsoPull, this depends on the cut-link direction parity and current timestep.
__device__ __forceinline__ void resolve_esopull_target(
    unsigned long k_f, unsigned long k_s,
    unsigned int dir, unsigned long t,
    unsigned long& target_cell, unsigned int& target_slot)
{
    target_cell = (dir & 1u) ? k_s : k_f;
    target_slot = (t & 1ul) ? (unsigned int)opp_dir((int)dir) : dir;
}

#endif // CELERIS_BOUNDARY_ESOPULL_CURVED_HELPERS_CUH
