35 void grayscott_propagation(
float * outMatU,
float * outMatV,
const float * matU,
const float * matV,
long nbRow,
long nbCol,
36 const float * matDeltaSquare,
long nbStencilRow,
long nbStencilCol,
37 float diffudionRateU,
float diffusionRateV,
float feedRate,
float killRate,
float dt)
42 long offsetStencilRow((nbStencilRow - 1l)/2l);
43 long offsetStencilCol((nbStencilCol - 1l)/2l);
47 for(
long i(0l); i < nbRow; ++i){
48 for(
long j(0l); j < nbCol; ++j){
52 long firstRowStencil(std::max(i - offsetStencilRow, 0l));
53 long firstColStencil(std::max(j - offsetStencilCol, 0l));
55 long lastRowStencil(std::min(i + offsetStencilRow + 1l, nbRow));
56 long lastColStencil(std::min(j + offsetStencilCol + 1l, nbCol));
60 long stencilIndexRow(0l);
61 float u(matU[i*nbCol + j]), v(matV[i*nbCol + j]);
62 float fullU(0.0f), fullV(0.0f);
66 for(
long k(firstRowStencil); k < lastRowStencil; ++k){
67 long stencilIndexCol(0l);
68 for(
long l(firstColStencil); l < lastColStencil; ++l){
72 float deltaSquare(matDeltaSquare[stencilIndexRow*nbStencilCol + stencilIndexCol]);
73 fullU += (matU[k*nbCol + l] - u)*deltaSquare;
74 fullV += (matV[k*nbCol + l] - v)*deltaSquare;
85 float uvSquare(u*v*v);
86 float du(diffudionRateU*fullU - uvSquare + feedRate*(1.0f - u));
87 float dv(diffusionRateV*fullV + uvSquare - (feedRate + killRate)*v);
91 outMatU[i*nbCol + j] = u + du*dt;
92 outMatV[i*nbCol + j] = v + dv*dt;
void grayscott_propagation(float *outMatU, float *outMatV, const float *matU, const float *matV, long nbRow, long nbCol, const float *matDeltaSquare, long nbStencilRow, long nbStencilCol, float diffudionRateU, float diffusionRateV, float feedRate, float killRate, float dt)
Propagate the U and V species in the matU and matV.