annotate src/SbpOperators/boundaryops/boundary_restriction.jl @ 516:f932af8c1e56 feature/boundary_ops

Remove obsolete type.
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Tue, 24 Nov 2020 15:30:16 +0100
parents d55008f5e2f3
children 2edacece1637
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
515
d55008f5e2f3 Fix the range of the BoundaryRestriction tensor mapping (the range is zero for the 1D operator). Add some documentation and todos.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 514
diff changeset
1 """
d55008f5e2f3 Fix the range of the BoundaryRestriction tensor mapping (the range is zero for the 1D operator). Add some documentation and todos.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 514
diff changeset
2 boundary_restriction(grid,closureStencil,boundary)
d55008f5e2f3 Fix the range of the BoundaryRestriction tensor mapping (the range is zero for the 1D operator). Add some documentation and todos.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 514
diff changeset
3
d55008f5e2f3 Fix the range of the BoundaryRestriction tensor mapping (the range is zero for the 1D operator). Add some documentation and todos.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 514
diff changeset
4 Creates a BoundaryRestriction operator for the specified boundary
d55008f5e2f3 Fix the range of the BoundaryRestriction tensor mapping (the range is zero for the 1D operator). Add some documentation and todos.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 514
diff changeset
5 """
514
14e722e8607d Clean up constructors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 513
diff changeset
6 function boundary_restriction(grid::EquidistantGrid{1,T}, closureStencil::Stencil{T,M}, boundary::CartesianBoundary{1}) where {T,M}
14e722e8607d Clean up constructors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 513
diff changeset
7 r = region(boundary)
14e722e8607d Clean up constructors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 513
diff changeset
8 return e = BoundaryRestriction(grid, closureStencil, r())
14e722e8607d Clean up constructors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 513
diff changeset
9 end
14e722e8607d Clean up constructors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 513
diff changeset
10
14e722e8607d Clean up constructors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 513
diff changeset
11 function boundary_restriction(grid::EquidistantGrid{2,T}, closureStencil::Stencil{T,M}, boundary::CartesianBoundary{1}) where {T,M}
512
5a8cfcc0765d Sketch on boundary_restriction function in 2D, returning an inflated BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 511
diff changeset
12 r = region(boundary)
514
14e722e8607d Clean up constructors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 513
diff changeset
13 e = BoundaryRestriction(restrict(grid, 1), closureStencil, r())
14e722e8607d Clean up constructors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 513
diff changeset
14 I = IdentityMapping{T}(size(restrict(grid,2)))
14e722e8607d Clean up constructors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 513
diff changeset
15 return e⊗I
512
5a8cfcc0765d Sketch on boundary_restriction function in 2D, returning an inflated BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 511
diff changeset
16 end
514
14e722e8607d Clean up constructors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 513
diff changeset
17
14e722e8607d Clean up constructors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 513
diff changeset
18 function boundary_restriction(grid::EquidistantGrid{2,T}, closureStencil::Stencil{T,M}, boundary::CartesianBoundary{2}) where {T,M}
14e722e8607d Clean up constructors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 513
diff changeset
19 r = region(boundary)
14e722e8607d Clean up constructors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 513
diff changeset
20 e = BoundaryRestriction(restrict(grid, 2), closureStencil, r())
14e722e8607d Clean up constructors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 513
diff changeset
21 I = IdentityMapping{T}(size(restrict(grid,1)))
14e722e8607d Clean up constructors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 513
diff changeset
22 return I⊗e
14e722e8607d Clean up constructors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 513
diff changeset
23 end
512
5a8cfcc0765d Sketch on boundary_restriction function in 2D, returning an inflated BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 511
diff changeset
24 export boundary_restriction
5a8cfcc0765d Sketch on boundary_restriction function in 2D, returning an inflated BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 511
diff changeset
25
510
db64cfe4d9de Start sketching on 1D boundary restriction operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
26 """
515
d55008f5e2f3 Fix the range of the BoundaryRestriction tensor mapping (the range is zero for the 1D operator). Add some documentation and todos.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 514
diff changeset
27 BoundaryRestriction{T,N,R} <: TensorMapping{T,0,1}
510
db64cfe4d9de Start sketching on 1D boundary restriction operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
28
db64cfe4d9de Start sketching on 1D boundary restriction operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
29 Implements the boundary operator `e` as a TensorMapping
db64cfe4d9de Start sketching on 1D boundary restriction operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
30 """
515
d55008f5e2f3 Fix the range of the BoundaryRestriction tensor mapping (the range is zero for the 1D operator). Add some documentation and todos.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 514
diff changeset
31 struct BoundaryRestriction{T,M,R<:Region} <: TensorMapping{T,0,1}
511
f5f3b832f9c4 Fix boundschecking for BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 510
diff changeset
32 stencil::Stencil{T,M}
510
db64cfe4d9de Start sketching on 1D boundary restriction operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
33 size::NTuple{1,Int}
db64cfe4d9de Start sketching on 1D boundary restriction operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
34 end
db64cfe4d9de Start sketching on 1D boundary restriction operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
35 export BoundaryRestriction
db64cfe4d9de Start sketching on 1D boundary restriction operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
36
514
14e722e8607d Clean up constructors
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 513
diff changeset
37 function BoundaryRestriction(grid::EquidistantGrid{1,T}, closureStencil::Stencil{T,M}, region::Region) where {T,M,R}
513
547639572208 Get some kind of tested working implementation.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 512
diff changeset
38 return BoundaryRestriction{T,M,typeof(region)}(closureStencil,size(grid))
510
db64cfe4d9de Start sketching on 1D boundary restriction operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
39 end
db64cfe4d9de Start sketching on 1D boundary restriction operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
40
515
d55008f5e2f3 Fix the range of the BoundaryRestriction tensor mapping (the range is zero for the 1D operator). Add some documentation and todos.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 514
diff changeset
41 LazyTensors.range_size(e::BoundaryRestriction) = (0,)
510
db64cfe4d9de Start sketching on 1D boundary restriction operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
42 LazyTensors.domain_size(e::BoundaryRestriction) = e.size
db64cfe4d9de Start sketching on 1D boundary restriction operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
43
515
d55008f5e2f3 Fix the range of the BoundaryRestriction tensor mapping (the range is zero for the 1D operator). Add some documentation and todos.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 514
diff changeset
44 # TODO: Currently not working.
d55008f5e2f3 Fix the range of the BoundaryRestriction tensor mapping (the range is zero for the 1D operator). Add some documentation and todos.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 514
diff changeset
45 # We need to handle getindex for LazyTensorMappingApplication such that we pass more #indices than the
d55008f5e2f3 Fix the range of the BoundaryRestriction tensor mapping (the range is zero for the 1D operator). Add some documentation and todos.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 514
diff changeset
46 # range size of the TensorMapping. Or we need to be able to handle the case where we dont pass any index, for
d55008f5e2f3 Fix the range of the BoundaryRestriction tensor mapping (the range is zero for the 1D operator). Add some documentation and todos.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 514
diff changeset
47 # 0-dimensional tensormappings.
511
f5f3b832f9c4 Fix boundschecking for BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 510
diff changeset
48 " Restricts a grid function v on a grid of size m to the scalar element v[1]"
f5f3b832f9c4 Fix boundschecking for BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 510
diff changeset
49 function LazyTensors.apply(e::BoundaryRestriction{T,M,Lower}, v::AbstractVector{T}, i::Index{Lower}) where {T,M}
f5f3b832f9c4 Fix boundschecking for BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 510
diff changeset
50 @boundscheck if Int(i)!=1
510
db64cfe4d9de Start sketching on 1D boundary restriction operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
51 throw(BoundsError())
db64cfe4d9de Start sketching on 1D boundary restriction operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
52 end
511
f5f3b832f9c4 Fix boundschecking for BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 510
diff changeset
53 apply_stencil(e.stencil,v,Int(i))
510
db64cfe4d9de Start sketching on 1D boundary restriction operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
54 end
db64cfe4d9de Start sketching on 1D boundary restriction operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
55
511
f5f3b832f9c4 Fix boundschecking for BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 510
diff changeset
56 " Restricts a grid function v on a grid of size m to the scalar element v[m]"
f5f3b832f9c4 Fix boundschecking for BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 510
diff changeset
57 function LazyTensors.apply(e::BoundaryRestriction{T,M,Upper}, v::AbstractVector{T}, i::Index{Upper}) where {T,M}
f5f3b832f9c4 Fix boundschecking for BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 510
diff changeset
58 @boundscheck if Int(i) != e.size[1]
510
db64cfe4d9de Start sketching on 1D boundary restriction operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
59 throw(BoundsError())
db64cfe4d9de Start sketching on 1D boundary restriction operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
60 end
511
f5f3b832f9c4 Fix boundschecking for BoundaryRestriction
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 510
diff changeset
61 apply_stencil_backwards(e.stencil,v,Int(i))
510
db64cfe4d9de Start sketching on 1D boundary restriction operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
62 end
db64cfe4d9de Start sketching on 1D boundary restriction operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
63
db64cfe4d9de Start sketching on 1D boundary restriction operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
64 " Transpose of a restriction is an inflation or prolongation.
db64cfe4d9de Start sketching on 1D boundary restriction operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
65 Inflates the scalar (1-element) vector to a vector of size of the grid"
515
d55008f5e2f3 Fix the range of the BoundaryRestriction tensor mapping (the range is zero for the 1D operator). Add some documentation and todos.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 514
diff changeset
66 function LazyTensors.apply_transpose(e::BoundaryRestriction{T,M,Lower}, v::AbstractArray{T,0}, i) where {T,M}
510
db64cfe4d9de Start sketching on 1D boundary restriction operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
67 @boundscheck if !(0 < Int(i) <= e.size[1])
db64cfe4d9de Start sketching on 1D boundary restriction operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
68 throw(BoundsError())
db64cfe4d9de Start sketching on 1D boundary restriction operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
69 end
515
d55008f5e2f3 Fix the range of the BoundaryRestriction tensor mapping (the range is zero for the 1D operator). Add some documentation and todos.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 514
diff changeset
70 return e.stencil[Int(i)-1]*v[]
510
db64cfe4d9de Start sketching on 1D boundary restriction operators.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
71 end
513
547639572208 Get some kind of tested working implementation.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 512
diff changeset
72
547639572208 Get some kind of tested working implementation.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 512
diff changeset
73 " Transpose of a restriction is an inflation or prolongation.
547639572208 Get some kind of tested working implementation.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 512
diff changeset
74 Inflates the scalar (1-element) vector to a vector of size of the grid"
515
d55008f5e2f3 Fix the range of the BoundaryRestriction tensor mapping (the range is zero for the 1D operator). Add some documentation and todos.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 514
diff changeset
75 function LazyTensors.apply_transpose(e::BoundaryRestriction{T,M,Upper}, v::AbstractArray{T,0}, i) where {T,M}
513
547639572208 Get some kind of tested working implementation.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 512
diff changeset
76 @boundscheck if !(0 < Int(i) <= e.size[1])
547639572208 Get some kind of tested working implementation.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 512
diff changeset
77 throw(BoundsError())
547639572208 Get some kind of tested working implementation.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 512
diff changeset
78 end
515
d55008f5e2f3 Fix the range of the BoundaryRestriction tensor mapping (the range is zero for the 1D operator). Add some documentation and todos.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 514
diff changeset
79 return e.stencil[e.size[1] - Int(i)]*v[]
513
547639572208 Get some kind of tested working implementation.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 512
diff changeset
80 end