12 January 2010 11:14:43 PM SPARSE_GRID_CLOSED_PRB C++ version Test the routines in the SPARSE_GRID_CLOSED library. TEST01 SPARSE_GRID_CFN_SIZE returns the number of distinct points in a sparse grid of Closed Fully Nested rules. Each sparse grid is of spatial dimension DIM, and is made up of all product grids of levels up to LEVEL_MAX. DIM: 1 2 3 4 5 LEVEL_MAX 0 1 1 1 1 1 1 3 5 7 9 11 2 5 13 25 41 61 3 9 29 69 137 241 4 17 65 177 401 801 5 33 145 441 1105 2433 6 65 321 1073 2929 6993 7 129 705 2561 7537 19313 8 257 1537 6017 18945 51713 9 513 3329 13953 46721 135073 10 1025 7169 32001 113409 345665 TEST01 SPARSE_GRID_CFN_SIZE returns the number of distinct points in a sparse grid of Closed Fully Nested rules. Each sparse grid is of spatial dimension DIM, and is made up of all product grids of levels up to LEVEL_MAX. DIM: 6 7 8 9 10 LEVEL_MAX 0 1 1 1 1 1 1 13 15 17 19 21 2 85 113 145 181 221 3 389 589 849 1177 1581 4 1457 2465 3937 6001 8801 5 4865 9017 15713 26017 41265 6 15121 30241 56737 100897 171425 7 44689 95441 190881 361249 652065 8 127105 287745 609025 1218049 2320385 9 350657 836769 1863937 3918273 7836545 10 943553 2362881 5515265 12133761 25370753 TEST02: LEVELS_MAX_INDEX returns all grid indexes whose level value satisfies 0 <= LEVEL <= LEVEL_MAX. Here, LEVEL is the sum of the levels of the 1D rules, and the order of the rule is 2**LEVEL + 1. LEVEL_MAX = 3 Spatial dimension DIM_NUM = 2 Number of unique points in the grid = 29 Grid index: 0 4 4 1 0 4 2 8 4 3 4 0 4 4 8 5 2 4 6 6 4 7 0 0 8 8 0 9 0 8 10 8 8 11 4 2 12 4 6 13 1 4 14 3 4 15 5 4 16 7 4 17 2 0 18 6 0 19 2 8 20 6 8 21 0 2 22 8 2 23 0 6 24 8 6 25 4 1 26 4 3 27 4 5 28 4 7 TEST02: LEVELS_MAX_INDEX returns all grid indexes whose level value satisfies 0 <= LEVEL <= LEVEL_MAX. Here, LEVEL is the sum of the levels of the 1D rules, and the order of the rule is 2**LEVEL + 1. LEVEL_MAX = 4 Spatial dimension DIM_NUM = 2 Number of unique points in the grid = 65 Grid index: 0 8 8 1 0 8 2 16 8 3 8 0 4 8 16 5 4 8 6 12 8 7 0 0 8 16 0 9 0 16 10 16 16 11 8 4 12 8 12 13 2 8 14 6 8 15 10 8 16 14 8 17 4 0 18 12 0 19 4 16 20 12 16 21 0 4 22 16 4 23 0 12 24 16 12 25 8 2 26 8 6 27 8 10 28 8 14 29 1 8 30 3 8 31 5 8 32 7 8 33 9 8 34 11 8 35 13 8 36 15 8 37 2 0 38 6 0 39 10 0 40 14 0 41 2 16 42 6 16 43 10 16 44 14 16 45 4 4 46 12 4 47 4 12 48 12 12 49 0 2 50 16 2 51 0 6 52 16 6 53 0 10 54 16 10 55 0 14 56 16 14 57 8 1 58 8 3 59 8 5 60 8 7 61 8 9 62 8 11 63 8 13 64 8 15 TEST02: LEVELS_MAX_INDEX returns all grid indexes whose level value satisfies 0 <= LEVEL <= LEVEL_MAX. Here, LEVEL is the sum of the levels of the 1D rules, and the order of the rule is 2**LEVEL + 1. LEVEL_MAX = 2 Spatial dimension DIM_NUM = 3 Number of unique points in the grid = 25 Grid index: 0 2 2 2 1 0 2 2 2 4 2 2 3 2 0 2 4 2 4 2 5 2 2 0 6 2 2 4 7 1 2 2 8 3 2 2 9 0 0 2 10 4 0 2 11 0 4 2 12 4 4 2 13 2 1 2 14 2 3 2 15 0 2 0 16 4 2 0 17 0 2 4 18 4 2 4 19 2 0 0 20 2 4 0 21 2 0 4 22 2 4 4 23 2 2 1 24 2 2 3 TEST02: LEVELS_MAX_INDEX returns all grid indexes whose level value satisfies 0 <= LEVEL <= LEVEL_MAX. Here, LEVEL is the sum of the levels of the 1D rules, and the order of the rule is 2**LEVEL + 1. LEVEL_MAX = 2 Spatial dimension DIM_NUM = 6 Number of unique points in the grid = 85 Grid index: 0 2 2 2 2 2 2 1 0 2 2 2 2 2 2 4 2 2 2 2 2 3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 2 2 4 2 0 77 2 2 2 0 2 4 78 2 2 2 4 2 4 79 2 2 2 2 0 0 80 2 2 2 2 4 0 81 2 2 2 2 0 4 82 2 2 2 2 4 4 83 2 2 2 2 2 1 84 2 2 2 2 2 3 TEST03: Make a sparse Clenshaw Curtis grid. LEVELS_CLOSED_INDEX returns all grid indexes whose level value satisfies 0 <= LEVEL <= LEVEL_MAX. Here, LEVEL is the sum of the levels of the 1D rules, and the order of the rule is 2^LEVEL + 1. Now we demonstrate how to convert grid indices into physical grid points. In this case, we want points on [-1,+1]^DIM_NUM. LEVEL_MAX = 3 Spatial dimension DIM_NUM = 2 Number of unique points in the grid = 29 Grid index: 0 4 4 1 0 4 2 8 4 3 4 0 4 4 8 5 2 4 6 6 4 7 0 0 8 8 0 9 0 8 10 8 8 11 4 2 12 4 6 13 1 4 14 3 4 15 5 4 16 7 4 17 2 0 18 6 0 19 2 8 20 6 8 21 0 2 22 8 2 23 0 6 24 8 6 25 4 1 26 4 3 27 4 5 28 4 7 Grid points: 0 0.000000 0.000000 1 -1.000000 0.000000 2 1.000000 0.000000 3 0.000000 -1.000000 4 0.000000 1.000000 5 -0.707107 0.000000 6 0.707107 0.000000 7 -1.000000 -1.000000 8 1.000000 -1.000000 9 -1.000000 1.000000 10 1.000000 1.000000 11 0.000000 -0.707107 12 0.000000 0.707107 13 -0.923880 0.000000 14 -0.382683 0.000000 15 0.382683 0.000000 16 0.923880 0.000000 17 -0.707107 -1.000000 18 0.707107 -1.000000 19 -0.707107 1.000000 20 0.707107 1.000000 21 -1.000000 -0.707107 22 1.000000 -0.707107 23 -1.000000 0.707107 24 1.000000 0.707107 25 0.000000 -0.923880 26 0.000000 -0.382683 27 0.000000 0.382683 28 0.000000 0.923880 TEST04: Make a sparse Newton Cotes Closed grid. LEVELS_CLOSED_INDEX returns all grid indexes whose level value satisfies 0 <= LEVEL <= LEVEL_MAX. Here, LEVEL is the sum of the levels of the 1D rules, and the order of the rule is 2^LEVEL + 1. Now we demonstrate how to convert grid indices into physical grid points. In this case, we want points on [0,+1]^DIM_NUM. LEVEL_MAX = 4 Spatial dimension DIM_NUM = 2 Number of unique points in the grid = 65 Grid index: 0 8 8 1 0 8 2 16 8 3 8 0 4 8 16 5 4 8 6 12 8 7 0 0 8 16 0 9 0 16 10 16 16 11 8 4 12 8 12 13 2 8 14 6 8 15 10 8 16 14 8 17 4 0 18 12 0 19 4 16 20 12 16 21 0 4 22 16 4 23 0 12 24 16 12 25 8 2 26 8 6 27 8 10 28 8 14 29 1 8 30 3 8 31 5 8 32 7 8 33 9 8 34 11 8 35 13 8 36 15 8 37 2 0 38 6 0 39 10 0 40 14 0 41 2 16 42 6 16 43 10 16 44 14 16 45 4 4 46 12 4 47 4 12 48 12 12 49 0 2 50 16 2 51 0 6 52 16 6 53 0 10 54 16 10 55 0 14 56 16 14 57 8 1 58 8 3 59 8 5 60 8 7 61 8 9 62 8 11 63 8 13 64 8 15 Grid points: 0 0.000000 0.000000 1 -1.000000 0.000000 2 1.000000 0.000000 3 0.000000 -1.000000 4 0.000000 1.000000 5 -0.500000 0.000000 6 0.500000 0.000000 7 -1.000000 -1.000000 8 1.000000 -1.000000 9 -1.000000 1.000000 10 1.000000 1.000000 11 0.000000 -0.500000 12 0.000000 0.500000 13 -0.750000 0.000000 14 -0.250000 0.000000 15 0.250000 0.000000 16 0.750000 0.000000 17 -0.500000 -1.000000 18 0.500000 -1.000000 19 -0.500000 1.000000 20 0.500000 1.000000 21 -1.000000 -0.500000 22 1.000000 -0.500000 23 -1.000000 0.500000 24 1.000000 0.500000 25 0.000000 -0.750000 26 0.000000 -0.250000 27 0.000000 0.250000 28 0.000000 0.750000 29 -0.875000 0.000000 30 -0.625000 0.000000 31 -0.375000 0.000000 32 -0.125000 0.000000 33 0.125000 0.000000 34 0.375000 0.000000 35 0.625000 0.000000 36 0.875000 0.000000 37 -0.750000 -1.000000 38 -0.250000 -1.000000 39 0.250000 -1.000000 40 0.750000 -1.000000 41 -0.750000 1.000000 42 -0.250000 1.000000 43 0.250000 1.000000 44 0.750000 1.000000 45 -0.500000 -0.500000 46 0.500000 -0.500000 47 -0.500000 0.500000 48 0.500000 0.500000 49 -1.000000 -0.750000 50 1.000000 -0.750000 51 -1.000000 -0.250000 52 1.000000 -0.250000 53 -1.000000 0.250000 54 1.000000 0.250000 55 -1.000000 0.750000 56 1.000000 0.750000 57 0.000000 -0.875000 58 0.000000 -0.625000 59 0.000000 -0.375000 60 0.000000 -0.125000 61 0.000000 0.125000 62 0.000000 0.375000 63 0.000000 0.625000 64 0.000000 0.875000 TEST05: Make sparse grids and write to files. LEVEL_MAX = 3 Spatial dimension DIM_NUM = 2 Number of unique points in the grid = 29 Grid index: 0 4 4 1 0 4 2 8 4 3 4 0 4 4 8 5 2 4 6 6 4 7 0 0 8 8 0 9 0 8 10 8 8 11 4 2 12 4 6 13 1 4 14 3 4 15 5 4 16 7 4 17 2 0 18 6 0 19 2 8 20 6 8 21 0 2 22 8 2 23 0 6 24 8 6 25 4 1 26 4 3 27 4 5 28 4 7 Wrote file "cc_d2_level3.txt". Wrote file "ncc_d2_level3.txt". SPARSE_GRID_CLOSED_PRB Normal end of execution. 12 January 2010 11:14:43 PM