Home My Page Projects Code Snippets Project Openings diderot

# SCM Repository

[diderot] Diff of /branches/lamont/test/implicit-surface/unit-circle.diderot
 [diderot] / branches / lamont / test / implicit-surface / unit-circle.diderot

# Diff of /branches/lamont/test/implicit-surface/unit-circle.diderot

revision 2132, Fri Feb 8 22:06:12 2013 UTC revision 2137, Thu Feb 14 12:39:47 2013 UTC
# Line 2  Line 2
2  //  //
3  // Demo of distributing particles on the unit circle  // Demo of distributing particles on the unit circle
4  //  //
5  int numOfParticles = 1000;  real{} initPosns = load("data/implicit-surface/circlePosns.nrrd");
6    int numOfParticles = length(initVelocities)/2;
7    input real r;  // particle radius
8  strand Particle (int i) {  input real d;  // desired difference of radius (d < r && d > 0)
9      output vec2 pos = [0.0,0.0];  input real R;  // neighbor radius
10    input real h;  // integration stepsize scaling ∇E update lenght
11    input real maxi; // maximum number of steps in the program
12
13    strand Particle (real posx, real posy) {
14        output vec2 pos = [posx,posy];
15      real isoval = 1;      real isoval = 1;
16      int steps = 0;      int steps = 0;
17
# Line 18  Line 22
22
23          for(Particle neighbor in sphere(raidus) {          for(Particle neighbor in sphere(raidus) {
24              real d = distance (pos,neighbor.pos);              real d = distance (pos,neighbor.pos);
if(d > 0) {
25                  if(d >= 0 && d <= 1) {                  if(d >= 0 && d <= 1) {
26                     force += -4.0 * ((1 - d)^3);                     force += -4.0 * ((1 - d)^3);
27                     energy += ((1 - d)^4);                     energy += ((1 - d)^4);
28                  }                  }
29              }              }
30          }          pos = pos + force;
31            pos = pos / |pos|;

if (|grad| == 0.0) {    // can't compute step if |∇F|, so have to bail
die;
}
vec2 delta = -((F(pos) - isoval)/|grad|)*norm;  // Newton-Raphson step
if (|delta| < epsilon) {    // we've converged if step is small enough
stabilize;
}
pos += stepScale * delta;
steps += 1;
32      }      }
33  }  }
34  initially {Particle(i) | i in 0 .. numOfParticles-1 };  initially {Particle(initPosns{i*2},initPosns{i*2+1}) | i in 0 .. numOfParticles-1 };
35

Legend:
 Removed from v.2132 changed lines Added in v.2137