Mercurial > repos > public > sbplib_julia
comparison src/BoundaryConditions/sat.jl @ 1217:ea2e8254820a feature/boundary_conditions
Update docstrings and start implementing tests
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Tue, 07 Feb 2023 21:55:07 +0100 |
parents | fd80e9a0ef99 |
children | 35840a0681d1 |
comparison
equal
deleted
inserted
replaced
1167:fd80e9a0ef99 | 1217:ea2e8254820a |
---|---|
1 """ | 1 """ |
2 sat_tensors(op, grid, bc::BoundaryCondition{T}, params...) | 2 sat_tensors(op, grid, bc::BoundaryCondition, params...) |
3 | 3 |
4 Returns the `LazyTensor`s used to construct a SAT for the SBP operator `op` on | 4 Returns the functions `closure(u)` and `penalty(g)` used to construct a SAT for the |
5 `grid` associated with the boundary condition `bc`. | 5 `LazyTensor` operator `op` on `grid` associated with the boundary condition `bc`, |
6 where g is the discretized data of `bc`. | |
6 """ | 7 """ |
7 function sat_tensors end | 8 function sat_tensors end |
8 | 9 |
9 # TODO: Docs must be more specific in what this function does... | 10 |
10 """ | 11 """ |
11 sat(op, grid, bc::BoundaryCondition, params...) | 12 sat(op, grid, bc::BoundaryCondition, params...) |
12 | 13 |
13 Simultaneous-Approximation-Term for general BoundaryCondition bc. f = sat(op, grid, bc) returns | 14 Simultaneous-Approximation-Term for a general `BoundaryCondition` `bc` to `LazyTensor` `op`. |
14 an anonymous function, such that f(t,u) is a `LazyTensorApplication` weakly imposing bc | 15 The function returns a function `f`, where f(t,u)` returns a `LazyTensorApplication` |
15 at time t. | 16 weakly imposing the boundary condition at time `t`, when added to `op*u`. |
17 | |
18 `op` must implement the function `sat_tensors`. `f` is then constructed as | |
19 `f(t,u) = closure(u) + `penalty(g(t))`. | |
16 """ | 20 """ |
17 function sat(op, grid, bc::BoundaryCondition, params...) | 21 function sat(op, grid, bc::BoundaryCondition, params...) |
18 closure, penalty = sat_tensors(op, grid, bc, params...) | 22 closure, penalty = sat_tensors(op, grid, bc, params...) |
19 data_array = discretize(data(bc),boundary_grid(grid, bc.id)) | 23 g = discretize(data(bc),boundary_grid(grid, bc.id)) |
20 return (t,u) -> closure(u) + penalty(data_array(t)) | 24 return (t,u) -> closure(u) + penalty(g(t)) |
21 end | 25 end |
22 | 26 |
27 | |
28 """ | |
29 sat(op, grid, bc::BoundaryCondition{ZeroBoundaryData}, params...) | |
30 | |
31 Simultaneous-Approximation-Term for a general `BoundaryCondition` `bc` to `LazyTensor` `op`. | |
32 The function returns a function `f`, where f(t,u)` returns a `LazyTensorApplication` | |
33 weakly imposing a homogenous boundary condition, when added to `op*u`. | |
34 | |
35 `op` must implement the function `sat_tensors`. `f` is then constructed as | |
36 `f(t,u) = closure(u)`. | |
37 """ | |
23 function sat(op, grid, bc::BoundaryCondition{ZeroBoundaryData}, params...) | 38 function sat(op, grid, bc::BoundaryCondition{ZeroBoundaryData}, params...) |
24 closure = sat_tensors(op, grid, bc, params...) | 39 closure = sat_tensors(op, grid, bc, params...) |
25 return (t,u) -> closure(u) | 40 return (t,u) -> closure(u) |
26 end | 41 end |
27 | |
28 | |
29 # """ | |
30 # sat(op, grid, bc::BoundaryCondition{SpaceDependentBoundaryData{T}}, params...) | |
31 | |
32 # Simultaneous-Approximation-Term for space-dependent boundary data. f = sat(op, grid, bc) returns | |
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 | |
40 | |
41 # """ | |
42 # sat(op, grid, bc::BoundaryCondition{SpaceDependentBoundaryData{T}}, params...) | |
43 | |
44 # Simultaneous-Approximation-Term for time-dependent boundary data. f = sat(op, grid, bc) returns | |
45 # an anonymous function, such that f(u,t) is a `LazyTensorApplication` weakly imposing the BC at time t. | |
46 # """ | |
47 # function sat(op, grid, bc::BoundaryCondition{TimeDependentBoundaryData{T}}, params...) where T | |
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 |