annotate src/SbpOperators/volumeops/volume_operator.jl @ 2015:5c2448d6a201 feature/grids/geometry_functions tip

Structure tests a bit more
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 09 May 2025 15:57:38 +0200
parents 0656b46a1a74
children
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}}
1761
0656b46a1a74 Simplify size type in VolumeOperator
Jonatan Werpers <jonatan@werpers.com>
parents: 1760
diff changeset
9 size::Int
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
10 parity::Parity
1760
aba2ce166546 Resolve unbound paramater in VolumeOperator
Jonatan Werpers <jonatan@werpers.com>
parents: 1369
diff changeset
11
1761
0656b46a1a74 Simplify size type in VolumeOperator
Jonatan Werpers <jonatan@werpers.com>
parents: 1760
diff changeset
12 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}
1760
aba2ce166546 Resolve unbound paramater in VolumeOperator
Jonatan Werpers <jonatan@werpers.com>
parents: 1369
diff changeset
13 M = length(closure_stencils)
aba2ce166546 Resolve unbound paramater in VolumeOperator
Jonatan Werpers <jonatan@werpers.com>
parents: 1369
diff changeset
14 return new{T,N,M,K}(inner_stencil, closure_stencils, size, parity)
aba2ce166546 Resolve unbound paramater in VolumeOperator
Jonatan Werpers <jonatan@werpers.com>
parents: 1369
diff changeset
15 end
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 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
17
1291
356ec6a72974 Implement changes in SbpOperators
Jonatan Werpers <jonatan@werpers.com>
parents: 1155
diff changeset
18 function VolumeOperator(grid::EquidistantGrid, inner_stencil, closure_stencils, parity)
1761
0656b46a1a74 Simplify size type in VolumeOperator
Jonatan Werpers <jonatan@werpers.com>
parents: 1760
diff changeset
19 return VolumeOperator(inner_stencil, Tuple(closure_stencils), size(grid,1), parity)
1369
ff64acfc1ec9 Add note about possibly removing a constructor for VolumeOperator
Jonatan Werpers <jonatan@werpers.com>
parents: 1365
diff changeset
20 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
21
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
22 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
23
1761
0656b46a1a74 Simplify size type in VolumeOperator
Jonatan Werpers <jonatan@werpers.com>
parents: 1760
diff changeset
24 LazyTensors.range_size(op::VolumeOperator) = (op.size,)
0656b46a1a74 Simplify size type in VolumeOperator
Jonatan Werpers <jonatan@werpers.com>
parents: 1760
diff changeset
25 LazyTensors.domain_size(op::VolumeOperator) = (op.size,)
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
26
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
27 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
28 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
29 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
30
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
31 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
32 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
33 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
34
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
35 function LazyTensors.apply(op::VolumeOperator, v::AbstractVector, i::Index{Upper})
1761
0656b46a1a74 Simplify size type in VolumeOperator
Jonatan Werpers <jonatan@werpers.com>
parents: 1760
diff changeset
36 return @inbounds Int(op.parity)*apply_stencil_backwards(op.closure_stencils[op.size-Int(i)+1], v, Int(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
37 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
38
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
39 function LazyTensors.apply(op::VolumeOperator, v::AbstractVector, i)
1761
0656b46a1a74 Simplify size type in VolumeOperator
Jonatan Werpers <jonatan@werpers.com>
parents: 1760
diff changeset
40 r = getregion(i, closure_size(op), op.size)
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
41 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
42 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
43 # TODO: Move this to LazyTensors when we have the region communication down.