comparison src/Grids/EquidistantGrid.jl @ 682:3ed922e95a35 feature/boundary_quads

Make boundary_grid throw if invalid boundary identifier is passed.
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Mon, 08 Feb 2021 20:12:09 +0100
parents 1d3e29ffc6c6
children 984f6fe42708
comparison
equal deleted inserted replaced
681:43cf58c69f91 682:3ed922e95a35
120 Creates the lower-dimensional restriciton of `grid` spanned by the dimensions 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 121 orthogonal to the boundary specified by `id`. The boundary grid of a 1-dimensional
122 grid is a zero-dimensional grid. 122 grid is a zero-dimensional grid.
123 """ 123 """
124 function boundary_grid(grid::EquidistantGrid,id::CartesianBoundary) 124 function boundary_grid(grid::EquidistantGrid,id::CartesianBoundary)
125 dims = collect(1:dimension(grid))
126 orth_dims = dims[dims .!= dim(id)]
127 if orth_dims == dims
128 throw(DomainError("boundary identifier not matching grid"))
129 end
125 dims = collect(1:dimension(grid)) 130 dims = collect(1:dimension(grid))
126 orth_dims = dims[dims .!= dim(id)] 131 orth_dims = dims[dims .!= dim(id)]
127 return restrict(grid,orth_dims) 132 return restrict(grid,orth_dims)
128 end 133 end
129 export boundary_grid 134 export boundary_grid
130 boundary_grid(::EquidistantGrid{1},::CartesianBoundary{1}) = EquidistantGrid((),(),()) 135 boundary_grid(::EquidistantGrid{1},::CartesianBoundary{1}) = EquidistantGrid((),(),())
131 boundary_grid(::EquidistantGrid{1},::CartesianBoundary) = throw(DimensionMismatch("dimension of Grid and BoundaryIdentifier not matching"))