SPH Approximation of different functions:
In this example a userdefined function is discretized using SPH with the cubic spline kernel [KBST19]. The left plot shows the particle sampling pattern while the right plot shows the exact functions and their SPH approximations. To compute the SPH approximations the function values are sampled along the red line in the left plot. That means that for each point on the line the neighbors are determined and the SPH approximation formula is applied:
$$\langle f(x,y) \rangle = \sum_j \frac{m_j}{\rho_j} f(x_j,y_j) W_{ij}$$
Shepard filter
The SPH approximation of a fluid quantity is errorprone if the particle neighborhood is only partially filled. To consider this in the computation the smoothing kernel can be corrected by a factor $s_i$:
$$\tilde {W}_{ij} = s_i W_{ij} = \frac{1}{\sum_k \frac{m_k}{\rho_k} W_{ik}} W_{ij}.$$
References
 [KBST19] Dan Koschier, Jan Bender, Barbara Solenthaler, Matthias Teschner. Smoothed Particle Hydrodynamics for PhysicallyBased Simulation of Fluids and Solids. Eurographics Tutorial, 2019
