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

SCM Repository

[diderot] View of /branches/fem/examples/lic_d2v2/lic_d2v2.diderot
ViewVC logotype

View of /branches/fem/examples/lic_d2v2/lic_d2v2.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3234 - (download) (annotate)
Fri Aug 14 13:35:44 2015 UTC (4 years ago) by cchiw
File size: 1161 byte(s)
updated examples
input int imgSizeX ;
input int imgSizeY;
input real h ;    // step size of integration
input int stepNum ; // take this many steps both upstream and downstream

input fem#1(2)[2] mV;
//input fem#0(2)[] mR;
field#1(2)[2] V=toField(mV);
//field#0(2)[] R=toField(mR);
field#0(2)[] R = image("../../data/vorttest-rand.nrrd") ⊛ tent;

strand LIC (int xi, int yi) {
    real xx = lerp(0.0, 3.0, -0.5, real(xi), real(imgSizeX)-0.5);
    real yy = lerp(0.0, 2.0, -0.5, real(yi), real(imgSizeY)-0.5);
    vec2 pos0 = [xx,yy];
    vec2 forw = pos0;
    vec2 back = pos0;
    output real out = R(pos0);
    int step = 0;

    update {
        // Euler integration step
        // forw = forw + h*V(forw);
        // back = back - h*V(back);
        // Midpoint method step
        forw += h*V(forw + 0.5*h*V(forw));
        back -= h*V(back - 0.5*h*V(back));
        out += R(forw) + R(back);
        step += 1;
        if (step == stepNum) {
          // modulate output by velocity at initial position
          out = |V(pos0)|*out/real(1 + 2*stepNum);
          stabilize;
        }
    }
}

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