Mercurial > repos > public > sbplib_julia
comparison DiffOps/src/laplace.jl @ 239:60011a10e17d boundary_conditions
Add tests for BoundaryValue and fix index types
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Wed, 26 Jun 2019 20:02:01 +0200 |
| parents | a5fdc00d5070 |
| children | 9819243102dd |
comparison
equal
deleted
inserted
replaced
| 238:d56bf288b3be | 239:60011a10e17d |
|---|---|
| 10 end | 10 end |
| 11 export NormalDerivative | 11 export NormalDerivative |
| 12 | 12 |
| 13 # Not correct abstraction level | 13 # Not correct abstraction level |
| 14 # TODO: Not type stable D:< | 14 # TODO: Not type stable D:< |
| 15 function apply(d::NormalDerivative, v::AbstractArray, I::CartesianIndex{2}) | 15 function apply(d::NormalDerivative, v::AbstractArray, I::NTuple{2,Int}) |
| 16 i = I[dim(d.bId)] | 16 i = I[dim(d.bId)] |
| 17 j = I[3-dim(d.bId)] | 17 j = I[3-dim(d.bId)] |
| 18 N_i = d.grid.size[dim(d.bId)] | 18 N_i = d.grid.size[dim(d.bId)] |
| 19 | 19 |
| 20 r = getregion(i, closureSize(d.op), N_i) | 20 r = getregion(i, closureSize(d.op), N_i) |
| 29 elseif r == Upper | 29 elseif r == Upper |
| 30 return d.grid.inverse_spacing[dim(d.bId)]*d.op.dClosure[N_i-j]*v[j] | 30 return d.grid.inverse_spacing[dim(d.bId)]*d.op.dClosure[N_i-j]*v[j] |
| 31 end | 31 end |
| 32 end | 32 end |
| 33 | 33 |
| 34 function apply_transpose(d::NormalDerivative, v::AbstractArray, I::CartesianIndex{1}) | 34 function apply_transpose(d::NormalDerivative, v::AbstractArray, I::NTuple{1,Int}) |
| 35 u = selectdim(v,3-dim(d.bId),I) | 35 u = selectdim(v,3-dim(d.bId),I) |
| 36 return apply_d(d.op, d.grid.inverse_spacing[dim(d.bId)], u, region(d.bId)) | 36 return apply_d(d.op, d.grid.inverse_spacing[dim(d.bId)], u, region(d.bId)) |
| 37 end | 37 end |
| 38 | 38 |
| 39 | 39 |
| 52 # TODO: This is obviouly strange. Is domain_size just discarded? Is there a way to avoid storing grid in BoundaryValue? | 52 # TODO: This is obviouly strange. Is domain_size just discarded? Is there a way to avoid storing grid in BoundaryValue? |
| 53 # Can we give special treatment to TensorMappings that go to a higher dim? | 53 # Can we give special treatment to TensorMappings that go to a higher dim? |
| 54 LazyTensors.range_size(e::BoundaryValue{T}, domain_size::NTuple{1,Integer}) where T = size(e.grid) | 54 LazyTensors.range_size(e::BoundaryValue{T}, domain_size::NTuple{1,Integer}) where T = size(e.grid) |
| 55 LazyTensors.domain_size(e::BoundaryValue{T}, range_size::NTuple{2,Integer}) where T = (range_size[3-dim(e.bId)],); | 55 LazyTensors.domain_size(e::BoundaryValue{T}, range_size::NTuple{2,Integer}) where T = (range_size[3-dim(e.bId)],); |
| 56 | 56 |
| 57 function LazyTensors.apply(e::BoundaryValue, v::AbstractArray, I::CartesianIndex{2}) | 57 function LazyTensors.apply(e::BoundaryValue, v::AbstractArray, I::NTuple{2,Int}) |
| 58 i = I[dim(e.bId)] | 58 i = I[dim(e.bId)] |
| 59 j = I[3-dim(e.bId)] | 59 j = I[3-dim(e.bId)] |
| 60 N_i = e.grid.size[dim(e.bId)] | 60 N_i = e.grid.size[dim(e.bId)] |
| 61 | 61 |
| 62 r = getregion(i, closureSize(e.op), N_i) | 62 r = getregion(i, closureSize(e.op), N_i) |
| 71 elseif r == Upper | 71 elseif r == Upper |
| 72 return e.op.eClosure[N_i-j]*v[j] | 72 return e.op.eClosure[N_i-j]*v[j] |
| 73 end | 73 end |
| 74 end | 74 end |
| 75 | 75 |
| 76 function LazyTensors.apply_transpose(e::BoundaryValue, v::AbstractArray, I::CartesianIndex{1}) | 76 function LazyTensors.apply_transpose(e::BoundaryValue, v::AbstractArray, I::NTuple{1,Int}) |
| 77 u = selectdim(v,3-dim(e.bId),I) | 77 u = selectdim(v,3-dim(e.bId),I[1]) |
| 78 return apply_e(e.op, u, region(e.bId)) | 78 return apply_e(e.op, u, region(e.bId)) |
| 79 end | 79 end |
| 80 | 80 |
| 81 | 81 |
| 82 | 82 |
