comparison EquidistantGrid.jl @ 63:a94ebe67e848 cell_based_test

Make grid.spacings more readable
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 17 Jan 2019 13:53:01 +0100
parents 8c6db1f6d8e0
children a88222fc01de
comparison
equal deleted inserted replaced
57:178a203f3e6d 63:a94ebe67e848
51 # between two points for each coordinate direction. 51 # between two points for each coordinate direction.
52 # 52 #
53 # @Input: grid - an EquidistantGrid 53 # @Input: grid - an EquidistantGrid
54 # @Return: h̄ - Grid spacing for each coordinate direction stored in a tuple. 54 # @Return: h̄ - Grid spacing for each coordinate direction stored in a tuple.
55 function spacings(grid::EquidistantGrid) 55 function spacings(grid::EquidistantGrid)
56 h̄ = Vector{Real}(undef, numberOfDimensions(grid)) 56 a = grid.limits[1]
57 for i ∈ eachindex(h̄) 57 b = grid.limits[2]
58 h̄[i] = abs(grid.limits[2][i]-grid.limits[1][i])/(grid.numberOfPointsPerDim[i]-1) 58
59 end 59 return abs.(b.-a)./(grid.numberOfPointsPerDim.-1)
60 return Tuple(h̄)
61 end 60 end
62 61
63 # Computes the points of an EquidistantGrid as a vector of tuples. The vector is ordered 62 # Computes the points of an EquidistantGrid as a vector of tuples. The vector is ordered
64 # such that points in the first coordinate direction varies first, then the second 63 # such that points in the first coordinate direction varies first, then the second
65 # and lastely the third (if applicable) 64 # and lastely the third (if applicable)