comparison 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
comparison
equal deleted inserted replaced
685:bc2a9b8d2774 686:27dcac8fb350
1 """ 1 """
2 EquidistantGrid(size::NTuple{Dim, Int}, limit_lower::NTuple{Dim, T}, limit_upper::NTuple{Dim, T} 2 EquidistantGrid(size::NTuple{Dim, Int}, limit_lower::NTuple{Dim, T}, limit_upper::NTuple{Dim, T})
3 EquidistantGrid{T}()
3 4
4 EquidistantGrid is a grid with equidistant grid spacing per coordinat direction. 5 `EquidistantGrid` is a grid with equidistant grid spacing per coordinat direction.
5 The domain is defined through the two points P1 = x̄₁, P2 = x̄₂ by the exterior 6
6 product of the vectors obtained by projecting (x̄₂-x̄₁) onto the coordinate 7 `EquidistantGrid(size, limit_lower, limit_upper)` construct the grid with the
7 directions. E.g for a 2D grid with x̄₁=(-1,0) and x̄₂=(1,2) the domain is defined 8 domain defined by the two points P1, and P2 given by `limit_lower` and
8 as (-1,1)x(0,2). The side lengths of the grid are not allowed to be negative 9 `limit_upper`. The length of the domain sides are given by the components of
10 (P2-P1). E.g for a 2D grid with P1=(-1,0) and P2=(1,2) the domain is defined
11 as (-1,1)x(0,2). The side lengths of the grid are not allowed to be negative.
12 The number of equidistantly spaced points in each coordinate direction are given
13 by `size`.
14
15 `EquidistantGrid{T}()` constructs a 0-dimensional grid.
16
9 """ 17 """
10 struct EquidistantGrid{Dim,T<:Real} <: AbstractGrid 18 struct EquidistantGrid{Dim,T<:Real} <: AbstractGrid
11 size::NTuple{Dim, Int} 19 size::NTuple{Dim, Int}
12 limit_lower::NTuple{Dim, T} 20 limit_lower::NTuple{Dim, T}
13 limit_upper::NTuple{Dim, T} 21 limit_upper::NTuple{Dim, T}
21 throw(DomainError("all side lengths must be postive")) 29 throw(DomainError("all side lengths must be postive"))
22 end 30 end
23 return new{Dim,T}(size, limit_lower, limit_upper) 31 return new{Dim,T}(size, limit_lower, limit_upper)
24 end 32 end
25 33
26 # Special constructor for 0-dimensional grids. 34 # Specialized constructor for 0-dimensional grid
27 function EquidistantGrid(size::Tuple{}, limit_lower::Tuple{}, limit_upper::Tuple{}) 35 EquidistantGrid{T}() where T = new{0,T}((),(),())
28 #TODO: Need to specialize T.
29 # Is Float64 a good choice here? How to propage from arguments?
30 return new{0,Float64}(size, limit_lower, limit_upper)
31 end
32 end 36 end
33 export EquidistantGrid 37 export EquidistantGrid
34 38
35 39
36 """ 40 """
128 throw(DomainError("boundary identifier not matching grid")) 132 throw(DomainError("boundary identifier not matching grid"))
129 end 133 end
130 return restrict(grid,orth_dims) 134 return restrict(grid,orth_dims)
131 end 135 end
132 export boundary_grid 136 export boundary_grid
133 boundary_grid(::EquidistantGrid{1},::CartesianBoundary{1}) = EquidistantGrid((),(),()) 137 boundary_grid(::EquidistantGrid{1,T},::CartesianBoundary{1}) where T = EquidistantGrid{T}()