Nine-point stencil explained

In numerical analysis, given a square grid in two dimensions, the nine-point stencil of a point in the grid is a stencil made up of the point itself together with its eight "neighbors". It is used to write finite difference approximations to derivatives at grid points. It is an example for numerical differentiation. This stencil is often used to approximate the Laplacian of a function of two variables.

Motivation

If we discretize the 2D Laplacian by using central-difference methods, we obtain the commonly used five-point stencil, represented by the following convolution kernel:

DCD=\begin{bmatrix}0&1&0\ 1&-4&1\ 0&1&0\end{bmatrix}

Even though it is simple to obtain and computationally lighter, the central difference kernel possess an undesired intrinsic anisotropic property, since it doesn't take into account the diagonal neighbours. This intrinsic anisotropy poses a problem when applied on certain numerical simulations or when more accuracy is required, by propagating the Laplacian effect faster in the coordinate axes directions and slower in the other directions, thus distortiong the final result.

This drawback calls for finding better methods for discretizing the Laplacian, reducing or eliminating the anisotropy.

Implementation

The two most commonly used isotropic nine-point stencils are displayed below, in their convolution kernel forms. They can be obtained by the following formula:[1] [2]

D=(1-\gamma)\begin{bmatrix}0&1&0\\1&-4&1\\0&1&0\end{bmatrix} +\gamma\begin{bmatrix}1/2&0&1/2\\0&-2&0\\1/2&0&1/2\end{bmatrix}

The first one is known by Oono-Puri,[3] [4] [5] [6] [7] and it is obtained when γ=1/2.

DOP=\begin{bmatrix}1/4&2/4&1/4\ 2/4&-12/4&2/4\ 1/4&2/4&1/4\end{bmatrix}=\begin{bmatrix}0.25&0.5&0.25\ 0.5&-3&0.5\ 0.25&0.5&0.25\end{bmatrix}

The second one is known by Patra-Karttunen or Mehrstellen,[8] and it is obtained when γ=1/3.

DPK=\begin{bmatrix}1/6&4/6&1/6\ 4/6&-20/6&4/6\ 1/6&4/6&1/6\end{bmatrix}=\begin{bmatrix}0.16&0.66&0.16\ 0.66&-3.33&0.66\ 0.16&0.66&0.16\end{bmatrix}

Both are isotropic forms of discrete Laplacian, and in the limit of small Δx, they all become equivalent,[9] as Oono-Puri being described as the optimally isotropic form of discretization, displaying reduced overall error, and Patra-Karttunen having been systematically derived by imposing conditions of rotational invariance, displaying smallest error around the origin.

Desired anisotropy

On the other hand, if controlled anisotropic effects are a desired feature, when solving anisotropic diffusion problems for example, it is also possible to use the 9-point stencil combined with tensors to generate them.

Consider the laplacian in the following form:

2A=cD
c\nabla
OP

*A

Where c is just a constant coefficient. Now if we replace c by the 2nd rank tensor C:

C=\begin{bmatrix}c1&0\ 0&c2\end{bmatrix}

Where c1 is the constant coefficient for the principal direction in x axis, and c2 is the constant coefficient for the secondary direction in y axis. In order to generate anisotropic effects, c1 and c2 must be different.

By multiplying it by the rotation matrix Q, we obtain C', allowing anisotropic propagations in arbitrary directions other than the coordinate axes.[10]

Q=\begin{bmatrix} \cos\theta&\sin\theta\-\sin\theta&\cos\theta\end{bmatrix}

C'=QCQ\operatorname{T

}

C'=\begin{bmatrix}cxx&cxy\cxy&cyy\end{bmatrix}=\begin{bmatrix}c1

2\theta+c
\cos
2

\sin2\theta&(c2-c1)\cos\theta\sin\theta\(c2-c1)\cos\theta\sin\theta&c2

2\theta+c
\cos
1

\sin2\theta\end{bmatrix}

Which is very similar to the Cauchy stress tensor in 2 dimensions. The angle

\theta

can be obtained by generating a vector field

V=Vx{i}+Vy{j}

in order to orientate the pattern as desired. Then:

\theta=\arctan(Vy/Vx)

Or, for different anisotropic effects using the same vector field

\theta=\arctan(Vy/-Vx)

It is important to note that, regardless of the values of

\theta

, the anisotropic propagation will occur parallel to the secondary direcion c2 and perpendicular to the principal direction c1:. The resulting convolution kernel is as follows

DAniso=\begin{bmatrix}

-cxy
2

&cyy&

cxy
2

\cxx&-2(cxx+cyy)&cxx\

cxy
2

&cyy&

-cxy
2

\end{bmatrix}

If, for example, c1=c2=1, the cxy component will vanish, resulting in the simple five-point stencil, rendering no controlled anisotropy.

If c2>c1 and

\theta

=0, the anisotropic effects will be more pronounced in the vertical axis.

if c2>c1 and

\theta

=45 degrees, the anisotropic effects will be more pronounced in the upper-right / lower-left diagonal.

Notes and References

  1. Book: Fomel . Sergey . Exploring three-dimensional implicit wavefield extrapolation with the helix transform . Claerbout . Jon F. . October 9, 1997 . Stanford Exploration Project . Constructing an isotropic Laplacian operator . http://sepwww.stanford.edu/public/docs/sep95/sergey2/paper_html/node12.html .
  2. Web site: Scale-Space for Discrete Signals . Tony . Lindeberg . Royal Institute of Technology. Stockholm . 22–23.
  3. Computationally efficient modeling of ordering of quenched phases . 10.1103/PhysRevLett.58.836 . 837 . 1987 . Oono . Y. . Puri . S. . Physical Review Letters . 58 . 8 . 10035049 . 1987PhRvL..58..836O .  
  4. Study of phase-separation dynamics by use of cell dynamical systems. I. Modeling . 10.1103/PhysRevA.38.434 . 436 . 1988 . Oono . Y. . Puri . S. . Physical Review A . 38 . 1 . 9900182 . 1988PhRvA..38..434O.  
  5. Rigorous embedding of cell dynamics simulations in the Cahn-Hilliard-Cook framework: Imposing stability and isotropy . 10.1103/PhysRevE.91.053309 . 4 . 2015 . Sevink . G. J. A. . Physical Review E . 91 . 5 . 26066281 . 2015PhRvE..91e3309S . 1887/3194035. free .  
  6. Web site: Rotation-invariant Laplacian for 2D grids. March 21, 2021.
  7. Investigation of Isotropic Laplacian Operators by Computer Simulation for A-B Diblock Copolymers . IJCSNS International Journal of Computer Science and Network Security. 18 . 5 . May 2018. 102–103.
  8.  
  9.  
  10. Web site: 2012 . Bob . McGinty . Coordinate Transforms. continuummechanics.org.