Mercurial > repos > public > sbplib_julia
diff src/Grids/EquidistantGrid.jl @ 686:27dcac8fb350 feature/boundary_quads
Fix type parameter for a 0-dimensional grid and update docs
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Tue, 09 Feb 2021 13:44:00 +0100 |
parents | 984f6fe42708 |
children | e9e46a587370 |
line wrap: on
line diff
--- a/src/Grids/EquidistantGrid.jl Tue Feb 09 09:44:32 2021 +0100 +++ b/src/Grids/EquidistantGrid.jl Tue Feb 09 13:44:00 2021 +0100 @@ -1,11 +1,19 @@ """ - EquidistantGrid(size::NTuple{Dim, Int}, limit_lower::NTuple{Dim, T}, limit_upper::NTuple{Dim, T} + EquidistantGrid(size::NTuple{Dim, Int}, limit_lower::NTuple{Dim, T}, limit_upper::NTuple{Dim, T}) + EquidistantGrid{T}() + +`EquidistantGrid` is a grid with equidistant grid spacing per coordinat direction. -EquidistantGrid is a grid with equidistant grid spacing per coordinat direction. -The domain is defined through the two points P1 = x̄₁, P2 = x̄₂ by the exterior -product of the vectors obtained by projecting (x̄₂-x̄₁) onto the coordinate -directions. E.g for a 2D grid with x̄₁=(-1,0) and x̄₂=(1,2) the domain is defined -as (-1,1)x(0,2). The side lengths of the grid are not allowed to be negative +`EquidistantGrid(size, limit_lower, limit_upper)` construct the grid with the +domain defined by the two points P1, and P2 given by `limit_lower` and +`limit_upper`. The length of the domain sides are given by the components of +(P2-P1). E.g for a 2D grid with P1=(-1,0) and P2=(1,2) the domain is defined +as (-1,1)x(0,2). The side lengths of the grid are not allowed to be negative. +The number of equidistantly spaced points in each coordinate direction are given +by `size`. + +`EquidistantGrid{T}()` constructs a 0-dimensional grid. + """ struct EquidistantGrid{Dim,T<:Real} <: AbstractGrid size::NTuple{Dim, Int} @@ -23,12 +31,8 @@ return new{Dim,T}(size, limit_lower, limit_upper) end - # Special constructor for 0-dimensional grids. - function EquidistantGrid(size::Tuple{}, limit_lower::Tuple{}, limit_upper::Tuple{}) - #TODO: Need to specialize T. - # Is Float64 a good choice here? How to propage from arguments? - return new{0,Float64}(size, limit_lower, limit_upper) - end + # Specialized constructor for 0-dimensional grid + EquidistantGrid{T}() where T = new{0,T}((),(),()) end export EquidistantGrid @@ -130,4 +134,4 @@ return restrict(grid,orth_dims) end export boundary_grid -boundary_grid(::EquidistantGrid{1},::CartesianBoundary{1}) = EquidistantGrid((),(),()) +boundary_grid(::EquidistantGrid{1,T},::CartesianBoundary{1}) where T = EquidistantGrid{T}()