summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilrik de Loose <wilrik@wilrik.nl>2007-12-13 14:37:35 (GMT)
committerWilrik de Loose <wilrik@wilrik.nl>2007-12-13 14:37:35 (GMT)
commit67465874258a26484ae39ce018caef6f0fbe0c92 (patch)
tree2f6aab02d27d2527c2930ff4a5c1fba997a4d955
parent24b088df4b8fec9e3ba988e72f8bf2c27dbed347 (diff)
download2iv35-67465874258a26484ae39ce018caef6f0fbe0c92.zip
2iv35-67465874258a26484ae39ce018caef6f0fbe0c92.tar.gz
2iv35-67465874258a26484ae39ce018caef6f0fbe0c92.tar.bz2
frame hist
-rw-r--r--Smoke/Week 2.ncbbin11930624 -> 11963392 bytes
-rw-r--r--Smoke/Week 2.suobin17408 -> 18432 bytes
-rw-r--r--Smoke/fluids.c43
3 files changed, 41 insertions, 2 deletions
diff --git a/Smoke/Week 2.ncb b/Smoke/Week 2.ncb
index e008392..a105095 100644
--- a/Smoke/Week 2.ncb
+++ b/Smoke/Week 2.ncb
Binary files differ
diff --git a/Smoke/Week 2.suo b/Smoke/Week 2.suo
index 699afbb..cda6f03 100644
--- a/Smoke/Week 2.suo
+++ b/Smoke/Week 2.suo
Binary files differ
diff --git a/Smoke/fluids.c b/Smoke/fluids.c
index bcd9684..f249425 100644
--- a/Smoke/fluids.c
+++ b/Smoke/fluids.c
@@ -38,6 +38,8 @@ fftw_real *vx0, *vy0; //(vx0,vy0) = velocity field at the previous mom
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 *hight_array; //used for hight plot
+int *frame_hist;
+int frame_index = 0;
rfftwnd_plan plan_rc, plan_cr; //simulation domain discretization
int winWidth, winHeight; //size of the graphics window, in pixels
@@ -84,6 +86,12 @@ struct color4f {
float a;
};
+struct point {
+ float x;
+ float y;
+ float z;
+};
+
//------ SIMULATION CODE STARTS HERE -----------------------------------------------------------------
//init_simulation: Initialize simulation data structures as a function of the grid size 'n'.
@@ -102,13 +110,19 @@ void init_simulation(int n)
vx0 = (fftw_real*) malloc(dim);
vy0 = (fftw_real*) malloc(dim);
dim = n * n * sizeof(fftw_real);
- fx = (fftw_real*) malloc(dim);
+ fx = (fftw_real*) malloc(dim);
fy = (fftw_real*) malloc(dim);
rho = (fftw_real*) malloc(dim);
rho0 = (fftw_real*) malloc(dim);
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);
- hight_array = (fftw_real*) malloc(dim);
+ hight_array = (fftw_real*) malloc(dim);
+ frame_hist = (int*) malloc(n * sizeof(int *));
+
+ for (i = 0; i <= n; i++)
+ {
+ frame_hist[i] = (fftw_real*)malloc(n * 2*(n/2+1)*sizeof(fftw_real));
+ }
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] = hight_array[i] = 0.0f; }
@@ -280,6 +294,28 @@ void calculate_hight_plot(void)
}
}
+void copy_frame(void)
+{
+ switch (vis_dataset)
+ {
+ case DATASET_FORCE:
+ // hight_array[i] = sqrt(fx[i] * fx[i] + fy[i] * fy[i]) * 100;
+ break;
+ case DATASET_VEL:
+ // hight_array[i] = sqrt(vx[i] * vx[i] + vy[i] * vy[i]) * 2000;
+ break;
+ case DATASET_RHO:
+ // hight_array[i] = rho[i] * 10;
+ memcpy(frame_hist[frame_index], rho, sizeof(DIM * 2 * (DIM / 2 + 1) * sizeof(fftw_real)));
+ break;
+ default:
+ case DATASET_DIVV:
+ case DATASET_DIVF:
+ // hight_array[i] = 0.0f;
+ break;
+ }
+ frame_index = (frame_index + 1) % DIM;
+}
//do_one_simulation_step: Do one complete cycle of the simulation:
// - set_forces:
@@ -294,6 +330,7 @@ void calculate_one_simulation_step(void)
solve(DIM, vx, vy, vx0, vy0, visc, dt);
diffuse_matter(DIM, vx, vy, rho, rho0, dt);
calculate_hight_plot();
+ copy_frame();
}
@@ -754,6 +791,8 @@ void draw_isolines(float threshold)
glEnd();
}
+//W
+
//visualize: This is the main visualization function
void visualize(void)
{