[cig-commits] r4329 - in long/3D/Gale/trunk/src/StGermain: . Discretisation/Utils/src

walter at geodynamics.org walter at geodynamics.org
Thu Aug 17 17:17:21 PDT 2006


Author: walter
Date: 2006-08-17 17:17:20 -0700 (Thu, 17 Aug 2006)
New Revision: 4329

Modified:
   long/3D/Gale/trunk/src/StGermain/
   long/3D/Gale/trunk/src/StGermain/Discretisation/Utils/src/SobolGenerator.c
   long/3D/Gale/trunk/src/StGermain/Discretisation/Utils/src/SobolGenerator.h
Log:
 r2707 at earth:  boo | 2006-08-17 17:14:20 -0700
  r2661 at earth (orig r3742):  PatrickSunter | 2006-08-02 03:48:21 -0700
  Updated the SobolGenerator to have 100 random generators 
  available, rather than just 20 -
  due to Mirko pointing out that the 20 limit was hit with a 
  model that had a material swarm + several tracer swarms.
  
  Need to think of a better long-term solution - perhaps re-using
  already used sobol generator sets, once the total is reached.
  
 



Property changes on: long/3D/Gale/trunk/src/StGermain
___________________________________________________________________
Name: svk:merge
   - 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:2706
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3741
   + 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:2707
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3742

Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Utils/src/SobolGenerator.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Utils/src/SobolGenerator.c	2006-08-18 00:17:17 UTC (rev 4328)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Utils/src/SobolGenerator.c	2006-08-18 00:17:20 UTC (rev 4329)
@@ -50,7 +50,7 @@
 			Name                                               name,
 			unsigned int                                       polynomialDegree,
 			unsigned int                                       polynomialCoefficient,
-			unsigned int *                                     initialDirectionNumbers )
+			const unsigned int *                               initialDirectionNumbers )
 {
 	SobolGenerator* self = _SobolGenerator_New( 
 			sizeof(SobolGenerator), 
@@ -92,7 +92,7 @@
 		SobolGenerator*                                    self,
 		unsigned int                                       polynomialDegree,
 		unsigned int                                       polynomialCoefficient,
-		unsigned int *                                     initialDirectionNumbers ) 
+		const unsigned int *                               initialDirectionNumbers ) 
 {
 	unsigned int        directionNum_I;
 
@@ -305,62 +305,189 @@
 	return (max - min) * SobolGenerator_GetNumberByIndex( sobolGenerator, index ) + min;
 }
 
+/* Some global variables that drive the random number generator */
 /* These numbers for initialisation come  from:
  * Stephen Joe and Frances Y. Juo. Remark on Algorithm 659: Implementing Sobol¿s Quasirandom Sequence Generator. ACM Transactions on Mathematical Software, 29(1), March 2003.*/
