-empty_grid = Grid 1 empty3d
-
-
--- | Returns a three-dimensional list of cubes centered on the grid
--- points of g with the appropriate 'FunctionValues'.
-cubes :: Grid -> [[[Cube]]]
-cubes g
- | xsize == 0 || ysize == 0 || zsize == 0 = [[[]]]
- | otherwise =
- [[[ Cube (h g) i j k (make_values fvs i j k) | i <- [0..xsize]]
- | j <- [0..ysize]]
- | k <- [0..zsize]]
- where
- fvs = function_values g
- (xsize, ysize, zsize) = dims fvs
+empty_grid = make_grid 1 empty3d
+
+
+-- | Returns a three-dimensional array of cubes centered on the grid
+-- points (h*i, h*j, h*k) with the appropriate 'FunctionValues'.
+cubes :: Double -> Values3D -> CubeGrid
+cubes delta fvs
+ = array (lbounds, ubounds)
+ [ ((i,j,k), cube_ijk)
+ | i <- [0..xmax],
+ j <- [0..ymax],
+ k <- [0..zmax],
+ let tet_vol = (1/24)*(delta^(3::Int)),
+ let cube_ijk =
+ Cube delta i j k (make_values fvs i j k) tet_vol]
+ where
+ xmax = xsize - 1
+ ymax = ysize - 1
+ zmax = zsize - 1
+ lbounds = (0, 0, 0)
+ ubounds = (xmax, ymax, zmax)
+ (xsize, ysize, zsize) = dims fvs