int main() { /* Play with these constants, if you want */ const int sizeX = 128; const int sizeY = 128; const double density = 0.1; const double timestep = 0.005; unsigned char *image = new unsigned char[sizeX*sizeY*4]; FluidSolver *solver = new FluidSolver(sizeX, sizeY, density); double time = 0.0; int iterations = 0; while (time < 8.0) { for (int i = 0; i < 4; i++) { solver->addInflow(0.45, 0.2, 0.15, 0.03, 1.0, 0.0, 3.0); solver->update(timestep); time += timestep; fflush(stdout); } solver->toImage(image); char path[256]; sprintf(path, "Frame%05d.png", iterations++); lodepng_encode32_file(path, image, sizeX, sizeY); } return 0; }
int main() { /* Play with these constants, if you want */ const int sizeX = 128; const int sizeY = 128; const double density = 0.1; const double frameStep = 0.01999; const double maxTimestep = 0.005; unsigned char *image = new unsigned char[sizeX*sizeY*4]; FluidSolver *solver = new FluidSolver(sizeX, sizeY, density); double time = 0.0; int iterations = 0; while (time < 8.0) { double nextTime = time + frameStep; do { double timestep = min(solver->maxTimestep(), maxTimestep); if (time + timestep >= nextTime) { timestep = nextTime - time; time = nextTime; } else time += timestep; printf("Using timestep %f ", timestep); solver->addInflow(0.45, 0.2, 0.1, 0.01, 1.0, 0.0, 3.0); solver->update(timestep); fflush(stdout); } while (time < nextTime); solver->toImage(image); char path[256]; sprintf(path, "Frame%05d.png", iterations++); lodepng_encode32_file(path, image, sizeX, sizeY); } return 0; }