Commit a3c1deae authored by Pierre Aubert's avatar Pierre Aubert
Browse files

Fix Gray Scott comutation

parent 9b2e1792
......@@ -33,20 +33,21 @@ void naive_propagation(float * outMatU, float * outMatV, const float * matU, con
for(long i(0l); i < nbRow; ++i){
for(long j(0l); j < nbCol; ++j){
float fullU(0.0f), fullV(0.0f);
long firstRowStencil(std::max(i - offsetStencilRow, 0l));
long firstColStencil(std::max(j - offsetStencilCol, 0l));
long lastRowStencil(std::min(i + offsetStencilRow + 1l, nbStencilRow));
long lastColStencil(std::min(j + offsetStencilCol + 1l, nbStencilCol));
long lastRowStencil(std::min(i + offsetStencilRow + 1l, nbRow));
long lastColStencil(std::min(j + offsetStencilCol + 1l, nbCol));
long stencilIndexRow(0l), stencilIndexCol(0l);
long stencilIndexRow(0l);
float u(matU[i*nbCol + j]), v(matV[i*nbCol + j]);
float fullU(0.0f), fullV(0.0f);
for(long k(firstRowStencil); k < lastRowStencil; ++k){
long stencilIndexCol(0l);
for(long l(firstColStencil); l < lastColStencil; ++l){
// float deltaSquare(matDeltaSquare[stencilIndexRow*nbStencilCol + stencilIndexCol]);
float deltaSquare(1.0f);
if(k == 1l && l == 1l){continue;}
float deltaSquare(matDeltaSquare[stencilIndexRow*nbStencilCol + stencilIndexCol]);
// float deltaSquare(1.0f);
fullU += (matU[k*nbCol + l] - u)*deltaSquare;
fullV += (matV[k*nbCol + l] - v)*deltaSquare;
++stencilIndexCol;
......@@ -54,8 +55,8 @@ void naive_propagation(float * outMatU, float * outMatV, const float * matU, con
++stencilIndexRow;
}
float uvSquare(u*v*v);
float du(diffudionRateU*fullU*u - uvSquare + feedRate*(1 - u));
float dv(diffusionRateV*fullV*v + uvSquare - (feedRate + killRate)*v);
float du(diffudionRateU*fullU/**u*/ - uvSquare + feedRate*(1.0f - u));
float dv(diffusionRateV*fullV/**v*/ + uvSquare - (feedRate + killRate)*v);
outMatU[i*nbCol + j] = u + du*dt;
outMatV[i*nbCol + j] = v + dv*dt;
......
......@@ -90,13 +90,13 @@ bool simulateImage(size_t nbRow, size_t nbCol, size_t nbImage, size_t nbExtraSte
long nbStencilRow(3l), nbStencilCol(3l);
float diffudionRateU(0.01f), diffusionRateV(0.5f);
// float matDeltaSquare[] = {0.05f, 0.2f, 0.05f,
// 0.2f, -1.0f, 0.2f,
// 0.05f, 0.2f, 0.05f};
float matDeltaSquare[] = {1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f};
float diffudionRateU(0.1f), diffusionRateV(0.05f);
float matDeltaSquare[] = {0.05f, 0.2f, 0.05f,
0.2f, -1.0f, 0.2f,
0.05f, 0.2f, 0.05f};
// float matDeltaSquare[] = {1.0f, 1.0f, 1.0f,
// 1.0f, 1.0f, 1.0f,
// 1.0f, 1.0f, 1.0f};
for(size_t i(0lu); i < nbImage; ++i){
std::cout << "simulateImage n°" << i << "..." << std::endl;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment