I want to calculate the stray magnetic field from a ferromagnet using the scalar potential method (1). The problem consists of a ferromagnetic cuboid divided into small cuboidal cells in which the magnetization $\mathbf{M}$ is assumed to be constant. To do this, I have to evaluate a convolution integral, discretized to a 3D - convolution sum (assuming all magnetization vectors point along $z$-axis)
$$\phi(\mathbf{r}_i) = \sum_j S_z(\mathbf{r}_i - \mathbf{r}_j)M_z(\mathbf{r}_j)$$
where $\phi$ is the scalar potential and $\mathbf{r}_i$ is the position vector a cell and $S_z$ is a known function. The solution is via FFT
$$\phi = \mathrm{F}^{-1}\left(\mathrm{F(S_z)} \, \mathrm{F}(M_z) \right)\, .$$
I am struggling to understand, especially the matrix representation of $S_z$, and how to proceed to perform the convolution with FFT.
References
- Abert, Claas, et al. "A fast finite-difference method for micromagnetics using the magnetic scalar potential." IEEE Transactions on Magnetics 48.3 (2011): 1105-1109.