Advertisement
backstreetimrul

fluid.c 3

Jul 26th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 16.00 KB | None | 0 0
  1. // Usage: Drag with the mouse to add smoke to the fluid. This will also move a "rotor" that disturbs
  2. //        the velocity field at the mouse location. Press the indicated keys to change options
  3. //--------------------------------------------------------------------------------------------------
  4. #include <rfftw.h>              //the numerical simulation FFTW library
  5. #include <GL/glut.h>            //the GLUT graphics library
  6. #include <stdio.h>              //for printing the help text
  7. #include<math.h>
  8. int idx0, idx1, idx2, idx3;
  9. double px0, py0, px1, py1, px2, py2, px3, py3;
  10. float r, g, b, f;
  11.  
  12. //--- SIMULATION PARAMETERS ------------------------------------------------------------------------
  13. const int DIM = 50;             //size of simulation grid
  14. double dt = 0.4;                //simulation time step
  15. float visc = 0.001;             //fluid viscosity
  16. fftw_real *vx, *vy;             //(vx,vy)   = velocity field at the current moment
  17. fftw_real *vx0, *vy0;           //(vx0,vy0) = velocity field at the previous moment
  18. fftw_real *fx, *fy;             //(fx,fy)   = user-controlled simulation forces, steered with the mouse
  19. fftw_real *rho, *rho0;          //smoke density at the current (rho) and previous (rho0) moment
  20. rfftwnd_plan plan_rc, plan_cr;  //simulation domain discretization
  21.  
  22.  
  23. //--- VISUALIZATION PARAMETERS ---------------------------------------------------------------------
  24. int   winWidth, winHeight;      //size of the graphics window, in pixels
  25. int   color_dir = 0;            //use direction color-coding or not
  26. float vec_scale = 1000;         //scaling of hedgehogs
  27. int   draw_smoke = 0;           //draw the smoke or not
  28. int   draw_vecs = 1;            //draw the vector field or not
  29. const int COLOR_BLACKWHITE=0;   //different types of color mapping: black-and-white, rainbow, banded
  30. const int COLOR_RAINBOW=1;
  31. const int COLOR_BANDS=2;
  32. int   scalar_col = 0;           //method for scalar coloring
  33. int   frozen = 0;               //toggles on/off the animation
  34.  
  35.  
  36. //------ SIMULATION CODE STARTS HERE -----------------------------------------------------------------
  37.  
  38. //init_simulation: Initialize simulation data structures as a function of the grid size 'n'.
  39. //                 Although the simulation takes place on a 2D grid, we allocate all data structures as 1D arrays,
  40. //                 for compatibility with the FFTW numerical library.
  41. void init_simulation(int n)
  42. {
  43.     int i; size_t dim;
  44.  
  45.     dim     = n*2*(n/2+1)*sizeof(fftw_real);        //Allocate data structures
  46.     vx       = (fftw_real*) malloc(dim);
  47.     vy       = (fftw_real*) malloc(dim);
  48.     vx0      = (fftw_real*) malloc(dim);
  49.     vy0      = (fftw_real*) malloc(dim);
  50.     dim     = n * n * sizeof(fftw_real);
  51.     fx      = (fftw_real*) malloc(dim);
  52.     fy      = (fftw_real*) malloc(dim);
  53.     rho     = (fftw_real*) malloc(dim);
  54.     rho0    = (fftw_real*) malloc(dim);
  55.     plan_rc = rfftw2d_create_plan(n, n, FFTW_REAL_TO_COMPLEX, FFTW_IN_PLACE);
  56.     plan_cr = rfftw2d_create_plan(n, n, FFTW_COMPLEX_TO_REAL, FFTW_IN_PLACE);
  57.  
  58.     for (i = 0; i < n * n; i++)                      //Initialize data structures to 0
  59.     { vx[i] = vy[i] = vx0[i] = vy0[i] = fx[i] = fy[i] = rho[i] = rho0[i] = 0.0f; }
  60. }
  61.  
  62.  
  63. //FFT: Execute the Fast Fourier Transform on the dataset 'vx'.
  64. //     'dirfection' indicates if we do the direct (1) or inverse (-1) Fourier Transform
  65. void FFT(int direction,void* vx)
  66. {
  67.     if(direction==1) rfftwnd_one_real_to_complex(plan_rc,(fftw_real*)vx,(fftw_complex*)vx);
  68.     else             rfftwnd_one_complex_to_real(plan_cr,(fftw_complex*)vx,(fftw_real*)vx);
  69. }
  70.  
  71. int clamp(float x)
  72. { return ((x)>=0.0?((int)(x)):(-((int)(1-(x))))); }
  73.  
  74. //solve: Solve (compute) one step of the fluid flow simulation
  75. void solve(int n, fftw_real* vx, fftw_real* vy, fftw_real* vx0, fftw_real* vy0, fftw_real visc, fftw_real dt)
  76. {
  77.     fftw_real x, y, x0, y0, f, r, U[2], V[2], s, t;
  78.     int i, j, i0, j0, i1, j1;
  79.  
  80.     for (i=0;i<n*n;i++)
  81.     { vx[i] += dt*vx0[i]; vx0[i] = vx[i]; vy[i] += dt*vy0[i]; vy0[i] = vy[i]; }
  82.  
  83.     for ( x=0.5f/n,i=0 ; i<n ; i++,x+=1.0f/n )
  84.        for ( y=0.5f/n,j=0 ; j<n ; j++,y+=1.0f/n )
  85.        {
  86.           x0 = n*(x-dt*vx0[i+n*j])-0.5f;
  87.           y0 = n*(y-dt*vy0[i+n*j])-0.5f;
  88.           i0 = clamp(x0); s = x0-i0;
  89.           i0 = (n+(i0%n))%n;
  90.           i1 = (i0+1)%n;
  91.           j0 = clamp(y0); t = y0-j0;
  92.           j0 = (n+(j0%n))%n;
  93.           j1 = (j0+1)%n;
  94.           vx[i+n*j] = (1-s)*((1-t)*vx0[i0+n*j0]+t*vx0[i0+n*j1])+s*((1-t)*vx0[i1+n*j0]+t*vx0[i1+n*j1]);
  95.           vy[i+n*j] = (1-s)*((1-t)*vy0[i0+n*j0]+t*vy0[i0+n*j1])+s*((1-t)*vy0[i1+n*j0]+t*vy0[i1+n*j1]);
  96.        }
  97.  
  98.     for(i=0; i<n; i++)
  99.       for(j=0; j<n; j++)
  100.       {  vx0[i+(n+2)*j] = vx[i+n*j]; vy0[i+(n+2)*j] = vy[i+n*j]; }
  101.  
  102.     FFT(1,vx0);
  103.     FFT(1,vy0);
  104.  
  105.     for (i=0;i<=n;i+=2)
  106.     {
  107.        x = 0.5f*i;
  108.        for (j=0;j<n;j++)
  109.        {
  110.           y = j<=n/2 ? (fftw_real)j : (fftw_real)j-n;
  111.           r = x*x+y*y;
  112.           if ( r==0.0f ) continue;
  113.           f = (fftw_real)exp(-r*dt*visc);
  114.           U[0] = vx0[i  +(n+2)*j]; V[0] = vy0[i  +(n+2)*j];
  115.           U[1] = vx0[i+1+(n+2)*j]; V[1] = vy0[i+1+(n+2)*j];
  116.  
  117.           vx0[i  +(n+2)*j] = f*((1-x*x/r)*U[0]     -x*y/r *V[0]);
  118.           vx0[i+1+(n+2)*j] = f*((1-x*x/r)*U[1]     -x*y/r *V[1]);
  119.           vy0[i+  (n+2)*j] = f*(  -y*x/r *U[0] + (1-y*y/r)*V[0]);
  120.           vy0[i+1+(n+2)*j] = f*(  -y*x/r *U[1] + (1-y*y/r)*V[1]);
  121.        }
  122.     }
  123.  
  124.     FFT(-1,vx0);
  125.     FFT(-1,vy0);
  126.  
  127.     f = 1.0/(n*n);
  128.     for (i=0;i<n;i++)
  129.        for (j=0;j<n;j++)
  130.        { vx[i+n*j] = f*vx0[i+(n+2)*j]; vy[i+n*j] = f*vy0[i+(n+2)*j]; }
  131. }
  132.  
  133.  
  134. // diffuse_matter: This function diffuses matter that has been placed in the velocity field. It's almost identical to the
  135. // velocity diffusion step in the function above. The input matter densities are in rho0 and the result is written into rho.
  136. void diffuse_matter(int n, fftw_real *vx, fftw_real *vy, fftw_real *rho, fftw_real *rho0, fftw_real dt)
  137. {
  138.     fftw_real x, y, x0, y0, s, t;
  139.     int i, j, i0, j0, i1, j1;
  140.  
  141.     for ( x=0.5f/n,i=0 ; i<n ; i++,x+=1.0f/n )
  142.         for ( y=0.5f/n,j=0 ; j<n ; j++,y+=1.0f/n )
  143.         {
  144.             x0 = n*(x-dt*vx[i+n*j])-0.5f;
  145.             y0 = n*(y-dt*vy[i+n*j])-0.5f;
  146.             i0 = clamp(x0);
  147.             s = x0-i0;
  148.             i0 = (n+(i0%n))%n;
  149.             i1 = (i0+1)%n;
  150.             j0 = clamp(y0);
  151.             t = y0-j0;
  152.             j0 = (n+(j0%n))%n;
  153.             j1 = (j0+1)%n;
  154.             rho[i+n*j] = (1-s)*((1-t)*rho0[i0+n*j0]+t*rho0[i0+n*j1])+s*((1-t)*rho0[i1+n*j0]+t*rho0[i1+n*j1]);
  155.         }
  156. }
  157.  
  158. //set_forces: copy user-controlled forces to the force vectors that are sent to the solver.
  159. //            Also dampen forces and matter density to get a stable simulation.
  160. void set_forces(void)
  161. {
  162.     int i;
  163.     for (i = 0; i < DIM * DIM; i++)
  164.     {
  165.         rho0[i]  = 0.995 * rho[i];
  166.         fx[i] *= 0.85;
  167.         fy[i] *= 0.85;
  168.         vx0[i]    = fx[i];
  169.         vy0[i]    = fy[i];
  170.     }
  171. }
  172.  
  173.  
  174. //do_one_simulation_step: Do one complete cycle of the simulation:
  175. //      - set_forces:
  176. //      - solve:            read forces from the user
  177. //      - diffuse_matter:   compute a new set of velocities
  178. //      - gluPostRedisplay: draw a new visualization frame
  179. void do_one_simulation_step(void)
  180. {
  181.     if (!frozen)
  182.     {
  183.       set_forces();
  184.       solve(DIM, vx, vy, vx0, vy0, visc, dt);
  185.       diffuse_matter(DIM, vx, vy, rho, rho0, dt);
  186.       glutPostRedisplay();
  187.     }
  188. }
  189.  
  190.  
  191. //------ VISUALIZATION CODE STARTS HERE -----------------------------------------------------------------
  192.  
  193.  
  194. //rainbow: Implements a color palette, mapping the scalar 'value' to a rainbow color RGB
  195. void rainbow(float value,float* R,float* G,float* B)
  196. {
  197.    const float dx=0.8;
  198.    if (value<0) value=0; if (value>1) value=1;
  199.    value = (6-2*dx)*value+dx;
  200.    *R = max(0.0,(3-fabs(value-4)-fabs(value-5))/2);
  201.    *G = max(0.0,(4-fabs(value-2)-fabs(value-4))/2);
  202.    *B = max(0.0,(3-fabs(value-1)-fabs(value-2))/2);
  203. }
  204.  
  205. //set_colormap: Sets three different types of colormaps
  206. void set_colormap(float vy)
  207. {
  208.    float R,G,B;
  209.  
  210.    if (scalar_col==COLOR_BLACKWHITE)
  211.        R = G = B = vy;
  212.    else if (scalar_col==COLOR_RAINBOW)
  213.        rainbow(vy,&R,&G,&B);
  214.    else if (scalar_col==COLOR_BANDS)
  215.        {
  216.           const int NLEVELS = 7;
  217.           vy *= NLEVELS; vy = (int)(vy); vy/= NLEVELS;
  218.           rainbow(vy,&R,&G,&B);
  219.        }
  220.    glColor3f(R,G,B);
  221. }
  222.  
  223.  
  224. //direction_to_color: Set the current color by mapping a direction vector (x,y), using
  225. //                    the color mapping method 'method'. If method==1, map the vector direction
  226. //                    using a rainbow colormap. If method==0, simply use the white color
  227. void direction_to_color(float x, float y, int method)
  228. {
  229.     //float r,g,b,f;
  230.     if (method)
  231.     {
  232.       f = atan2(y,x) / 3.1415927 + 1;
  233.       r = f;
  234.       if(r > 1) r = 2 - r;
  235.       g = f + .66667;
  236.       if(g > 2) g -= 2;
  237.       if(g > 1) g = 2 - g;
  238.       b = f + 2 * .66667;
  239.       if(b > 2) b -= 2;
  240.       if(b > 1) b = 2 - b;
  241.     }
  242.     else
  243.     { r = g = b = 1; }
  244.     glColor3f(r,g,b);
  245. }
  246.  
  247. void colorbar()
  248. {
  249.     glBegin(GL_QUADS);
  250.     //------------------------------------------------------------
  251.                                 glColor3f(r, g, b);
  252.                                 glColor3f(0.58, 0.0, 0.82);
  253.     //glColor3f(1.0, 0.0, 0.0);
  254.     glVertex2f(600, 200);
  255.     glVertex2f(650, 200);
  256.                                 glColor3f(r, g, b);
  257.                                 glColor3f(0.3, 0.0, 0.51);
  258.     //glColor3f(0.0, 0.0, 1.0);
  259.     glVertex2f(650, 233.33);
  260.     glVertex2f(600, 233.33);
  261.                                 glColor3f(r, g, b);
  262.                                 glColor3f(0.3, 0.0, 0.51);
  263.     //glColor3f(0.0, 0.0, 1.0);
  264.     glVertex2f(650, 233.33);
  265.     glVertex2f(600, 233.33);
  266.                                 glColor3f(r, g, b);
  267.                                 glColor3f(0.0, 0.0, 1.0);
  268.     //glColor3f(0.0, 0.0, 1.0);
  269.     glVertex2f(600, 266.66);
  270.     glVertex2f(650, 266.66);
  271.                                 glColor3f(r, g, b);
  272.                                 glColor3f(0.0, 0.0, 1.0);
  273.     //glColor3f(0.0, 0.0, 1.0);
  274.     glVertex2f(600, 266.66);
  275.     glVertex2f(650, 266.66);
  276.                                 glColor3f(r, g, b);
  277.                                 glColor3f(0.0, 1.0, 0.0);
  278.     //glColor3f(0.0, 0.0, 1.0);
  279.     glVertex2f(650, 299.99);
  280.     glVertex2f(600, 299.99);
  281.                                 glColor3f(r, g, b);
  282.                                 glColor3f(0.0, 1.0, 0.0);
  283.     //glColor3f(0.0, 0.0, 1.0);
  284.     glVertex2f(650, 299.99);
  285.     glVertex2f(600, 299.99);
  286.                                 glColor3f(r, g, b);
  287.                                 glColor3f(1.0, 1.0, 0.0);
  288.     //glColor3f(0.0, 0.0, 1.0);
  289.     glVertex2f(600, 333.33);
  290.     glVertex2f(650, 333.33);
  291.                                 glColor3f(r, g, b);
  292.                                 glColor3f(1.0, 1.0, 0.0);
  293.     //glColor3f(0.0, 0.0, 1.0);
  294.     glVertex2f(600, 333.33);
  295.     glVertex2f(650, 333.33);
  296.                                 glColor3f(r, g, b);
  297.                                 glColor3f(1.0, 0.5, 0.0);
  298.     //glColor3f(0.0, 0.0, 1.0);
  299.     glVertex2f(650, 366.66);
  300.     glVertex2f(600, 366.66);
  301.                                 glColor3f(r, g, b);
  302.                                 glColor3f(1.0, 0.5, 0.0);
  303.     //glColor3f(0.0, 0.0, 1.0);
  304.     glVertex2f(650, 366.66);
  305.     glVertex2f(600, 366.66);
  306.                                 glColor3f(r, g, b);
  307.                                 glColor3f(1.0, 0.0, 0.0);
  308.     //glColor3f(0.0, 0.0, 1.0);
  309.     glVertex2f(600, 400);
  310.     glVertex2f(650, 400);
  311.  
  312.     glEnd();
  313.     glFlush();
  314. }
  315.  
  316. //visualize: This is the main visualization function
  317. void visualize(void)
  318. {
  319.     colorbar();
  320.     /***
  321.     glBegin(GL_QUADS);
  322.     glColor3f(1.0,0.0,0.0);
  323.     glVertex2f(600,200);
  324.     glVertex2f(650,200);
  325.     glColor3f(0.0,0.0,1.0);
  326.     glVertex2f(650,400);
  327.     glVertex2f(600,400);
  328.     glEnd();
  329.     glFlush();
  330.     ***/
  331.    
  332.  
  333.  
  334.  
  335.     int i, j, idx;
  336.     fftw_real  wn = (fftw_real)(winWidth - 300) / (fftw_real)(DIM + 1);   // Grid cell width
  337.     fftw_real  hn = (fftw_real)winHeight / (fftw_real)(DIM + 1);  // Grid cell heigh    printf(winWidth);
  338.  
  339.  
  340.     if (draw_smoke)
  341.     {
  342.         //int idx0, idx1, idx2, idx3;
  343.         //double px0, py0, px1, py1, px2, py2, px3, py3;
  344.         glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
  345.        
  346.  
  347.         glBegin(GL_TRIANGLES);
  348.         for (j = 0; j < DIM - 1; j++)            //draw smoke
  349.         {
  350.            
  351.             for (i = 0; i < DIM - 1; i++)
  352.             {
  353.                
  354.                 px0 = wn + (fftw_real)i * wn;
  355.                 py0 = hn + (fftw_real)j * hn;
  356.                 idx0 = (j * DIM) + i;
  357.  
  358.  
  359.                 px1 = wn + (fftw_real)i * wn;
  360.                 py1 = hn + (fftw_real)(j + 1) * hn;
  361.                 idx1 = ((j + 1) * DIM) + i;
  362.                 px2 = wn + (fftw_real)(i + 1) * wn;
  363.                 py2 = hn + (fftw_real)(j + 1) * hn;
  364.                 idx2 = ((j + 1) * DIM) + (i + 1);
  365.  
  366.  
  367.                 px3 = wn + (fftw_real)(i + 1) * wn;
  368.                 py3 = hn + (fftw_real)j * hn;
  369.                 idx3 = (j * DIM) + (i + 1);
  370.  
  371.                 set_colormap(rho[idx0]);    
  372.                                             glVertex2f(px0, py0);
  373.                 set_colormap(rho[idx1]);  
  374.                                             glVertex2f(px1, py1);
  375.                 set_colormap(rho[idx2]);    
  376.                                             glVertex2f(px2, py2);
  377.  
  378.                 set_colormap(rho[idx0]);    
  379.                                             glVertex2f(px0, py0);
  380.                 set_colormap(rho[idx2]);    
  381.                                             glVertex2f(px2, py2);
  382.                 set_colormap(rho[idx3]);    
  383.                                             glVertex2f(px3, py3);
  384.    
  385.             }
  386.         }
  387.         glEnd();
  388.     }
  389.  
  390.     if (draw_vecs)
  391.     {
  392.         glBegin(GL_LINES);              //draw velocities
  393.         for (i = 0; i < DIM; i++)
  394.             for (j = 0; j < DIM; j++)
  395.             {
  396.                 idx = (j * DIM) + i;
  397.                 direction_to_color(vx[idx],vy[idx],color_dir);
  398.                 glVertex2f(wn + (fftw_real)i * wn, hn + (fftw_real)j * hn);
  399.                 glVertex2f((wn + (fftw_real)i * wn) + vec_scale * vx[idx], (hn + (fftw_real)j * hn) + vec_scale * vy[idx]);
  400.             }
  401.         glEnd();
  402.     }
  403. }
  404.  
  405.  
  406. //------ INTERACTION CODE STARTS HERE -----------------------------------------------------------------
  407.  
  408. //display: Handle window redrawing events. Simply delegates to visualize().
  409. void display(void)
  410. {
  411.     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  412.     glMatrixMode(GL_MODELVIEW);
  413.     glLoadIdentity();
  414.     visualize();
  415.  
  416.     glFlush();
  417.     glutSwapBuffers();
  418. }
  419.  
  420. //reshape: Handle window resizing (reshaping) events
  421. void reshape(int w, int h)
  422. {
  423.     glViewport(0.0f, 0.0f, (GLfloat)w, (GLfloat)h);
  424.     glMatrixMode(GL_PROJECTION);
  425.     glLoadIdentity();
  426.     gluOrtho2D(0.0, (GLdouble)w, 0.0, (GLdouble)h);
  427.     winWidth = w; winHeight = h;
  428. }
  429.  
  430. //keyboard: Handle key presses
  431. void keyboard(unsigned char key, int x, int y)
  432. {
  433.     switch (key)
  434.     {
  435.       case 't': dt -= 0.001; break;
  436.       case 'T': dt += 0.001; break;
  437.       case 'c': color_dir = 1 - color_dir; break;
  438.       case 'S': vec_scale *= 1.2; break;
  439.       case 's': vec_scale *= 0.8; break;
  440.       case 'V': visc *= 5; break;
  441.       case 'vy': visc *= 0.2; break;
  442.       case 'x': draw_smoke = 1 - draw_smoke;
  443.             if (draw_smoke==0) draw_vecs = 1; break;
  444.       case 'y': draw_vecs = 1 - draw_vecs;
  445.             if (draw_vecs==0) draw_smoke = 1; break;
  446.       case 'm': scalar_col++; if (scalar_col>COLOR_BANDS) scalar_col=COLOR_BLACKWHITE; break;
  447.       case 'a': frozen = 1-frozen; break;
  448.       case 'q': exit(0);
  449.     }
  450. }
  451.  
  452.  
  453.  
  454. // drag: When the user drags with the mouse, add a force that corresponds to the direction of the mouse
  455. //       cursor movement. Also inject some new matter into the field at the mouse location.
  456. void drag(int mx, int my)
  457. {
  458.     int xi,yi,X,Y; double  dx, dy, len;
  459.     static int lmx=0,lmy=0;             //remembers last mouse location
  460.  
  461.     // Compute the array index that corresponds to the cursor location
  462.     xi = (int)clamp((double)(DIM + 1) * ((double)mx / (double)winWidth));
  463.     yi = (int)clamp((double)(DIM + 1) * ((double)(winHeight - my) / (double)winHeight));
  464.  
  465.     X = xi; Y = yi;
  466.  
  467.     if (X > (DIM - 1))  X = DIM - 1; if (Y > (DIM - 1))  Y = DIM - 1;
  468.     if (X < 0) X = 0; if (Y < 0) Y = 0;
  469.  
  470.     // Add force at the cursor location
  471.     my = winHeight - my;
  472.     dx = mx - lmx; dy = my - lmy;
  473.     len = sqrt(dx * dx + dy * dy);
  474.     if (len != 0.0) {  dx *= 0.1 / len; dy *= 0.1 / len; }
  475.     fx[Y * DIM + X] += dx;
  476.     fy[Y * DIM + X] += dy;
  477.     rho[Y * DIM + X] = 10.0f;
  478.     lmx = mx; lmy = my;
  479. }
  480.  
  481.  
  482. //main: The main program
  483. int main(int argc, char **argv)
  484. {
  485.     printf("Fluid Flow Simulation and Visualization\n");
  486.     printf("=======================================\n");
  487.     printf("Click and drag the mouse to steer the flow!\n");
  488.     printf("T/t:   increase/decrease simulation timestep\n");
  489.     printf
  490.     ("S/s:   increase/decrease hedgehog scaling\n");
  491.     printf("c:     toggle direction coloring on/off\n");
  492.     printf("V/vy:   increase decrease fluid viscosity\n");
  493.     printf("x:     toggle drawing matter on/off\n");
  494.     printf("y:     toggle drawing hedgehogs on/off\n");
  495.     printf("m:     toggle thru scalar coloring\n");
  496.     printf("a:     toggle the animation on/off\n");
  497.     printf("q:     quit\n\n");
  498.  
  499.     glutInit(&argc, argv);
  500.     glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
  501.     //glutInitWindowSize(500,500);
  502.     glutInitWindowSize(800, 500);
  503.     glutCreateWindow("Real-time smoke simulation and visualization");
  504.     glutDisplayFunc(display);
  505.     glutReshapeFunc(reshape);
  506.     glutIdleFunc(do_one_simulation_step);
  507.     glutKeyboardFunc(keyboard);
  508.     glutMotionFunc(drag);
  509.  
  510.  
  511.     init_simulation(DIM);   //initialize the simulation data structures
  512.     glutMainLoop();         //calls do_one_simulation_step, keyboard, display, drag, reshape
  513.     return 0;
  514. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement