diff options
Diffstat (limited to 'Smoke/fluids.c')
-rw-r--r-- | Smoke/fluids.c | 58 |
1 files changed, 2 insertions, 56 deletions
diff --git a/Smoke/fluids.c b/Smoke/fluids.c index 04d28d8..4a23c85 100644 --- a/Smoke/fluids.c +++ b/Smoke/fluids.c @@ -36,8 +36,6 @@ fftw_real *vx, *vy; //(vx,vy) = velocity field at the current mome fftw_real *vx0, *vy0; //(vx0,vy0) = velocity field at the previous moment fftw_real *fx, *fy; //(fx,fy) = user-controlled simulation forces, steered with the mouse fftw_real *rho, *rho0; //smoke density at the current (rho) and previous (rho0) moment -fftw_real *height_array; //used for height plot -struct point *normal_array; //used for normal vectors rfftwnd_plan plan_rc, plan_cr; //simulation domain discretization int winWidth, winHeight; //size of the graphics window, in pixels @@ -70,9 +68,6 @@ void fluids_init_simulation(int n, struct vis_data_arrays *vis_data) plan_rc = rfftw2d_create_plan(n, n, FFTW_REAL_TO_COMPLEX, FFTW_IN_PLACE); plan_cr = rfftw2d_create_plan(n, n, FFTW_COMPLEX_TO_REAL, FFTW_IN_PLACE); - height_array = (fftw_real*) malloc(dim2); - normal_array = (struct point *)malloc(dim *sizeof(struct point)); - for (i = 0; i < HISTORY_SIZE; i++) { vis_data->history_frame[i] = (fftw_real *)malloc(dim1); @@ -253,45 +248,10 @@ struct point vector_normal(struct point vert1, struct point vert2, struct point } -void calculate_normal_vectors(void) -{ - int i, j, idx; - struct point p1, p2, p3; - float px, py; - - fftw_real wn = (fftw_real)winWidth / (fftw_real)(DIM + 1); // Grid cell width - fftw_real hn = (fftw_real)winHeight / (fftw_real)(DIM + 1); // Grid cell height - - for (j = 0; j < DIM; j++) - { - for (i = 0; i < DIM; i++) - { - idx = (j * DIM) + i; - px = wn + (fftw_real)i * wn; - py = hn + (fftw_real)(j + 1) * hn; - - p1.x = px; - p1.y = py; - p1.z = height_array[idx]; - - p2.x = px; - p2.y = py + hn; - p2.z = height_array[idx + DIM]; - - p3.x = px + wn; - p3.y = py; - p3.z = height_array[idx + 1]; - - normal_array[idx] = vector_normal(p2, p1, p3); - normal_array[idx + 1] = vector_normal(p2, p1, p3); - } - } -} - struct point calculate_normal_vector(fftw_real *height, int index, int i, int j) { float px, py; - struct point p1, p2, p3, rv; + struct point p1, p2, p3; fftw_real wn = (fftw_real)winWidth / (fftw_real)(DIM + 1); // Grid cell width fftw_real hn = (fftw_real)winHeight / (fftw_real)(DIM + 1); // Grid cell height @@ -311,19 +271,7 @@ struct point calculate_normal_vector(fftw_real *height, int index, int i, int j) p3.y = py; p3.z = height[index + 1]; - normal_array[index] = vector_normal(p2, p1, p3); - rv = vector_normal(p2, p1, p3); - - return rv; -} - -void calculate_height_plots(void) -{ - int i; - for (i = 0; i < DIM * DIM; i++) - { - height_array[i] = rho[i] * 16; - } + return vector_normal(p2, p1, p3); } fftw_real calculate_height_plot(int dataset, int index) @@ -498,8 +446,6 @@ void fluids_calculate_one_simulation_step(struct vis_data_arrays *vis_data) set_forces(); solve(DIM, vx, vy, vx0, vy0, visc, dt); diffuse_matter(DIM, vx, vy, rho, rho0, dt); - calculate_height_plots(); - calculate_normal_vectors(); fluids_hisdex = (fluids_hisdex >= HISTORY_SIZE -1) ? 0 : fluids_hisdex +1; } |