comparison EquidistantGrid.jl @ 130:155bbecf18bb cell_based_test

Fix bug in points(::EquidistantGrid)
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Thu, 21 Feb 2019 11:40:48 +0100
parents 1aaeb46ba5f4
children 99308f68e548
comparison
equal deleted inserted replaced
129:1aaeb46ba5f4 130:155bbecf18bb
35 # 35 #
36 function spacing(grid::EquidistantGrid) 36 function spacing(grid::EquidistantGrid)
37 return 1.0./grid.inverse_spacing 37 return 1.0./grid.inverse_spacing
38 end 38 end
39 39
40 # Computes the points of an EquidistantGrid as a vector of tuples. The vector is ordered 40 # Computes the points of an EquidistantGrid as an array of tuples with
41 # such that points in the first coordinate direction varies first, then the second 41 # the same dimension as the grid.
42 # and lastely the third (if applicable)
43 # 42 #
44 # @Input: grid - an EquidistantGrid 43 # @Input: grid - an EquidistantGrid
45 # @Return: points - the points of the grid. 44 # @Return: points - the points of the grid.
46 function points(grid::EquidistantGrid) 45 function points(grid::EquidistantGrid)
47 # TODO: Make this return an abstract array? 46 # TODO: Make this return an abstract array?
48 physical_domain_size = (grid.limit_upper .- grid.limit_lower)
49 indices = Tuple.(CartesianIndices(grid.size)) 47 indices = Tuple.(CartesianIndices(grid.size))
50 return broadcast(I -> grid.limit_lower .+ physical_domain_size.*(I.-1), indices) 48 h = spacing(grid)
49 return broadcast(I -> grid.limit_lower .+ (I.-1).*h, indices)
51 end 50 end
52 51
53 function pointsalongdim(grid::EquidistantGrid, dim::Integer) 52 function pointsalongdim(grid::EquidistantGrid, dim::Integer)
54 @assert dim<=dimension(grid) 53 @assert dim<=dimension(grid)
55 @assert dim>0 54 @assert dim>0