A crude drawing of the problem I'm interested in is shown below. I want to sum over the entire space, counting all the green vectors that terminate at some particular point and ignoring all the orange vectors that don't terminate at that point. I want to do this for all possible points. I'm not sure what kind of operation this is or how it should be formally described. Is there a common name/procedure for this kind of thing? The basis for the problem is understanding how mass at some points in the space 'flows' from one point to another. Note that I have already derived a PDE/conservation law to describe this behaviour in another context, but I am interested in something more general involving this unusual kind of set up.
Here's my attempt to describe it. Let $\mathbf{x}, \hat{\mathbf{x}} \in S$ be points in the space. Let $\mathbf{v}(\mathbf{x})$ be a vector at point $\mathbf{x}$ pointing to some other point in $S$. I define a function
$$ \begin{equation} f(\hat{\mathbf{x}}, \mathbf{x}) = \begin{cases} 1, & \text{if}\ \hat{\mathbf{x}} + \mathbf{v}(\hat{\mathbf{x}}) = \mathbf{x} \\ 0, & \text{otherwise}, \end{cases} \end{equation} $$
such that I can define the quantity I'm interested in as some kind of sum or integral (depending on whether the space is discrete or continuous) of the form
$$ \begin{equation} g(\mathbf{x}) = \int_{\hat{\mathbf{x}}} f(\hat{\mathbf{x}}, \mathbf{x}) \; dS \end{equation}. $$
Any thoughts appreciated.