diff options
author | Oliver Schinagl <oliver@schinagl.nl> | 2007-12-20 01:34:35 (GMT) |
---|---|---|
committer | Oliver Schinagl <oliver@schinagl.nl> | 2007-12-20 01:34:35 (GMT) |
commit | 4aabbced4987d0321827e4ae8bbd2e928205c9ba (patch) | |
tree | bad531cdacb7b4ce76e19f467e0c90677654c548 /Smoke/fluids.c | |
parent | c087310ffc1618cac7d0100b5492794f5d03db20 (diff) | |
download | 2iv35-4aabbced4987d0321827e4ae8bbd2e928205c9ba.zip 2iv35-4aabbced4987d0321827e4ae8bbd2e928205c9ba.tar.gz 2iv35-4aabbced4987d0321827e4ae8bbd2e928205c9ba.tar.bz2 |
moved alpha value constant to each of their own classes;
flowvis now draws copy of frame
Diffstat (limited to 'Smoke/fluids.c')
-rw-r--r-- | Smoke/fluids.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Smoke/fluids.c b/Smoke/fluids.c index fb7d65d..8e8620a 100644 --- a/Smoke/fluids.c +++ b/Smoke/fluids.c @@ -9,6 +9,7 @@ #include <math.h> #include <stdio.h> +#include <string.h> #include <rfftw.h> #include <GL/gl.h> @@ -58,11 +59,13 @@ float z_rot = 0.0f; //init_simulation: Initialize simulation data structures as a function of the grid size 'n'. // Although the simulation takes place on a 2D grid, we allocate all data structures as 1D arrays, // for compatibility with the FFTW numerical library. -void init_simulation(int n) +fftw_real *init_simulation(int n) { int i; size_t dim; + fftw_real *return_value; dim = n * 2*(n/2+1)*sizeof(fftw_real); //Allocate data structures + return_value = (fftw_real *)malloc(dim); vx = (fftw_real*) malloc(dim); vy = (fftw_real*) malloc(dim); vx0 = (fftw_real*) malloc(dim); @@ -85,6 +88,8 @@ void init_simulation(int n) for (i = 0; i < n * n; i++) //Initialize data structures to 0 { vx[i] = vy[i] = vx0[i] = vy0[i] = fx[i] = fy[i] = rho[i] = rho0[i] = height_array[i] = 0.0f; } + + return return_value; } int rescale_to_winwidth(float value) @@ -230,8 +235,10 @@ void calculate_hight_plot(void) } } -void copy_frame(void) +void copy_frame(fftw_real *field) { + memcpy(field, rho, DIM * 2 * (DIM / 2 + 1) * sizeof(fftw_real)); +#if 0 switch (vis_dataset) { case DATASET_FORCE: @@ -247,7 +254,7 @@ void copy_frame(void) case DATASET_DIVF: break; } - frame_index = (frame_index + 1) % DIM; +#endif } //do_one_simulation_step: Do one complete cycle of the simulation: @@ -257,13 +264,13 @@ void copy_frame(void) // - gluPostRedisplay: draw a new visualization frame -void calculate_one_simulation_step(void) +void calculate_one_simulation_step(fftw_real *field) { set_forces(); solve(DIM, vx, vy, vx0, vy0, visc, dt); diffuse_matter(DIM, vx, vy, rho, rho0, dt); calculate_hight_plot(); - copy_frame(); + copy_frame(field); } //------ VISUALIZATION CODE STARTS HERE ----------------------------------------------------------------- |