Mercurial > repos > public > sbplib_julia
comparison sbpD2.jl @ 35:91e662512e9a
Fix bugs in sbpD2
author | Ylva Rydin <ylva.rydin@telia.com> |
---|---|
date | Thu, 10 Jan 2019 14:47:44 +0100 |
parents | 55fea1ceb6aa |
children | 8b04efde1a46 |
comparison
equal
deleted
inserted
replaced
29:19078a768c5a | 35:91e662512e9a |
---|---|
13 function readOperator(D2fn, Hfn) | 13 function readOperator(D2fn, Hfn) |
14 d = readSectionedFile(D2fn) | 14 d = readSectionedFile(D2fn) |
15 h = readSectionedFile(Hfn) | 15 h = readSectionedFile(Hfn) |
16 | 16 |
17 # Create inner stencil | 17 # Create inner stencil |
18 innerStencilWeights = stringToVector(Float64, d["inner_stencil"]) | 18 innerStencilWeights = stringToVector(Float64, d["inner_stencil"][1]) |
19 width = length(innerStencilWeights) | 19 width = length(innerStencilWeights) |
20 r = (-width//2, width//2) | 20 r = (-div(width,2), div(width,2)) |
21 | |
21 innerStencil = Stencil(r, innerStencilWeights) | 22 innerStencil = Stencil(r, innerStencilWeights) |
22 | 23 |
23 # Create boundary stencils | 24 # Create boundary stencils |
24 boundarySize = length(d["boundary_stencils"]) | 25 boundarySize = length(d["boundary_stencils"]) |
25 closureStencils = Vector{Stencil}() | 26 closureStencils = Vector{Stencil}() |
27 | |
26 for i ∈ 1:boundarySize | 28 for i ∈ 1:boundarySize |
27 stencilWeights = stringToVector(Float64, d["boundary_stencils"][i]) | 29 stencilWeights = stringToVector(Float64, d["boundary_stencils"][i]) |
28 | 30 width = length(stencilWeights) |
31 r = (1-i,width-i) | |
32 push!(closureStencils,Stencil(r, stencilWeights)) | |
29 end | 33 end |
30 | 34 |
31 d2 = D2( | 35 d2 = D2( |
32 stringToVector(Float64, h["closure"]), | 36 stringToVector(Float64, h["closure"][1]), |
33 innerStencil, | 37 innerStencil, |
34 closureStencils, | 38 closureStencils, |
35 stringToVector(Float64, d["e"]), | 39 stringToVector(Float64, d["e"][1]), |
36 stringToVector(Float64, d["d1"]), | 40 stringToVector(Float64, d["d1"][1]), |
37 ) | 41 ) |
38 | 42 |
39 # Return d2! | 43 return d2 |
40 | |
41 return nothing | |
42 end | 44 end |
43 | 45 |
44 | 46 |
45 function readSectionedFile(filename)::Dict{String, Vector{String}} | 47 function readSectionedFile(filename)::Dict{String, Vector{String}} |
46 f = open(filename) | 48 f = open(filename) |
64 end | 66 end |
65 | 67 |
66 return sections | 68 return sections |
67 end | 69 end |
68 | 70 |
69 function stringToVector(T::DataType, s::String; delimiter = " ") | 71 function stringToVector(T::DataType, s::String) |
70 return parse(T, split(s, delimiter)) | 72 return T.(eval.(Meta.parse.(split(s)))) |
71 end | 73 end |