comparison sbpD2.jl @ 40:8b04efde1a46

Merge
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 10 Jan 2019 15:53:44 +0100
parents bb841977d198 91e662512e9a
children ef060ab3b035
comparison
equal deleted inserted replaced
34:bb841977d198 40:8b04efde1a46
37 function readOperator(D2fn, Hfn) 37 function readOperator(D2fn, Hfn)
38 d = readSectionedFile(D2fn) 38 d = readSectionedFile(D2fn)
39 h = readSectionedFile(Hfn) 39 h = readSectionedFile(Hfn)
40 40
41 # Create inner stencil 41 # Create inner stencil
42 innerStencilWeights = stringToVector(Float64, d["inner_stencil"]) 42 innerStencilWeights = stringToVector(Float64, d["inner_stencil"][1])
43 width = length(innerStencilWeights) 43 width = length(innerStencilWeights)
44 r = (-width//2, width//2) 44 r = (-div(width,2), div(width,2))
45
45 innerStencil = Stencil(r, innerStencilWeights) 46 innerStencil = Stencil(r, innerStencilWeights)
46 47
47 # Create boundary stencils 48 # Create boundary stencils
48 boundarySize = length(d["boundary_stencils"]) 49 boundarySize = length(d["boundary_stencils"])
49 closureStencils = Vector{Stencil}() 50 closureStencils = Vector{Stencil}()
51
50 for i ∈ 1:boundarySize 52 for i ∈ 1:boundarySize
51 stencilWeights = stringToVector(Float64, d["boundary_stencils"][i]) 53 stencilWeights = stringToVector(Float64, d["boundary_stencils"][i])
52 54 width = length(stencilWeights)
55 r = (1-i,width-i)
56 push!(closureStencils,Stencil(r, stencilWeights))
53 end 57 end
54 58
55 d2 = D2( 59 d2 = D2(
56 stringToVector(Float64, h["closure"]), 60 stringToVector(Float64, h["closure"][1]),
57 innerStencil, 61 innerStencil,
58 closureStencils, 62 closureStencils,
59 stringToVector(Float64, d["e"]), 63 stringToVector(Float64, d["e"][1]),
60 stringToVector(Float64, d["d1"]), 64 stringToVector(Float64, d["d1"][1]),
61 even 65 even
62 ) 66 )
63 67
64 # Return d2! 68 return d2
65
66 return nothing
67 end 69 end
68 70
69 71
70 function readSectionedFile(filename)::Dict{String, Vector{String}} 72 function readSectionedFile(filename)::Dict{String, Vector{String}}
71 f = open(filename) 73 f = open(filename)
89 end 91 end
90 92
91 return sections 93 return sections
92 end 94 end
93 95
94 function stringToVector(T::DataType, s::String; delimiter = " ") 96 function stringToVector(T::DataType, s::String)
95 return parse(T, split(s, delimiter)) 97 return T.(eval.(Meta.parse.(split(s))))
96 end 98 end