Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Annotation of /benchmarks/programs/lic2d/bmark-diderot.diderot
ViewVC logotype

Annotation of /benchmarks/programs/lic2d/bmark-diderot.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1596 - (view) (download)

1 : nseltzer 1592 // lic-turb.diderot
2 :     //
3 :     // demo of line integral convolution (LIC) on 2D turbulent flow
4 :     //
5 :     // process output with:
6 :     // unu reshape -i lic-turb2d.txt -s 3 1020 561 | unu quantize -b 8 -o lic-turb2d.ppm
7 :    
8 :     int imgSizeX = 1020;
9 :     int imgSizeY = 561;
10 :     real h = 0.005; // step size of integration
11 :     int stepNum = 10; // take this many steps both upstream and downstream
12 :    
13 :     field#2(2)[2] boundary = load("../../data/turb2d.nrrd") ⊛ bspln3;
14 :     field#2(2)[2] V = load("../../data/v.nrrd") ⊛ bspln3;
15 :     field#0(2)[] R = load("../../data/R.nrrd") ⊛ tent;
16 :    
17 :     strand LIC (int xi, int yi) {
18 :     real xx = lerp(0.04, 6.76, 0.0, real(xi), real(imgSizeX)-1.0);
19 :     real yy = lerp(0.04, 3.7, 0.0, real(yi), real(imgSizeY)-1.0);
20 :     vec2 pos0 = [xx,yy];
21 :     vec2 forw = pos0;
22 :     vec2 back = pos0;
23 :     real sum = R(pos0);
24 :     output vec3 RGB = [0.0, 0.0, 0.0];
25 :     real l = 0.0;
26 :     int step = 0;
27 :     int num = 1;
28 :     real crl = 0.0;
29 :    
30 :     update {
31 : jhr 1596 if (inside(forw, boundary)) {
32 : nseltzer 1592 forw += h*normalize(V(forw + 0.5*h*normalize(V(forw))));
33 :     sum += R(forw);
34 :     num += 1;
35 :     }
36 : jhr 1596 if (inside(back, boundary)) {
37 : nseltzer 1592 back -= h*normalize(V(back - 0.5*h*normalize(V(back))));
38 :     sum += R(back);
39 :     num += 1;
40 :     }
41 :     step += 1;
42 : jhr 1596 if ((!inside(forw, boundary) && !inside(back, boundary)) || step == stepNum) {
43 : nseltzer 1592 sum = pow(|V(pos0)|,0.3)*sum/real(num);
44 :     tensor[2,2] M = ∇⊗V(pos0);
45 :     crl = M[0,1] - M[1,0];
46 :     real s = lerp(0.0, 1.0, 0.0, |crl|, 132.0);
47 :     l = lerp(0.0, 1.0, -1.6, sum, 2.6);
48 :     real c = (1.0 - |2.0 * l - 1.0|) * s;
49 :     if(crl < 0.0) {
50 :     real x = c;
51 :     real m = l - c / 2.0;
52 :     RGB = [c + m, 0.0 + m, x + m];
53 :     }
54 :     else {
55 :     real x = 0.0;
56 :     real m = l - c / 2.0;
57 :     RGB = [0.0 + m, c + m, x + m];
58 :     }
59 :     stabilize;
60 :     }
61 :     }
62 :     }
63 :    
64 :     initially [ LIC(xi, yi) | yi in 0..(imgSizeY-1), xi in 0..(imgSizeX-1) ];

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0