Multigrid algorithm below uses
*read/write to the same texture* yet and do not work
with DirectX 11 (Windows)
On 2D plane positive *u* values are displayed by the red color,
*Ta* by the green and stretching by the blue color.
This script uses simple explicit algorithm and
512×512 float32 textures with the Neumann (CLAMP_TO_EDGE)
boundary conditions. It makes *2 it* time steps *dt* per frame.
Use *Alt- r, s* keys to control the script (surprisingly they work in Firefox only).
## Linear elasticity

For small deformations the equilibrium equation in the displacement formulation is [1]

*(μ + λ)∇div***u** + μΔ**u**
+ **f** = 0, **f** = div(**I** Ta) = ∇Ta,

where **u** = (X, Y) is displacement of a point from equilibrium position,
*μ, λ* are Lame parameters (we put *μ = 1* ),
*Ta* represents the active stress in cardiac tissue [2]

*dTa/dt = ε(u) (k*_{T} u - Ta).

We consider tissue patch with fixed border **u**_{border} = 0.
Using 2-nd order finite differences we obtain the approximate equation

*(2 + λ)(X*_{i+1,j} + X_{i-1,j} - 2X_{i,j} ) +
X_{i,j+1} + X_{i,j-1} - 2X_{i,j} + (Y_{i+1,j+1} + Y_{i-1,j-1}
- Y_{i+1,j-1} - Y_{i-1,j+1} )(1 + λ)/4 + h^{2}Fx_{i,j} = 0,

Fx_{i,j} = (Ta_{i+1,j} - Ta_{i-1,j })/2h. (*)
## Multigrid algorithm

For weighted Jacobi relaxation [3] of *(X*_{i,j }, Y_{i,j }) on
*n×n* grid we rewrite equations (*) as

*2(3 + λ)X*_{i,j} = (2 + λ)(X_{i+1,j} + X_{i-1,j} ) +
X_{i,j+1} + X_{i,j-1} + (Y_{i+1,j+1} + Y_{i-1,j-1}
- Y_{i+1,j-1} - Y_{i-1,j+1} )(1 + λ)/4 + h^{2}Fx_{i,j}

Multigrid algorithm is used next.
In this simulation *λ = 1, ω = 4/5*. You can set all parameters in the script
by hand.

[1] Linear elasticity (Wiki)

[2] M.P. Nasha, A.V. Panfilov
*Electromechanical model of excitable tissue to study reentrant cardiac arrhythmias*
Progress in Biophysics & Molecular Biology **85** (2004) 501.

[3] William L. Briggs, Van Emden Henson, Steve F. McCormick
A Multigrid Tutorial
(look at "Tutorial Slides")

Heart rhythms
*updated* 2 Aug 2012