summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilrik de Loose <wilrik@wilrik.nl>2008-01-10 16:01:42 (GMT)
committerWilrik de Loose <wilrik@wilrik.nl>2008-01-10 16:01:42 (GMT)
commit151a258568713f9b3c4e63a55747e6a0bce110ae (patch)
treebd84262aae7a9862ffdb5c1e7cc36a114d10dc11
parentddf0911cb40875378c53f35511a015c78b70034e (diff)
download2iv35-151a258568713f9b3c4e63a55747e6a0bce110ae.zip
2iv35-151a258568713f9b3c4e63a55747e6a0bce110ae.tar.gz
2iv35-151a258568713f9b3c4e63a55747e6a0bce110ae.tar.bz2
-rw-r--r--Smoke/fluids.c47
1 files 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 <math.h>
+#include <float.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -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 -----------------------------------------------------------------