annotate src/SbpOperators/volumeops/volume_operator.jl @ 1685:4aa0973bffb0 feature/grids/manifolds

Restrict the argument types of the simplest equidistant_grid to Number to avoid ambiguity
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 21 Aug 2024 19:10:37 +0200
parents ff64acfc1ec9
children aba2ce166546
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
611
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
1 """
1070
2b6298905692 Fix typo in doc string for VolumeOperator
Jonatan Werpers <jonatan@werpers.com>
parents: 995
diff changeset
2 VolumeOperator{T,N,M,K} <: LazyTensor{T,1,1}
1155
716e721ce3eb Fix formatting in a few docstrings
Jonatan Werpers <jonatan@werpers.com>
parents: 1149
diff changeset
3
1329
e94ddef5e72f Clean up documentation for changed types in SbpOperatorClean up documentation for changed types in SbpOperatorss
Jonatan Werpers <jonatan@werpers.com>
parents: 1291
diff changeset
4 A one-dimensional constant coefficients stencil operator.
611
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
5 """
995
1ba8a398af9c Rename types
Jonatan Werpers <jonatan@werpers.com>
parents: 946
diff changeset
6 struct VolumeOperator{T,N,M,K} <: LazyTensor{T,1,1}
611
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
7 inner_stencil::Stencil{T,N}
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
8 closure_stencils::NTuple{M,Stencil{T,K}}
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
9 size::NTuple{1,Int}
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
10 parity::Parity
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
11 end
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
12
1291
356ec6a72974 Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents: 1155
diff changeset
13 function VolumeOperator(grid::EquidistantGrid, inner_stencil, closure_stencils, parity)
773
86bb3606b215 Make volume_operators() less restrictive in the type of collection of closure_stencils
Jonatan Werpers <jonatan@werpers.com>
parents: 627
diff changeset
14 return VolumeOperator(inner_stencil, Tuple(closure_stencils), size(grid), parity)
1369
ff64acfc1ec9 Add note about possibly removing a constructor for VolumeOperator
Jonatan Werpers <jonatan@werpers.com>
parents: 1365
diff changeset
15 end # TBD: Remove this function?
611
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
16
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
17 closure_size(::VolumeOperator{T,N,M}) where {T,N,M} = M
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
18
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
19 LazyTensors.range_size(op::VolumeOperator) = op.size
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
20 LazyTensors.domain_size(op::VolumeOperator) = op.size
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
21
946
469ed954b493 Allow volume_operator, boundary_operator, and constant_interior_scaling_operator to act on arbitrary arrays
Jonatan Werpers <jonatan@werpers.com>
parents: 818
diff changeset
22 function LazyTensors.apply(op::VolumeOperator, v::AbstractVector, i::Index{Lower})
611
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
23 return @inbounds apply_stencil(op.closure_stencils[Int(i)], v, Int(i))
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
24 end
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
25
946
469ed954b493 Allow volume_operator, boundary_operator, and constant_interior_scaling_operator to act on arbitrary arrays
Jonatan Werpers <jonatan@werpers.com>
parents: 818
diff changeset
26 function LazyTensors.apply(op::VolumeOperator, v::AbstractVector, i::Index{Interior})
611
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
27 return apply_stencil(op.inner_stencil, v, Int(i))
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
28 end
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
29
946
469ed954b493 Allow volume_operator, boundary_operator, and constant_interior_scaling_operator to act on arbitrary arrays
Jonatan Werpers <jonatan@werpers.com>
parents: 818
diff changeset
30 function LazyTensors.apply(op::VolumeOperator, v::AbstractVector, i::Index{Upper})
611
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
31 return @inbounds Int(op.parity)*apply_stencil_backwards(op.closure_stencils[op.size[1]-Int(i)+1], v, Int(i))
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
32 end
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
33
946
469ed954b493 Allow volume_operator, boundary_operator, and constant_interior_scaling_operator to act on arbitrary arrays
Jonatan Werpers <jonatan@werpers.com>
parents: 818
diff changeset
34 function LazyTensors.apply(op::VolumeOperator, v::AbstractVector, i)
611
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
35 r = getregion(i, closure_size(op), op.size[1])
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
36 return LazyTensors.apply(op, v, Index(i, r))
e71f2f81b5f8 NOT WORKING: Draft implementation of VolumeOperator and make SecondDerivative specialize it. Reformulate Laplace for the new SecondDerivative.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
37 end
1022
bbbc31953367 Introduce an inflate function in lazy tensors and use it in volume_operator and boundary_operator
Jonatan Werpers <jonatan@werpers.com>
parents: 946
diff changeset
38 # TODO: Move this to LazyTensors when we have the region communication down.