Mercurial > repos > public > sbplib_julia
changeset 1693:c7eee3952dcd feature/sbp_operators/laplace_curvilinear
Add tests for inner product on boundary grids of mapped grid
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 28 Aug 2024 09:56:35 +0200 |
parents | de2c4b2663b4 |
children | 29b96fc75bee |
files | test/SbpOperators/volumeops/inner_products/inner_product_test.jl |
diffstat | 1 files changed, 27 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/test/SbpOperators/volumeops/inner_products/inner_product_test.jl Mon Aug 26 16:15:25 2024 +0200 +++ b/test/SbpOperators/volumeops/inner_products/inner_product_test.jl Wed Aug 28 09:56:35 2024 +0200 @@ -7,6 +7,7 @@ import Sbplib.SbpOperators.ConstantInteriorScalingOperator using StaticArrays +using LinearAlgebra @testset "Diagonal-stencil inner_product" begin Lx = π/2. @@ -107,6 +108,32 @@ mg = equidistant_grid(c, 10,13) @test inner_product(mg, stencil_set) isa LazyTensor{<:Any, 2,2} + + @testset "Accuracy" begin + v = function(x̄) + log(norm(x̄-@SVector[.5, .5]))/2π + log(norm(x̄-@SVector[1.5, 3]))/2π + end + ∇v = function(x̄) + ∇log(ȳ) = ȳ/(ȳ⋅ȳ) + ∇log(x̄-@SVector[.5, .5])/2π + ∇log(x̄-@SVector[1.5, 3])/2π + end + + mg = equidistant_grid(c, 80,80) + v̄ = map(v, mg) + + @testset for (order, atol) ∈ [(2,1e-3),(4,1e-7)] + stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order=order) + + @test sum(boundary_identifiers(mg)) do bId + ∂ₙv = map(boundary_grid(mg,bId),normal(mg,bId)) do x̄,n̂ + n̂⋅∇v(x̄) + end + Hᵧ = inner_product(boundary_grid(mg,bId), stencil_set) + sum(Hᵧ*∂ₙv) + end ≈ 2 atol=atol + + end + end @test_broken false # Test that it calculates the right thing end end