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

SCM Repository

[diderot] View of /branches/charisee/ertest/vispaper/gmiso2d/gmiso2d.diderot
ViewVC logotype

View of /branches/charisee/ertest/vispaper/gmiso2d/gmiso2d.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2884 - (download) (annotate)
Fri Feb 27 04:23:44 2015 UTC (4 years, 5 months ago) by glk
File size: 1356 byte(s)
new data and test
/*

../../../bin/diderotc gmiso2d.diderot \
&& ./gmiso2d \
&& unu jhisto -i gmiso2d.txt -b 600 600 -min -1 -1 -max 1 1 | \
   unu 2op neq - 0 | \
   unu quantize -b 8 -o gmiso2d.png \
&& open gmiso2d.png

*/

//note my branch doesn't know Inputs, "InputWithDefault"
//input real isoval = 0.5;

real isoval = 1.0;
field#2(2)[] V = bspln3 ⊛ load("parab2.nrrd");
field#1(2)[] F = |∇V| - isoval;
field#0(2)[2] gradF = ∇F;


int grid = 150;
int stepsMax = 10;
real epsilon = 0.000001;

strand RootFind(real xi,real yi) {
   output vec2 x = [xi,yi];
   int steps = 0;


   update {
      // Stop if we're no longer inside or taken too many steps.
      if (!inside(x, V) || steps > stepsMax)
         die;

        vec2 grad = gradF(x);
        real m=|grad|;
      // subsequent expressions are undefined if |∇F| is zero
      if (m == 0.0)
         die;

      // the Newton-Raphson step
       vec2 delta = normalize(grad) * F(x)/m;

      // we've converged if the change is small enough
      if (|delta| < epsilon)
         stabilize;
      x -= delta;
      steps += 1;
   }
}

initially { RootFind(lerp(-1.5, 1.5, -0.5, ui, grid-0.5),
                      lerp(-1.5, 1.5, -0.5, vi, grid-0.5))
            | vi in 0..(grid-1), ui in 0..(grid-1) };

/*
 different in 3D:
 vec2 -> vec3
 field#1(2)[] F -> field#1(3)[] F
 initially over 3D grid
*/

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