[cig-commits] r7974 - mc/3D/CitcomS/trunk/lib
tan2 at geodynamics.org
tan2 at geodynamics.org
Fri Sep 14 17:17:25 PDT 2007
Author: tan2
Date: 2007-09-14 17:17:24 -0700 (Fri, 14 Sep 2007)
New Revision: 7974
Modified:
mc/3D/CitcomS/trunk/lib/Tracer_setup.c
Log:
Revert accidental commit in part of r7957
Modified: mc/3D/CitcomS/trunk/lib/Tracer_setup.c
===================================================================
--- mc/3D/CitcomS/trunk/lib/Tracer_setup.c 2007-09-14 23:39:59 UTC (rev 7973)
+++ mc/3D/CitcomS/trunk/lib/Tracer_setup.c 2007-09-15 00:17:24 UTC (rev 7974)
@@ -742,7 +742,6 @@
double theta,phi,rad;
double xmin,xmax,ymin,ymax,zmin,zmax;
double random1,random2,random3;
- double u, v, s, r;
allocate_tracer_arrays(E,j,tracers_cap);
@@ -770,25 +769,30 @@
while (E->trace.ntracers[j]<tracers_cap) {
- do {
- /* pick two uniformly distributed random numbers in [-1;1] */
- u = -1 + drand48()*2;
- v = -1 + drand48()*2;
- s = u*u + v*v;
- /* length has to be <= 1 */
- } while(s > 1);
- r = 2.0 * sqrt(1.0-s);
+ number_of_tries++;
+ max_tries=100*tracers_cap;
- /* cartesian coordinates */
- x = u * r;
- y = v * r;
- z = 2.0*s -1 ;
+ if (number_of_tries>max_tries) {
+ fprintf(E->trace.fpt,"Error(make_tracer_array)-too many tries?\n");
+ fprintf(E->trace.fpt,"%d %d %d\n",max_tries,number_of_tries,RAND_MAX);
+ fflush(E->trace.fpt);
+ exit(10);
+ }
- /* skip if outside the bounding box */
- if ((x < xmin) || (x > xmax)) continue;
- if ((y < ymin) || (y > ymax)) continue;
- if ((z < zmin) || (z > zmax)) continue;
+#if 1
+ random1=drand48();
+ random2=drand48();
+ random3=drand48();
+#else
+ random1=(1.0*rand())/(1.0*RAND_MAX);
+ random2=(1.0*rand())/(1.0*RAND_MAX);
+ random3=(1.0*rand())/(1.0*RAND_MAX);
+#endif
+ x=xmin+random1*(xmax-xmin);
+ y=ymin+random2*(ymax-ymin);
+ z=zmin+random3*(zmax-zmin);
+
/* first check if within shell */
cart_to_sphere(E,x,y,z,&theta,&phi,&rad);
More information about the cig-commits
mailing list