Mercurial > repos > public > sbplib_julia
changeset 139:b9e8d2e1a30f cell_based_test
Merged heads for cell_based_test
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 21 Feb 2019 16:53:13 +0100 |
parents | d61bfc8cf6a5 (current diff) 6b6d921e8f05 (diff) |
children | 6aa61155fd37 |
files | |
diffstat | 2 files changed, 27 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/sbpD2.jl Thu Feb 21 16:51:27 2019 +0100 +++ b/sbpD2.jl Thu Feb 21 16:53:13 2019 +0100 @@ -31,6 +31,7 @@ end end + # Wrapper functions for using regular indecies without specifying regions @inline function apply(op::ConstantStencilOperator, h::Real, v::AbstractVector, i::Int) return apply(op, h, v, Index{Unknown}(i)) @@ -45,8 +46,8 @@ quadratureClosure::NTuple{M,T} innerStencil::Stencil{T,N} closureStencils::NTuple{M,Stencil{T,K}} - eClosure::NTuple{M,T} - dClosure::NTuple{M,T} + eClosure::Stencil{T,M} + dClosure::Stencil{T,M} parity::Parity end @@ -77,8 +78,8 @@ end quadratureClosure = pad_tuple(stringToTuple(Float64, h["closure"][1]), boundarySize) - eClosure = pad_tuple(stringToTuple(Float64, d["e"][1]), boundarySize) - dClosure = pad_tuple(stringToTuple(Float64, d["d1"][1]), boundarySize) + eClosure = Stencil((0,boundarySize-1), pad_tuple(stringToTuple(Float64, d["e"][1]), boundarySize)) + dClosure = Stencil((0,boundarySize-1), pad_tuple(stringToTuple(Float64, d["d1"][1]), boundarySize)) d2 = D2( quadratureClosure, @@ -93,6 +94,23 @@ end +function apply_e(op::D2, v::AbstractVector, ::Type{Lower}) + apply(op.eClosure,v,1) +end + +function apply_e(op::D2, v::AbstractVector, ::Type{Upper}) + apply(flip(op.eClosure),v,length(v)) +end + + +function apply_d(op::D2, h::Real, v::AbstractVector, ::Type{Lower}) + -apply(op.dClosure,v,1)/h +end + +function apply_d(op::D2, h::Real, v::AbstractVector, ::Type{Upper}) + -apply(flip(op.dClosure),v,length(v))/h +end + function readSectionedFile(filename)::Dict{String, Vector{String}} f = open(filename) sections = Dict{String, Vector{String}}()
--- a/stencil.jl Thu Feb 21 16:51:27 2019 +0100 +++ b/stencil.jl Thu Feb 21 16:53:13 2019 +0100 @@ -1,6 +1,11 @@ struct Stencil{T<:Real,N} range::Tuple{Int,Int} weights::NTuple{N,T} + + function Stencil(range::Tuple{Int,Int},weights::NTuple{N,T}) where {T <: Real, N} + @assert range[2]-range[1]+1 == N + new{T,N}(range,weights) + end end function flip(s::Stencil)