comparison src/BoundaryConditions/sat.jl @ 1167:fd80e9a0ef99 feature/boundary_conditions

Make use of discretize in sat functions
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Wed, 07 Dec 2022 21:56:00 +0100
parents 05b1d6fd6401
children ea2e8254820a
comparison
equal deleted inserted replaced
1164:d26aef8a5987 1167:fd80e9a0ef99
4 Returns the `LazyTensor`s used to construct a SAT for the SBP operator `op` on 4 Returns the `LazyTensor`s used to construct a SAT for the SBP operator `op` on
5 `grid` associated with the boundary condition `bc`. 5 `grid` associated with the boundary condition `bc`.
6 """ 6 """
7 function sat_tensors end 7 function sat_tensors end
8 8
9 # TODO: Docs must be more specific in what this function does...
9 """ 10 """
10 sat(op, grid, bc::BoundaryCondition{ConstantBoundaryData{T}}, params...) 11 sat(op, grid, bc::BoundaryCondition, params...)
11 12
12 Simultaneous-Approximation-Term for constant boundary data. f = sat(op, grid, bc) returns 13 Simultaneous-Approximation-Term for general BoundaryCondition bc. f = sat(op, grid, bc) returns
13 an anonymous function, such that f(u) is a `LazyTensorApplication` weakly imposing the BC. 14 an anonymous function, such that f(t,u) is a `LazyTensorApplication` weakly imposing bc
15 at time t.
14 """ 16 """
15 function sat(op, grid, bc::BoundaryCondition{ConstantBoundaryData{T}}, params...) where T 17 function sat(op, grid, bc::BoundaryCondition, params...)
16 closure, penalty = sat_tensors(op, grid, bc, params...) 18 closure, penalty = sat_tensors(op, grid, bc, params...)
17 b_sz = size(boundary_grid(grid, bc.id)) 19 data_array = discretize(data(bc),boundary_grid(grid, bc.id))
18 g = fill(data(bc), b_sz) 20 return (t,u) -> closure(u) + penalty(data_array(t))
19 if iszero(g)
20 return u -> closure(u)
21 else
22 return u -> closure(u) + penalty(g)
23 end
24 end 21 end
25 22
26 """ 23 function sat(op, grid, bc::BoundaryCondition{ZeroBoundaryData}, params...)
27 sat(op, grid, bc::BoundaryCondition{SpaceDependentBoundaryData{T}}, params...) 24 closure = sat_tensors(op, grid, bc, params...)
28 25 return (t,u) -> closure(u)
29 Simultaneous-Approximation-Term for space-dependent boundary data. f = sat(op, grid, bc) returns
30 an anonymous function, such that f(u) is a `LazyTensorApplication` weakly imposing the BC.
31 """
32 function sat(op, grid, bc::BoundaryCondition{SpaceDependentBoundaryData{T}}, params...) where T
33 closure, penalty = sat_tensors(op, grid, bc, params...)
34 g = data(bc)
35 return u -> closure(u) + penalty(g)
36 end 26 end
37 27
38 """
39 sat(op, grid, bc::BoundaryCondition{SpaceDependentBoundaryData{T}}, params...)
40 28
41 Simultaneous-Approximation-Term for time-dependent boundary data. f = sat(op, grid, bc) returns 29 # """
42 an anonymous function, such that f(u,t) is a `LazyTensorApplication` weakly imposing the BC at time t. 30 # sat(op, grid, bc::BoundaryCondition{SpaceDependentBoundaryData{T}}, params...)
43 """
44 function sat(op, grid, bc::BoundaryCondition{TimeDependentBoundaryData{T}}, params...) where T
45 closure, penalty = sat_tensors(op, grid, bc, params...)
46 b_sz = size(boundary_grid(grid, bc.id))
47 b_vec = ones(eltype(grid), b_sz)
48 g = data(bc)
49 return (u,t) -> closure(u) + g(t)*penalty(b_vec)
50 end
51 31
52 """ 32 # Simultaneous-Approximation-Term for space-dependent boundary data. f = sat(op, grid, bc) returns
53 sat(op, grid, bc::BoundaryCondition{SpaceDependentBoundaryData{T}}, params...) 33 # an anonymous function, such that f(u) is a `LazyTensorApplication` weakly imposing the BC.
34 # """
35 # function sat(op, grid, bc::BoundaryCondition{SpaceDependentBoundaryData{T}}, params...) where T
36 # closure, penalty = sat_tensors(op, grid, bc, params...)
37 # g = data(bc)
38 # return u -> closure(u) + penalty(g)
39 # end
54 40
55 Simultaneous-Approximation-Term for space-time-dependent boundary data. f = sat(op, grid, bc) returns 41 # """
56 an anonymous function, such that f(u,t) is a `LazyTensorApplication` weakly imposing the BC at time t. 42 # sat(op, grid, bc::BoundaryCondition{SpaceDependentBoundaryData{T}}, params...)
57 """ 43
58 function sat(op, grid, bc::BoundaryCondition{SpaceTimeDependentBoundaryData{T}}, params...) where T 44 # Simultaneous-Approximation-Term for time-dependent boundary data. f = sat(op, grid, bc) returns
59 closure, penalty = sat_tensors(op, grid, bc, params...) 45 # an anonymous function, such that f(u,t) is a `LazyTensorApplication` weakly imposing the BC at time t.
60 g = data(bc) 46 # """
61 return (u,t) -> closure(u) + penalty(g(t)) 47 # function sat(op, grid, bc::BoundaryCondition{TimeDependentBoundaryData{T}}, params...) where T
62 end 48 # closure, penalty = sat_tensors(op, grid, bc, params...)
49 # b_sz = size(boundary_grid(grid, bc.id))
50 # b_vec = ones(eltype(grid), b_sz)
51 # g = data(bc)
52 # return (u,t) -> closure(u) + g(t)*penalty(b_vec)
53 # end
54
55 # """
56 # sat(op, grid, bc::BoundaryCondition{SpaceDependentBoundaryData{T}}, params...)
57
58 # Simultaneous-Approximation-Term for space-time-dependent boundary data. f = sat(op, grid, bc) returns
59 # an anonymous function, such that f(u,t) is a `LazyTensorApplication` weakly imposing the BC at time t.
60 # """
61 # function sat(op, grid, bc::BoundaryCondition{SpaceTimeDependentBoundaryData{T}}, params...) where T
62 # closure, penalty = sat_tensors(op, grid, bc, params...)
63 # g = data(bc)
64 # return (u,t) -> closure(u) + penalty(g(t))
65 # end