Mercurial > repos > public > sbplib_julia
comparison sbpD2.jl @ 42:c061d1bddba5
Merge latest changes
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 10 Jan 2019 16:49:20 +0100 |
parents | 8b04efde1a46 |
children | ef060ab3b035 |
comparison
equal
deleted
inserted
replaced
41:3d8bfb695497 | 42:c061d1bddba5 |
---|---|
1 struct D2{T} | 1 abstract type ConstantStencilOperator end |
2 | |
3 function apply!(op::ConstantStencilOperator, u::AbstractVector, v::AbstractVector, h::Real, start::Int, N::Int; stride::Int=1) | |
4 cSize = closureSize(op) | |
5 | |
6 for i ∈ range(start; length=cSize, step=stride) | |
7 u[i] = apply!(op.closureStencils[i], v, i; stride=stride)/h^2 | |
8 end | |
9 | |
10 innerStart = start + cSize*stride | |
11 innerEnd = N - cSize*stride-1 | |
12 for i ∈ range(innerStart, stop=innerEnd, step=stride) | |
13 u[i] = apply(op.innerStencil, v, i; stride=stride)/h^2 | |
14 end | |
15 | |
16 for i ∈ range(innerEnd+1, length=cSize, step=cSize) | |
17 u[i] = op.parity*apply(flip(op.closureStencils[M-i+1]), v, i; stride=stride)/h^2 | |
18 end | |
19 end | |
20 | |
21 odd = -1 | |
22 even = 1 | |
23 | |
24 struct D2{T} <: ConstantStencilOperator | |
2 quadratureClosure::Vector{T} | 25 quadratureClosure::Vector{T} |
3 innerStencil::Stencil | 26 innerStencil::Stencil |
4 closureStencils::Vector{Stencil} # TBD: Should this be a tuple? | 27 closureStencils::Vector{Stencil} # TBD: Should this be a tuple? |
5 eClosure::Vector{T} | 28 eClosure::Vector{T} |
6 dClosure::Vector{T} | 29 dClosure::Vector{T} |
30 parity::Int | |
7 end | 31 end |
8 | 32 |
9 function closureSize(D::D2)::Int | 33 function closureSize(D::D2)::Int |
10 return length(quadratureClosure) | 34 return length(quadratureClosure) |
11 end | 35 end |
36 stringToVector(Float64, h["closure"][1]), | 60 stringToVector(Float64, h["closure"][1]), |
37 innerStencil, | 61 innerStencil, |
38 closureStencils, | 62 closureStencils, |
39 stringToVector(Float64, d["e"][1]), | 63 stringToVector(Float64, d["e"][1]), |
40 stringToVector(Float64, d["d1"][1]), | 64 stringToVector(Float64, d["d1"][1]), |
65 even | |
41 ) | 66 ) |
42 | 67 |
43 return d2 | 68 return d2 |
44 end | 69 end |
45 | 70 |