Mercurial > repos > public > sbplib_julia
comparison src/Grids/EquidistantGrid.jl @ 680:1d3e29ffc6c6 feature/boundary_quads
Add support for 0-dimensional grid, and add method boundary_grid
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Mon, 08 Feb 2021 18:43:38 +0100 |
parents | f0ceddeae993 |
children | 3ed922e95a35 |
comparison
equal
deleted
inserted
replaced
675:1ce3a104afc8 | 680:1d3e29ffc6c6 |
---|---|
19 end | 19 end |
20 if any(limit_upper.-limit_lower .<= 0) | 20 if any(limit_upper.-limit_lower .<= 0) |
21 throw(DomainError("all side lengths must be postive")) | 21 throw(DomainError("all side lengths must be postive")) |
22 end | 22 end |
23 return new{Dim,T}(size, limit_lower, limit_upper) | 23 return new{Dim,T}(size, limit_lower, limit_upper) |
24 end | |
25 | |
26 # Special constructor for 0-dimensional grids. | |
27 function EquidistantGrid(size::Tuple{}, limit_lower::Tuple{}, limit_upper::Tuple{}) | |
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) | |
24 end | 31 end |
25 end | 32 end |
26 export EquidistantGrid | 33 export EquidistantGrid |
27 | 34 |
28 | 35 |
102 CartesianBoundary(2,Lower), | 109 CartesianBoundary(2,Lower), |
103 ...) | 110 ...) |
104 """ | 111 """ |
105 boundary_identifiers(g::EquidistantGrid) = (((ntuple(i->(CartesianBoundary{i,Lower}(),CartesianBoundary{i,Upper}()),dimension(g)))...)...,) | 112 boundary_identifiers(g::EquidistantGrid) = (((ntuple(i->(CartesianBoundary{i,Lower}(),CartesianBoundary{i,Upper}()),dimension(g)))...)...,) |
106 export boundary_identifiers | 113 export boundary_identifiers |
114 | |
115 | |
116 """ | |
117 boundary_grid(grid::EquidistantGrid,id::CartesianBoundary) | |
118 boundary_grid(::EquidistantGrid{1},::CartesianBoundary{1}) | |
119 | |
120 Creates the lower-dimensional restriciton of `grid` spanned by the dimensions | |
121 orthogonal to the boundary specified by `id`. The boundary grid of a 1-dimensional | |
122 grid is a zero-dimensional grid. | |
123 """ | |
124 function boundary_grid(grid::EquidistantGrid,id::CartesianBoundary) | |
125 dims = collect(1:dimension(grid)) | |
126 orth_dims = dims[dims .!= dim(id)] | |
127 return restrict(grid,orth_dims) | |
128 end | |
129 export boundary_grid | |
130 boundary_grid(::EquidistantGrid{1},::CartesianBoundary{1}) = EquidistantGrid((),(),()) | |
131 boundary_grid(::EquidistantGrid{1},::CartesianBoundary) = throw(DimensionMismatch("dimension of Grid and BoundaryIdentifier not matching")) |