Parallel Spectral Numerical Methods/Gray Scott

Background
$$ \frac{\partial u}{\partial t} = D_{u} \nabla ^{2} u-uv^{2}+F (1-u) $$ $$ \frac{\partial v}{\partial t} = D_{v} \nabla ^{2} u+uv^{2}-(F+k)v $$ The above reaction-diffusion system describes the density of two chemicals ,($$u$$ and $$v$$), reacting with another. First term in the equations is for the diffusion, the second describes the reaction of $$u$$ and $$v$$,($$u+2v$$ → $$3v$$) and the last term in the first equation is the input of new $$u$$, while in the second the last term removes $$v$$ from the system.

Matlab Program
The program solves the linear part with fourier transformation and the nonlinear part with the implicit midpoint rule. A Matlab program to solve the 3-dimensional GrayScott equation Code download To compute the visualisation download vol3d.m.

Fortran Program
The program uses 2decomp_fft like the programs from previous chapters. A Fortran program to solve the 3-dimensional GrayScott equation Code download

OpenCL
In OpenCL you write a 'Kernel' to do the intense work in parallel. You can choose to run the kernel on your cpu, gpu or some other coprocessor. The kernel is compiled during runtime for the device you have choosen.

To run the following code you need an valid OpenCL 1.2 framework for example AMD APP SDK which runs also on non AMD CPU's. You also need clfft an implementation of the FFT for OpenCL.

The main program to solve the 2-dimensional GrayScott equation Code download

You can change "chooseplatform" and "choosedevice" to the device you want to compute on.

This file contains some functions to give the main code better read ability. Code download

Now all the OpenCL-Kernel's, which should be saved in the same folder.

initialdata.clCode download

frequencies.cl Code download

linearpart.cl Code download

nonlinearpart_a.cl Code download

nonlinearpart_b.cl Code download

Here is your makefile! Change the clFFT to your path.

makefile Code download

To run you need the INPUTFILE with the parameters.

INPUTFILE Code download

To view the data, compile and run xdmfcreate.f90. Open udata.xdmf and vdata.xdmf in ParaView.

xdmfcreate.f90 Code download