Mercurial > repos > public > sbplib_julia
changeset 254:4ca3794fffef boundary_conditions
Add apply_quadrature to SbpOperators
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 27 Jun 2019 16:10:25 +0200 |
parents | 396eadb652bd |
children | e960b877e07e |
files | SbpOperators/src/d2.jl SbpOperators/test/runtests.jl |
diffstat | 2 files changed, 30 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/SbpOperators/src/d2.jl Thu Jun 27 16:05:26 2019 +0200 +++ b/SbpOperators/src/d2.jl Thu Jun 27 16:10:25 2019 +0200 @@ -18,6 +18,16 @@ return length(D.quadratureClosure) end +apply_quadrature(op::D2{T}, h::Real, v::T, i::Integer, N::Integer, ::Type{Lower}) where T = v*h*op.quadratureClosure[i] +apply_quadrature(op::D2{T}, h::Real, v::T, i::Integer, N::Integer, ::Type{Upper}) where T = v*h*op.quadratureClosure[N-i+1] +apply_quadrature(op::D2{T}, h::Real, v::T, i::Integer, N::Integer, ::Type{Interior}) where T = v*h + +function apply_quadrature(op::D2{T}, h::Real, v::T, i::Integer, N::Integer) where T + r = getregion(i, closuresize(op), N) + return apply_quadrature(op, h, v, i, N, r) +end +export apply_quadrature + function apply_e_T(op::D2, v::AbstractVector, ::Type{Lower}) @boundscheck if length(v) < closuresize(op) throw(BoundsError())
--- a/SbpOperators/test/runtests.jl Thu Jun 27 16:05:26 2019 +0200 +++ b/SbpOperators/test/runtests.jl Thu Jun 27 16:10:25 2019 +0200 @@ -1,4 +1,23 @@ using SbpOperators using Test -@test_broken false +@testset "apply_quadrature" begin + op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") + h = 0.5 + + @test apply_quadrature(op, h, 1.0, 10, 100) == h + + N = 10 + qc = op.quadratureClosure + q = h.*(qc..., ones(N-2*closuresize(op))..., reverse(qc)...) + @assert length(q) == N + + for i ∈ 1:N + @test apply_quadrature(op, h, 1.0, i, N) == q[i] + end + + v = [2.,3.,2.,4.,5.,4.,3.,4.,5.,4.5] + for i ∈ 1:N + @test apply_quadrature(op, h, v[i], i, N) == q[i]*v[i] + end +end