Mercurial > repos > public > sbplib_julia
changeset 1761:0656b46a1a74 feature/jet_aqua
Simplify size type in VolumeOperator
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 13 Sep 2024 14:47:23 +0200 |
parents | aba2ce166546 |
children | 164e26a6cf79 |
files | src/SbpOperators/volumeops/volume_operator.jl test/SbpOperators/volumeops/volume_operator_test.jl |
diffstat | 2 files changed, 8 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/SbpOperators/volumeops/volume_operator.jl Fri Sep 13 14:32:05 2024 +0200 +++ b/src/SbpOperators/volumeops/volume_operator.jl Fri Sep 13 14:47:23 2024 +0200 @@ -6,23 +6,23 @@ struct VolumeOperator{T,N,M,K} <: LazyTensor{T,1,1} inner_stencil::Stencil{T,N} closure_stencils::NTuple{M,Stencil{T,K}} - size::NTuple{1,Int} + size::Int parity::Parity - function VolumeOperator(inner_stencil::Stencil{T,N}, closure_stencils::Tuple{Stencil{T,K}, Vararg{Stencil{T,K}}}, size::NTuple{1,Int}, parity::Parity) where {T,N,K} + function VolumeOperator(inner_stencil::Stencil{T,N}, closure_stencils::Tuple{Stencil{T,K}, Vararg{Stencil{T,K}}}, size::Int, parity::Parity) where {T,N,K} M = length(closure_stencils) return new{T,N,M,K}(inner_stencil, closure_stencils, size, parity) end end function VolumeOperator(grid::EquidistantGrid, inner_stencil, closure_stencils, parity) - return VolumeOperator(inner_stencil, Tuple(closure_stencils), size(grid), parity) + return VolumeOperator(inner_stencil, Tuple(closure_stencils), size(grid,1), parity) end # TBD: Remove this function? closure_size(::VolumeOperator{T,N,M}) where {T,N,M} = M -LazyTensors.range_size(op::VolumeOperator) = op.size -LazyTensors.domain_size(op::VolumeOperator) = op.size +LazyTensors.range_size(op::VolumeOperator) = (op.size,) +LazyTensors.domain_size(op::VolumeOperator) = (op.size,) function LazyTensors.apply(op::VolumeOperator, v::AbstractVector, i::Index{Lower}) return @inbounds apply_stencil(op.closure_stencils[Int(i)], v, Int(i)) @@ -33,11 +33,11 @@ end function LazyTensors.apply(op::VolumeOperator, v::AbstractVector, i::Index{Upper}) - return @inbounds Int(op.parity)*apply_stencil_backwards(op.closure_stencils[op.size[1]-Int(i)+1], v, Int(i)) + return @inbounds Int(op.parity)*apply_stencil_backwards(op.closure_stencils[op.size-Int(i)+1], v, Int(i)) end function LazyTensors.apply(op::VolumeOperator, v::AbstractVector, i) - r = getregion(i, closure_size(op), op.size[1]) + r = getregion(i, closure_size(op), op.size) return LazyTensors.apply(op, v, Index(i, r)) end # TODO: Move this to LazyTensors when we have the region communication down.
--- a/test/SbpOperators/volumeops/volume_operator_test.jl Fri Sep 13 14:32:05 2024 +0200 +++ b/test/SbpOperators/volumeops/volume_operator_test.jl Fri Sep 13 14:47:23 2024 +0200 @@ -17,7 +17,7 @@ g = equidistant_grid(0.,1., 11) @testset "Constructors" begin - op = VolumeOperator(inner_stencil,closure_stencils,(11,),even) + op = VolumeOperator(inner_stencil, closure_stencils, 11, even) @test op == VolumeOperator(g,inner_stencil,closure_stencils,even) @test op isa LazyTensor{T,1,1} where T end