Nine-point stencil

From HandWiki
Revision as of 18:58, 6 February 2024 by John Stpola (talk | contribs) (fix)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Short description: Numerical analysis method


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.

An illustration of the nine-point stencil in two dimensions.

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:

[math]\displaystyle{ D_{CD}=\begin{bmatrix} 0 & 1 & 0 \\ 1 & -4 & 1 \\ 0 & 1 & 0\end{bmatrix} }[/math]

Starting from homogeneous initial conditions with only one point-like perturbation, the correct growth process would yield a circle (left). If growth is faster along the coordinate axes, which is caused by the anisotropic effect of central difference discretization, the circle would turn into star-shaped structure, as the errors propagate (right):[1].

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.[1]

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:[2][3]

[math]\displaystyle{ 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} }[/math]

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

[math]\displaystyle{ D_{OP}=\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} }[/math]

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

[math]\displaystyle{ D_{PK}=\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} }[/math]

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

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:

[math]\displaystyle{ c\nabla^2A=cD_{OP}*A }[/math]

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

[math]\displaystyle{ C=\begin{bmatrix} c_{1} & 0 \\ 0 & c_{2} \end{bmatrix} }[/math]

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.[12][13]

[math]\displaystyle{ Q = \begin{bmatrix} \cos \theta & \sin \theta \\ -\sin \theta & \cos \theta \end{bmatrix} }[/math]

