Mercurial > repos > public > sbplib_julia
changeset 784:cd8cd6db2a42 refactor/inner_product_recursive
Refactor inner_product to use a recursive call to 1-dim code for multi dimensional equidistant grids
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 19 Jul 2021 20:39:38 +0200 |
parents | d7d030f8f708 |
children | 21d6bc4a6d65 |
files | src/SbpOperators/volumeops/inner_products/inner_product.jl |
diffstat | 1 files changed, 12 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/SbpOperators/volumeops/inner_products/inner_product.jl Wed Jul 14 23:58:20 2021 +0200 +++ b/src/SbpOperators/volumeops/inner_products/inner_product.jl Mon Jul 19 20:39:38 2021 +0200 @@ -16,14 +16,20 @@ `H` is a 0-dimensional `IdentityMapping`. """ function inner_product(grid::EquidistantGrid, closure_stencils, inner_stencil = CenteredStencil(one(eltype(grid)))) - h = spacing(grid) - H = SbpOperators.volume_operator(grid, scale(inner_stencil,h[1]), scale.(closure_stencils,h[1]), even, 1) - for i ∈ 2:dimension(grid) - Hᵢ = SbpOperators.volume_operator(grid, scale(inner_stencil,h[i]), scale.(closure_stencils,h[i]), even, i) - H = H∘Hᵢ + Hs = () + + for i ∈ 1:dimension(grid) + Hs = (Hs..., inner_product(restrict(grid, i), closure_stencils, inner_stencil)) end - return H + + return foldl(⊗, Hs) end export inner_product +function inner_product(grid::EquidistantGrid{1}, closure_stencils, inner_stencil = CenteredStencil(one(eltype(grid)))) + h = spacing(grid) + H = SbpOperators.volume_operator(grid, scale(inner_stencil,h[1]), scale.(closure_stencils,h[1]), even, 1) + return H +end + inner_product(grid::EquidistantGrid{0}, closure_stencils, inner_stencil) = IdentityMapping{eltype(grid)}()