-SobolGenerator* SobolGenerator_NewFromTable( Name name ) {
-	static int        generatorCount                = 0;
-	Index             generatorIndex;
+const unsigned int SobolGenerator_PolynomialDegree[] = {
+	1,2,3,3,4, 4,5,5,5,5,
+	5,5,6,6,6, 6,6,6,7,7,
+	7,7,7,7,7, 7,7,7,7,7,
+	7,7,7,7,7, 7,8,8,8,8,
+	8,8,8,8,8, 8,8,8,8,8,
+	
+	8,8,9,9,9, 9,9,9,9,9,
+	9,9,9,9,9, 9,9,9,9,9,
+	9,9,9,9,9, 9,9,9,9,9,
+	9,9,9,9,9, 9,9,9,9,9,
+	9,9,9,9,9, 9,9,9,9,9
+	};
 
+const unsigned int SobolGenerator_PolynomialCoefficient[] = {
+	0,1,1,2,1, 4,2,13,7,14,
+	11,4,1,16,13, 22,19,25,1,32,
+	4,8,7,56,14, 28,19,50,21,42,
+	31,62,37,41,55, 59,14,56,21,22,
+	38,47,49,50,52, 67,70,84,97,103,
 
+	115,122,8,13,16, 22,25,44,47,52,
+	55,59,62,67,74, 81,82,87,91,94,
+	103,104,109,122,124, 137,138,143,145,152,
+	157,167,173,176,181, 182,185,191,194,199,
+	218,220,227,229,230, 234,236,241,244,253
+	};
 
-	unsigned int      polynomialDegree[]	= { 1,2,3,3,4,4,5,5,5,5,5,5,6,6,6,6,6,6,7,7 };
+const unsigned int SobolGenerator_InitialDirectionNumbers[][13] = {
+	 { 1 },
+	 { 1, 1 },
+	 { 1, 3, 7 },
+	 { 1, 1, 5 },
+	 { 1, 3, 1, 1 },
 
-	unsigned int polynomialCoefficient[]	= { 0,1,1,2,1,4,2,13,7,14,11,4,1,16,13,22,19,25,1,32 };
+	 { 1, 1, 3, 7 },
+	 { 1, 3, 3, 9, 9 },
+	 { 1, 3, 7, 13, 3 },
+	 { 1, 1, 5, 11, 27 },
+	 { 1, 3, 5, 1, 15 },
 
-	unsigned int      initialDirectionNumbers[][13]	 = {
- { 1 },
- { 1, 1 },
- { 1, 3, 7 },
- { 1, 1, 5 },
- { 1, 3, 1, 1 },
- { 1, 1, 3, 7 },
- { 1, 3, 3, 9, 9 },
- { 1, 3, 7, 13, 3 },
- { 1, 1, 5, 11, 27 },
- { 1, 3, 5, 1, 15 },
- { 1, 1, 7, 3, 29 },
- { 1, 3, 7, 7, 21 },
- { 1, 1, 1, 9, 23, 37 },
- { 1, 3, 3, 5, 19, 33 },
- { 1, 1, 3, 13, 11, 7 },
- { 1, 1, 7, 13, 25, 5 },
- { 1, 3, 5, 11, 7, 11 },
- { 1, 1, 1, 3, 13, 39 },
- { 1, 3, 1, 15, 17, 63, 13 },
- { 1, 1, 5, 5, 1, 59, 33 },
- { 1, 3, 3, 3, 25, 17, 115 },
- { 1, 1, 7, 15, 29, 15, 41 },
- { 1, 3, 1, 7, 3, 23, 79 },
- { 1, 3, 7, 9, 31, 29, 17 } };
+	 /*10*/
+	 { 1, 1, 7, 3, 29 },
+	 { 1, 3, 7, 7, 21 },
+	 { 1, 1, 1, 9, 23, 37 },
+	 { 1, 3, 3, 5, 19, 33 },
+	 { 1, 1, 3, 13, 11, 7 },
 
+	 { 1, 1, 7, 13, 25, 5 },
+	 { 1, 3, 5, 11, 7, 11 },
+	 { 1, 1, 1, 3, 13, 39 },
+	 { 1, 3, 1, 15, 17, 63, 13 },
+	 { 1, 1, 5, 5, 1, 59, 33 },
 
+	 /*20*/
+	 { 1, 3, 3, 3, 25, 17, 115 },
+	 { 1, 1, 7, 15, 29, 15, 41 },
+	 { 1, 3, 1, 7, 3, 23, 79 },
+	 { 1, 3, 7, 9, 31, 29, 17 },
+	 { 1, 1, 5, 13, 11, 3, 29 },
+	 
+	 { 1, 1, 1, 9, 5, 21, 119 },
+	 { 1, 1, 3, 1, 23, 13, 75 },
+	 { 1, 3, 7, 11, 27, 31, 73 },
+	 { 1, 1, 7, 7, 19, 25, 105 },
+	 { 1, 3, 1, 5, 21, 9, 7 },
+	 
+	 /*30*/
+	 { 1, 1, 1, 15, 5, 49, 59 },
+	 { 1, 3, 1, 1, 1, 33, 65 },
+	 { 1, 3, 5, 15, 17, 19, 21 },
+	 { 1, 1, 7, 11, 13, 29, 3 },
+	 { 1, 3, 7, 5, 7, 11, 113 },
+	 
+	 { 1, 1, 5, 11, 15, 19, 61 },
+	 { 1, 1, 1, 1, 9, 27, 89, 7 },
+	 { 1, 1, 3, 7, 31, 15, 45, 23 },
+	 { 1, 3, 3, 9, 25, 25, 107, 39 },
+	 { 1, 1, 7, 7, 3, 63, 21, 217 },
+	 
+	 /*40*/
+	 { 1, 3, 5, 7, 5, 55, 71, 141 },
+	 { 1, 1, 5, 1, 23, 17, 79, 27 },
+	 { 1, 1, 5, 15, 7, 63, 19, 53 },
+	 { 1, 1, 3, 15, 3, 49, 71, 181 },
+	 { 1, 3, 3, 15, 17, 19, 61, 169 },
+	 
+	 { 1, 3, 3, 13, 23, 41, 41, 35 },
+	 { 1, 1, 1, 3, 3, 59, 57, 15 },
+	 { 1, 3, 1, 3, 3, 3, 121, 207 },
+	 { 1, 3, 5, 15, 21, 57, 87, 45 },
+	 { 1, 1, 1, 5, 25, 33, 119, 247 },
+	 
+	 /*50*/
+	 { 1, 1, 1, 9, 25, 49, 55, 185 },
+	 { 1, 3, 5, 7, 23, 53, 85, 117 },
+	 { 1, 3, 3, 13, 11, 57, 121, 41, 235 },
+	 { 1, 1, 3, 3, 19, 57, 119, 81, 307 },
+	 { 1, 3, 3, 7, 3, 39, 11, 223, 495 },
+	 
+	 { 1, 3, 3, 5, 11, 21, 23, 151, 417 },
+	 { 1, 3, 1, 11, 31, 7, 61, 81, 57 },
+	 { 1, 1, 3, 9, 7, 53, 11, 189, 151 },
+	 { 1, 3, 7, 1, 9, 9, 35, 61, 19 },
+	 { 1, 1, 5, 9, 5, 55, 33, 95, 119 },
+	 
+	 /*60*/
+	 { 1, 3, 7, 1, 17, 15, 43, 185, 375 },
+	 { 1, 1, 3, 5, 23, 59, 107, 23, 451 },
+	 { 1, 1, 7, 7, 17, 19, 113, 73, 55 },
+	 { 1, 3, 1, 13, 17, 49, 101, 113, 449 },
+	 { 1, 3, 3, 9, 25, 31, 29, 239, 501 },
+	 
+	 { 1, 1, 3, 9, 13, 3, 87, 85, 53 },
+	 { 1, 1, 5, 1, 11, 39, 119, 9, 185 },
+	 { 1, 1, 1, 7, 31, 5, 97, 201, 317 },
+	 { 1, 1, 3, 3, 27, 5, 29, 83, 17 },
+	 { 1, 3, 5, 5, 19, 41, 17, 53, 21 },
+	 
+	 /*70*/
+	 { 1, 1, 5, 1, 17, 9, 89, 183, 487 },
+	 { 1, 1, 7, 11, 23, 19, 5, 203, 13 },
+	 { 1, 3, 7, 11, 7, 9, 127, 91, 347 },
+	 { 1, 1, 7, 13, 5, 57, 89, 149, 393 },
+	 { 1, 1, 1, 7, 11, 25, 119, 101, 15 },
+	 
+	 { 1, 1, 1, 7, 19, 1, 117, 13, 391 },
+	 { 1, 3, 3, 9, 19, 15, 103, 111, 307 },
+	 { 1, 3, 3, 9, 7, 51, 105, 239, 189 },
+	 { 1, 1, 1, 1, 13, 11, 41, 3, 381 },
+	 { 1, 3, 1, 1, 21, 19, 83, 205, 71 },
+	 
+	 /*80*/
+	 { 1, 3, 5, 3, 21, 61, 25, 253, 163 },
+	 { 1, 1, 1, 9, 7, 53, 41, 247, 99 },
+	 { 1, 3, 5, 15, 9, 29, 55, 121, 467 },
+	 { 1, 3, 7, 1, 11, 19, 69, 189, 167 },
+	 { 1, 3, 5, 5, 1, 11, 117, 169, 433 },
+	 
+	 { 1, 1, 1, 13, 5, 9, 49, 179, 337 },
+	 { 1, 3, 7, 1, 21, 21, 127, 197, 257 },
+	 { 1, 3, 5, 9, 11, 19, 29, 175, 179 },
+	 { 1, 3, 3, 9, 13, 43, 1, 217, 47 },
+	 { 1, 1, 3, 9, 25, 13, 99, 249, 385 },
+	 
+	 /*90*/
+	 { 1, 3, 1, 9, 9, 13, 53, 195, 23 },
+	 { 1, 3, 5, 9, 7, 41, 83, 95, 117 },
+	 { 1, 1, 7, 13, 7, 25, 15, 63, 369 },
+	 { 1, 3, 1, 11, 27, 31, 31, 19, 425 },
+	 { 1, 3, 7, 3, 15, 9, 73, 7, 207 },
+	 
+	 { 1, 3, 5, 5, 25, 11, 115, 5, 433 },
+	 { 1, 1, 1, 11, 15, 19, 35, 75, 301 },
+	 { 1, 3, 7, 11, 21, 5, 21, 217, 147 },
+	 { 1, 1, 3, 13, 17, 53, 89, 245, 333 },
+	 { 1, 3, 1, 5, 19, 37, 5, 111, 85 }
+	 };
 
+
+SobolGenerator* SobolGenerator_NewFromTable( Name name ) {
+	static int        generatorCount                = 0;
+	Index             generatorIndex;
+
 	generatorIndex = generatorCount;
 	generatorCount++;
 
 	/* Make sure that the number generators used from this function is smaller than the number in the table */
 	Journal_Firewall(
-		generatorCount <= sizeof(polynomialDegree)/sizeof(unsigned int),
+		generatorCount <= sizeof(SobolGenerator_PolynomialDegree)/sizeof(unsigned int),
 		Journal_Register( Error_Type, SobolGenerator_Type ),
 		"Error in func '%s' - Trying to instantiate a %dth SobolGenerator ('%s') using table, "
 		"but only %d initial directional numbers have been implemented. Please contact developers.\n",
-		__func__, generatorIndex + 1, name, sizeof(polynomialDegree)/sizeof(unsigned int) );
+		__func__, generatorIndex + 1, name, sizeof(SobolGenerator_PolynomialDegree)/sizeof(unsigned int) );
 		
 	return SobolGenerator_New( 
 			name,
-			polynomialDegree[ generatorIndex ], 
-			polynomialCoefficient[ generatorIndex ],
-			initialDirectionNumbers[ generatorIndex ] );
+			SobolGenerator_PolynomialDegree[ generatorIndex ], 
+			SobolGenerator_PolynomialCoefficient[ generatorIndex ],
+			SobolGenerator_InitialDirectionNumbers[ generatorIndex ] );
 
 }
 

Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Utils/src/SobolGenerator.h
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Utils/src/SobolGenerator.h	2006-08-18 00:17:17 UTC (rev 4328)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Utils/src/SobolGenerator.h	2006-08-18 00:17:20 UTC (rev 4329)
@@ -68,7 +68,7 @@
 			Name                                               name,
 			unsigned int                                       polynomialDegree,
 			unsigned int                                       polynomialCoefficient,
-			unsigned int *                                     initialDirectionNumbers );
+			const unsigned int *                               initialDirectionNumbers );
 
 	/** Private Constructor */
 	SobolGenerator* _SobolGenerator_New(
@@ -83,7 +83,7 @@
 		SobolGenerator*                                    self,
 		unsigned int                                       polynomialDegree,
 		unsigned int                                       polynomialCoefficient,
-		unsigned int *                                     initialDirectionNumbers )	;		
+		const unsigned int *                               initialDirectionNumbers )	;		
 
 	/** Stg_Class Virtual Functions */
 	void _SobolGenerator_Delete( void* sobolGenerator ) ;



More information about the cig-commits mailing list