Mercurial > repos > public > sbplib_julia
comparison sbpD2.jl @ 56:27a8d3021a1c cell_based_test
Convert apply functions to cell-based
author | Ylva Rydin <ylva.rydin@telia.com> |
---|---|
date | Tue, 15 Jan 2019 12:26:06 +0100 |
parents | 8c4cfa680e5a |
children | 7ab0043aca53 d485da6e3a77 |
comparison
equal
deleted
inserted
replaced
55:c62ea0112d4d | 56:27a8d3021a1c |
---|---|
1 abstract type ConstantStencilOperator end | 1 abstract type ConstantStencilOperator end |
2 | 2 |
3 function apply!(op::ConstantStencilOperator, u::AbstractVector, v::AbstractVector, h::Real) | 3 function apply(op::ConstantStencilOperator, h::Real, v::AbstractVector, i::Int) |
4 cSize = closureSize(op) | |
4 N = length(v) | 5 N = length(v) |
5 cSize = closureSize(op) | |
6 | 6 |
7 for i ∈ range(1; length=cSize) | 7 if i ∈ range(1; length=cSize) |
8 u[i] = apply(op.closureStencils[i], v, i)/h^2 | 8 uᵢ = apply(op.closureStencils[i], v, i)/h^2 |
9 elseif i ∈ range(N - cSize+1, length=cSize) | |
10 uᵢ = Int(op.parity)*apply(flip(op.closureStencils[N-i+1]), v, i)/h^2 | |
11 else | |
12 uᵢ = apply(op.innerStencil, v, i)/h^2 | |
9 end | 13 end |
10 | 14 |
11 innerStart = 1 + cSize | 15 return uᵢ |
12 innerEnd = N - cSize | |
13 for i ∈ range(innerStart, stop=innerEnd) | |
14 u[i] = apply(op.innerStencil, v, i)/h^2 | |
15 end | |
16 | |
17 for i ∈ range(innerEnd+1, length=cSize) | |
18 u[i] = Int(op.parity)*apply(flip(op.closureStencils[N-i+1]), v, i)/h^2 | |
19 end | |
20 | |
21 return nothing | |
22 end | 16 end |
23 | 17 |
24 @enum Parity begin | 18 @enum Parity begin |
25 odd = -1 | 19 odd = -1 |
26 even = 1 | 20 even = 1 |