Mercurial > repos > public > sbplib_julia
diff Grids/src/EquidistantGrid.jl @ 268:f67ce2eb6019 boundary_conditions
Remove property spacing in EquidistantGrid, due to redundancy.
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 05 Dec 2019 09:44:34 +0100 |
parents | 01017d2b46b0 |
children | 12b738f260a0 |
line wrap: on
line diff
--- a/Grids/src/EquidistantGrid.jl Thu Dec 05 09:28:04 2019 +0100 +++ b/Grids/src/EquidistantGrid.jl Thu Dec 05 09:44:34 2019 +0100 @@ -10,16 +10,14 @@ size::NTuple{Dim, Int} # First coordinate direction stored first limit_lower::NTuple{Dim, T} limit_upper::NTuple{Dim, T} - spacing::NTuple{Dim, T} # Grid spacing inverse_spacing::NTuple{Dim, T} # Reciprocal of grid spacing # General constructor function EquidistantGrid(size::NTuple{Dim, Int}, limit_lower::NTuple{Dim, T}, limit_upper::NTuple{Dim, T}) where Dim where T @assert all(size.>0) @assert all(limit_upper.-limit_lower .!= 0) - spacing = abs.(limit_upper.-limit_lower)./(size.-1) - inverse_spacing = 1.0./spacing - return new{Dim,T}(size, limit_lower, limit_upper, spacing, inverse_spacing) + inverse_spacing = (size.-1)./ abs.(limit_upper.-limit_lower) + return new{Dim,T}(size, limit_lower, limit_upper, inverse_spacing) end end @@ -37,7 +35,6 @@ return length(grid.size) end -# TODO: Keep the below functions or just use properties? # Returns the reciprocal of the spacing of the grid # function inverse_spacing(grid::EquidistantGrid) @@ -48,7 +45,7 @@ # Returns the reciprocal of the spacing of the grid # function spacing(grid::EquidistantGrid) - return grid.spacing + return 1.0./grid.inverse_spacing end export spacing