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

# SCM Repository

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

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

revision 2268, Thu Mar 7 12:53:00 2013 UTC revision 2269, Thu Mar 7 13:56:24 2013 UTC
# Line 4  Line 4
4  //  //
5  real{} initPosns = load("posns.nrrd");  real{} initPosns = load("posns.nrrd");
6  int numOfParticles = length(initPosns)/2;  int numOfParticles = length(initPosns)/2;
7  input int iterMax = 5;  // maximum number of steps to run  input int iterMax = 500;  // maximum number of steps to run
8  input real rr = 0.2;      // actual particle radius  input real rr = 0.2;      // actual particle radius
9    real d = rr - 0.2;   // desired distance for a new particle.
10  real RR = rr+0.0;         // neighbor query radius (MUST be >= rr; should get same results for any RR >= rr)  real RR = rr+0.0;         // neighbor query radius (MUST be >= rr; should get same results for any RR >= rr)
11  real hhInit = 10.0;       // initial integration step size; can err too big, will be trimmed down during iterations  real hhInit = 10.0;       // initial integration step size; can err too big, will be trimmed down during iterations
12  int iter = 1;             // which iteration we're on  int iter = 1;             // which iteration we're on
13  real stepMax = 2*π/numOfParticles;  // limit on distance to travel per iter  real stepMax = 2*π/numOfParticles;  // limit on distance to travel per iter
14    real stdev = 0;                     // used to test for convergence
15    real convergThershold = rr + 0.32;       // covnergence thershold
16    bool haveConverged = false;
17
18  // ============================ begin setting up gridding of domain  // ============================ begin setting up gridding of domain
19  vec2 xDom = [-1,1];  vec2 xDom = [-1,1];
# Line 27  Line 30
30      real hh = hhInit;      real hh = hhInit;
31      vec2 posOld1 = pos;   // remember last TWO positions      vec2 posOld1 = pos;   // remember last TWO positions
32      vec2 posOld2 = pos;      vec2 posOld2 = pos;
33        int id = ii;
34      output vec2 outPos = pos;      output vec2 outPos = pos;
35      real energy = ii;     // HEY: can do convergence test based on variance of energies      real energy = ii;     // HEY: can do convergence test based on variance of energies
36      vec2 force = [0,0];   // or can test convergence based on sum of |force|      vec2 force = [0,0];   // or can test convergence based on sum of |force|
37      update {      update {
38
39            if(stdev <= convergThershold)  {
40                stabilize;
41            }
42
43          // compute energy and forces on us          // compute energy and forces on us
44          energy = 0;          energy = 0;
45          force = [0,0];          force = [0,0];
# Line 69  Line 77
77                  // slow down if oscillating, speed up a little if not                  // slow down if oscillating, speed up a little if not
78                  hh *= lerp(0.8, 1.01, 0, okay, 1);                  hh *= lerp(0.8, 1.01, 0, okay, 1);
79              }              }
80            }else {  // we do have neighbors so create new neighbors
81                new Particle(-1,pos[0] + d, pos[1] + d);
82          }          }
83
84          outPos = pos;          outPos = pos;
if (iter >= iterMax) {
stabilize;
}

85      }      }
86  }  }
87
88  // can add statements in here to do some global computation  // can add statements in here to do some global computation
89  global{  global{
90    iter+=1;    iter+=1;
91      real var = variance{P.energy | P in Particle.all};
92      stdev = sqrt(var);
93  }  }
94
95  initially {Particle(ii, initPosns{ii*2}, initPosns{ii*2+1})  initially {Particle(ii, initPosns{ii*2}, initPosns{ii*2+1})

Legend:
 Removed from v.2268 changed lines Added in v.2269

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