Mercurial > repos > public > sbplib_julia
changeset 1114:fc57804c9bf4 feature/grids
Add function dims
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Fri, 15 Jul 2022 09:38:08 +0200 |
parents | 4e4c5011140d |
children | 6530fceef37c |
files | src/Grids/AbstractGrid.jl src/Grids/EquidistantGrid.jl src/SbpOperators/boundaryops/boundary_operator.jl src/SbpOperators/volumeops/inner_products/inner_product.jl src/SbpOperators/volumeops/inner_products/inverse_inner_product.jl src/SbpOperators/volumeops/volume_operator.jl |
diffstat | 6 files changed, 15 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Grids/AbstractGrid.jl Thu Jul 14 18:33:36 2022 +0200 +++ b/src/Grids/AbstractGrid.jl Fri Jul 15 09:38:08 2022 +0200 @@ -22,3 +22,12 @@ return F.(points(g)) end export evalOn + + +""" + dims(g::AbstractGrid) + +A range containing the dimensions of the grid +""" +dims(grid::AbstractGrid) = 1:dimension(grid) +export dims \ No newline at end of file
--- a/src/Grids/EquidistantGrid.jl Thu Jul 14 18:33:36 2022 +0200 +++ b/src/Grids/EquidistantGrid.jl Fri Jul 15 09:38:08 2022 +0200 @@ -124,9 +124,8 @@ Returns the dimensions of grid orthogonal to that of dim. """ function orthogonal_dims(grid::EquidistantGrid, dim) - dims = 1:dimension(grid) - orth_dims = filter(i -> i != dim, dims) - if orth_dims == dims + orth_dims = filter(i -> i != dim, dims(grid)) + if orth_dims == dims(grid) throw(DomainError(string("dimension ",string(dim)," not matching grid"))) end return orth_dims
--- a/src/SbpOperators/boundaryops/boundary_operator.jl Thu Jul 14 18:33:36 2022 +0200 +++ b/src/SbpOperators/boundaryops/boundary_operator.jl Fri Jul 15 09:38:08 2022 +0200 @@ -18,7 +18,7 @@ op = BoundaryOperator(restrict(grid, d), closure_stencil, r) # Create 1D IdentityTensors for each coordinate direction - one_d_grids = restrict.(Ref(grid), Tuple(1:dimension(grid))) + one_d_grids = restrict.(Ref(grid), Tuple(dims(grid))) Is = IdentityTensor{eltype(grid)}.(size.(one_d_grids)) # Formulate the correct outer product sequence of the identity mappings and
--- a/src/SbpOperators/volumeops/inner_products/inner_product.jl Thu Jul 14 18:33:36 2022 +0200 +++ b/src/SbpOperators/volumeops/inner_products/inner_product.jl Fri Jul 15 09:38:08 2022 +0200 @@ -18,7 +18,7 @@ function inner_product(grid::EquidistantGrid, interior_weight, closure_weights) Hs = () - for i ∈ 1:dimension(grid) + for i ∈ dims(grid) Hs = (Hs..., inner_product(restrict(grid, i), interior_weight, closure_weights)) end
--- a/src/SbpOperators/volumeops/inner_products/inverse_inner_product.jl Thu Jul 14 18:33:36 2022 +0200 +++ b/src/SbpOperators/volumeops/inner_products/inverse_inner_product.jl Fri Jul 15 09:38:08 2022 +0200 @@ -15,7 +15,7 @@ function inverse_inner_product(grid::EquidistantGrid, interior_weight, closure_weights) H⁻¹s = () - for i ∈ 1:dimension(grid) + for i ∈ dims(grid) H⁻¹s = (H⁻¹s..., inverse_inner_product(restrict(grid, i), interior_weight, closure_weights)) end
--- a/src/SbpOperators/volumeops/volume_operator.jl Thu Jul 14 18:33:36 2022 +0200 +++ b/src/SbpOperators/volumeops/volume_operator.jl Fri Jul 15 09:38:08 2022 +0200 @@ -15,7 +15,7 @@ # Create 1D volume operator in along coordinate direction op = VolumeOperator(restrict(grid, direction), inner_stencil, closure_stencils, parity) # Create 1D IdentityTensors for each coordinate direction - one_d_grids = restrict.(Ref(grid), Tuple(1:dimension(grid))) + one_d_grids = restrict.(Ref(grid), Tuple(dims(grid))) Is = IdentityTensor{eltype(grid)}.(size.(one_d_grids)) # Formulate the correct outer product sequence of the identity mappings and # the volume operator