[math]\displaystyle{ C'=QCQ^{\operatorname{T}} }[/math]

[math]\displaystyle{ C'=\begin{bmatrix} c_{xx} & c_{xy} \\ c_{xy} & c_{yy} \end{bmatrix}=\begin{bmatrix} c_{1}\cos^2\theta+c_{2}\sin^2\theta & (c_{2}-c_{1})\cos\theta\sin\theta \\ (c_{2}-c_{1})\cos\theta\sin\theta & c_{2}\cos^2\theta+c_{1}\sin^2\theta \end{bmatrix} }[/math]

The angle [math]\displaystyle{ \theta }[/math] can be obtained by generating a vector field [math]\displaystyle{ \mathbf{V}= V_x{\mathbf i} +V_y{\mathbf j} }[/math] in order to orientate the pattern as desired.[13] Then:

[math]\displaystyle{ \theta=\arctan(V_y/V_x) }[/math]

Or, for different anisotropic effects using the same vector field[14]

[math]\displaystyle{ \theta=\arctan(V_y/-V_x) }[/math]

It is important to note that, regardless of the values of [math]\displaystyle{ \theta }[/math], the anisotropic propagation will occur parallel to the secondary direcion c2 and perpendicular to the principal direction c1:[15]. The resulting convolution kernel is as follows[13]

[math]\displaystyle{ D_{Aniso}=\begin{bmatrix} \frac{-c_{xy}}{2} & c_{yy} & \frac{c_{xy}}{2} \\ c_{xx} & -2(c_{xx}+c_{yy}) & c_{xx} \\ \frac{c_{xy}}{2} & c_{yy} & \frac{-c_{xy}}{2} \end{bmatrix} }[/math]

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 [math]\displaystyle{ \theta }[/math]=0, the anisotropic effects will be more pronounced in the vertical axis.

if c2>c1 and [math]\displaystyle{ \theta }[/math]=45 degrees, the anisotropic effects will be more pronounced in the upper-right / lower-left diagonal.

References

  1. 1.0 1.1 1.2 Patra, Michael; Karttunen, Mikko (2006). "Stencils with isotropic discretization error for differential operators". Numerical Methods for Partial Differential Equations 22 (4): 3–7. doi:10.1002/num.20129. 
  2. 2.0 2.1 2.2 2.3 2.4 Fomel, Sergey; Claerbout, Jon F. (October 9, 1997). "Constructing an isotropic Laplacian operator". Exploring three-dimensional implicit wavefield extrapolation with the helix transform. http://sepwww.stanford.edu/public/docs/sep95/sergey2/paper_html/node12.html. 
  3. Lindeberg, Tony. "Scale-Space for Discrete Signals". Stockholm: Royal Institute of Technology. pp. 22–23. http://kth.diva-portal.org/smash/get/diva2:472968/FULLTEXT01.pdf. 
  4. Oono, Y.; Puri, S. (1987). "Computationally efficient modeling of ordering of quenched phases". Physical Review Letters 58 (8): 837. doi:10.1103/PhysRevLett.58.836. PMID 10035049. Bibcode1987PhRvL..58..836O. http://repository.ias.ac.in/31904/1/31904.pdf.  Free to read
  5. Oono, Y.; Puri, S. (1988). "Study of phase-separation dynamics by use of cell dynamical systems. I. Modeling". Physical Review A 38 (1): 436. doi:10.1103/PhysRevA.38.434. PMID 9900182. Bibcode1988PhRvA..38..434O. http://repository.ias.ac.in/32406/1/32406.pdf.  Free to read
  6. Sevink, G. J. A. (2015). "Rigorous embedding of cell dynamics simulations in the Cahn-Hilliard-Cook framework: Imposing stability and isotropy". Physical Review E 91 (5): 4. doi:10.1103/PhysRevE.91.053309. PMID 26066281. Bibcode2015PhRvE..91e3309S. https://scholarlypublications.universiteitleiden.nl/access/item%3A3194036/download.  Free to read
  7. 7.0 7.1 "Rotation-invariant Laplacian for 2D grids". March 21, 2021. https://eng.aurelienpierre.com/2021/03/rotation-invariant-laplacian-for-2d-grids/. 
  8. 8.0 8.1 8.2 8.3 "Investigation of Isotropic Laplacian Operators by Computer Simulation for A-B Diblock Copolymers". IJCSNS International Journal of Computer Science and Network Security 18 (5): 102–103. May 2018. http://paper.ijcsns.org/07_book/201805/20180514.pdf. Free to read
  9. 9.0 9.1 Thampi, Sumesh P.; Ansumali, Santosh; Adhikari, R.; Succi, Sauro (2013), "Isotropic discrete Laplacian operators from lattice hydrodynamics", Journal of Computational Physics 234: 3–7, doi:10.1016/j.jcp.2012.07.037, Bibcode2013JCoPh.234....1T 
  10. Lynch, Robert (7 January 1992), "Fundamental Solutions of 9-point Discrete Laplacians; Derivation and Tables", Department of Computer Science Technical Reports: 2, https://docs.lib.purdue.edu/cstech/929  Free to read
  11. Provatas, Nikolas; Elder, Ken (2010), Phase-Field Methods in Materials Science and Engineering, p. 219, doi:10.1002/9783527631520, ISBN 9783527631520, http://www.physics.mcgill.ca/~provatas/papers/Phase_Field_Methods_text.pdf  Free to read
  12. McGinty, Bob (2012). "Coordinate Transforms". http://www.continuummechanics.org/coordxforms.html. 
  13. 13.0 13.1 13.2 Witkin, Andrew; Kass, Michael (1991), "Reaction-diffusion textures", ACM SIGGRAPH Computer Graphics 25 (4): 3–4, doi:10.1145/127719.122750, http://www.cs.cmu.edu/afs/cs.cmu.edu/user/aw/www/pdf/texture.pdf Free to read
  14. Sanderson, Allen R.; Kirby, Robert M.; Johnson, Chris R.; Yang, Lingfa (2006), "Advanced Reaction-Diffusion Models for Texture Synthesis", Journal of Graphics Tools 11 (3): 4, doi:10.1080/2151237X.2006.10129222, http://www.sci.utah.edu/~allen/materials/Sanderson_JGT_2006.pdf 
  15. Garnier, David-Henri; Schmidt, Martin-Pierre; Rohmer, Damien (2022), "Growth of oriented orthotropic structures with reaction/Diffusion", Structural and Multidisciplinary Optimization 65 (11): 7–8, doi:10.1007/s00158-022-03395-7, https://hal.science/hal-03842830v1/document