From 151a258568713f9b3c4e63a55747e6a0bce110ae Mon Sep 17 00:00:00 2001 From: Wilrik de Loose Date: Thu, 10 Jan 2008 16:01:42 +0000 Subject: --- Smoke/fluids.c | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/Smoke/fluids.c b/Smoke/fluids.c index a0bcb89..f1d5ea6 100644 --- a/Smoke/fluids.c +++ b/Smoke/fluids.c @@ -8,6 +8,7 @@ #endif #include +#include #include #include #include @@ -79,7 +80,7 @@ void fluids_init_simulation(int n, struct vis_data_arrays *vis_data) for (i = 0; i < HISTORY_SIZE; i++) { - vis_data->history[i] = (fftw_real *)malloc(dim1); +// vis_data->history[i] = (fftw_real *)malloc(dim1); } fluids_reset_simulation(); @@ -367,9 +368,9 @@ void copy_frames(fftw_real *dataset) } -float par_der(float xy1, float xy2, fftw_real cell) +float par_der(float vp1, float v, fftw_real cell) { - return (xy1 - (xy2/ cell)); + return (vp1 - v / cell); } @@ -412,7 +413,7 @@ void add_history_frame(int dataset, struct vis_data_arrays *vis_data) if (dataset != DATASET_HIST) { frame = get_frame(vis_data, dataset); - memcpy(vis_data->history[fluids_hisdex], frame, DIM * 2 * (DIM / 2 + 1) * sizeof(fftw_real)); +// memcpy(vis_data->history[fluids_hisdex], frame, DIM * 2 * (DIM / 2 + 1) * sizeof(fftw_real)); fluids_hisdex = (fluids_hisdex >= HISTORY_SIZE -1) ? 0 : fluids_hisdex +1; } } @@ -421,7 +422,7 @@ void add_history_frame(int dataset, struct vis_data_arrays *vis_data) void setup_arrays(struct vis_data_arrays *vis_data) { int idx, i, j; - float scale_min, scale_max; + float scale_min, scale_max, l, m; fftw_real *frame; @@ -437,30 +438,26 @@ void setup_arrays(struct vis_data_arrays *vis_data) { idx = (j * DIM) + i; - vis_data->rho[idx] = rho[idx]; - vis_data->vel[idx] = vec_len2f(vx[idx], vy[idx]); - vis_data->force[idx] = vec_len2f(fx[idx], fy[idx]); - vis_data->div_vel[idx] = par_der(vx[idx +1], vx[idx], wn) - +par_der(vy[idx +1], vy[idx], winHeight); - vis_data->div_force[idx] = par_der(fx[idx +1], fx[idx], hn) - +par_der(fy[idx +1], fy[idx], winHeight); + vis_data->rho[idx] = rho[idx]; + vis_data->vel[idx] = vec_len2f(vx[idx], vy[idx]); + vis_data->force[idx] = vec_len2f(fx[idx], fy[idx]); + vis_data->div_vel[idx] = par_der(vx[idx + 1], vx[idx], wn) + par_der(vy[idx + 1], vy[idx], wn); + vis_data->div_force[idx] = par_der(fx[idx + 1], fx[idx], hn) + par_der(fy[idx + 1], fy[idx], hn); - vis_data->height[idx] = calculate_height_plot(heightplots_get_dataset(), idx); + vis_data->height[idx] = calculate_height_plot(heightplots_get_dataset(), idx); + vis_data->normals[idx] = calculate_normal_vector(vis_data->height, idx, i, j); - vis_data->normals[idx] = calculate_normal_vector(vis_data->height, idx, i, j); -// if (normal_array[idx].z != vis_data->normals[idx].z) { -// printf("n: %lf; old: %lf\n", -// vis_data->normals[idx].z, normal_array[idx].z); -// } + if (frame[idx] < scale_min && frame[idx] > FLT_MIN) scale_min = frame[idx]; + if (frame[idx] > scale_max) scale_max = frame[idx]; - - - if (colormap_get_autoscaling()) { - if (scale_min > frame[idx]) { colormap_set_scale_min(frame[idx]); } - if (scale_max < frame[idx]) { colormap_set_scale_max(frame[idx]); } - } } } + + if (colormap_get_autoscaling()) + { + colormap_set_scale_min(scale_min); + colormap_set_scale_max(scale_max); + } } //do_one_simulation_step: Do one complete cycle of the simulation: @@ -495,7 +492,7 @@ void fluids_calculate_one_simulation_step(struct vis_data_arrays *vis_data) heightplots_set_frame(vis_data->height); normals_set_frame(vis_data->normals); - streamlines_set_history(vis_data->history); +// streamlines_set_history(vis_data->history); } //------ VISUALIZATION CODE STARTS HERE ----------------------------------------------------------------- -- cgit v0.12