doyubkim / fluid-engine-dev

Fluid simulation engine for computer graphics applications
https://fluidenginedevelopment.org/
MIT License
1.88k stars 263 forks source link

GridSmokeSolver3::computeDiffusion is diffusing smokeDensity instead of temperature #325

Closed kentbarber closed 2 years ago

kentbarber commented 2 years ago

I noticed that on line 107 of grid_smoke_solver3.cpp that it is using smokeDensity

if (_temperatureDiffusionCoefficient > kEpsilonD) {
            auto temp = smokeDensity();

But shouldn't that be using temperature?

if (_temperatureDiffusionCoefficient > kEpsilonD) {
            auto temp = temperature();

Same issue in GridSmokeSolver2. I changed my local code to use temperature() instead of smokeDensity() and now it looks like it is giving the correct results.

kentbarber commented 2 years ago

This is the result I get now, where in this example I have the temperature diffusion coefficient is set to 0.1 and it is now diffusing the temperature grid properly, resulting here in the fire using the temperature grid in a blackbody rendering using Redshift.

https://user-images.githubusercontent.com/12145275/178088889-1d1c666a-5fcc-4628-a8f4-6935829dcd8e.mp4

doyubkim commented 2 years ago

Nice catch!! Feel free to raise a PR for the fix.