Mercurial > repos > public > sbplib_julia
changeset 104:1862e901febb cell_based_test
Merge with tip
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 07 Feb 2019 17:17:31 +0100 |
parents | a274d6384e91 (current diff) f99320a459ef (diff) |
children | 44cd6b4371de |
files | |
diffstat | 2 files changed, 35 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TODO.txt Thu Feb 07 17:17:31 2019 +0100 @@ -0,0 +1,7 @@ +# TODO + +Kolla att vi har @inbounds och @propagate_inbounds på rätt ställen +Kolla att vi gör boundschecks överallt och att de är markerade med @boundscheck +Kolla att vi har @inline på rätt ställen + +Ändra namn på variabler och funktioner så att det följer style-guide \ No newline at end of file
--- a/sbpD2.jl Thu Feb 07 17:15:26 2019 +0100 +++ b/sbpD2.jl Thu Feb 07 17:17:31 2019 +0100 @@ -42,11 +42,11 @@ end struct D2{T,N,M,K} <: ConstantStencilOperator - quadratureClosure::Vector{T} + quadratureClosure::NTuple{M,T} innerStencil::Stencil{T,N} - closureStencils::NTuple{M, Stencil{T,K}} - eClosure::Vector{T} - dClosure::Vector{T} + closureStencils::NTuple{M,Stencil{T,K}} + eClosure::NTuple{M,T} + dClosure::NTuple{M,T} parity::Parity end @@ -59,29 +59,33 @@ h = readSectionedFile(Hfn) # Create inner stencil - innerStencilWeights = stringToVector(Float64, d["inner_stencil"][1]) + innerStencilWeights = stringToTuple(Float64, d["inner_stencil"][1]) width = length(innerStencilWeights) r = (-div(width,2), div(width,2)) - innerStencil = Stencil(r, Tuple(innerStencilWeights)) + innerStencil = Stencil(r, innerStencilWeights) # Create boundary stencils boundarySize = length(d["boundary_stencils"]) closureStencils = Vector{typeof(innerStencil)}() # TBD: is the the right way to get the correct type? for i ∈ 1:boundarySize - stencilWeights = stringToVector(Float64, d["boundary_stencils"][i]) + stencilWeights = stringToTuple(Float64, d["boundary_stencils"][i]) width = length(stencilWeights) r = (1-i,width-i) - closureStencils = (closureStencils..., Stencil(r, Tuple(stencilWeights))) + closureStencils = (closureStencils..., Stencil(r, stencilWeights)) 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) + d2 = D2( - stringToVector(Float64, h["closure"][1]), + quadratureClosure, innerStencil, closureStencils, - stringToVector(Float64, d["e"][1]), - stringToVector(Float64, d["d1"][1]), + eClosure, + dClosure, even ) @@ -113,6 +117,19 @@ return sections end +function stringToTuple(T::DataType, s::String) + return Tuple(stringToVector(T,s)) +end + function stringToVector(T::DataType, s::String) return T.(eval.(Meta.parse.(split(s)))) end + + +function pad_tuple(t::NTuple{N, T}, n::Integer) where {N,T} + if N >= n + return t + else + return pad_tuple((t..., zero(T)), n) + end +end