Mercurial > repos > public > sbplib_julia
comparison src/BoundaryConditions/sat.jl @ 1135:05b1d6fd6401 feature/boundary_conditions
Add functions for constructing SATs
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Tue, 11 Oct 2022 18:15:47 +0200 |
parents | |
children | fd80e9a0ef99 |
comparison
equal
deleted
inserted
replaced
1134:667e9c588f23 | 1135:05b1d6fd6401 |
---|---|
1 """ | |
2 sat_tensors(op, grid, bc::BoundaryCondition{T}, params...) | |
3 | |
4 Returns the `LazyTensor`s used to construct a SAT for the SBP operator `op` on | |
5 `grid` associated with the boundary condition `bc`. | |
6 """ | |
7 function sat_tensors end | |
8 | |
9 """ | |
10 sat(op, grid, bc::BoundaryCondition{ConstantBoundaryData{T}}, params...) | |
11 | |
12 Simultaneous-Approximation-Term for constant boundary data. f = sat(op, grid, bc) returns | |
13 an anonymous function, such that f(u) is a `LazyTensorApplication` weakly imposing the BC. | |
14 """ | |
15 function sat(op, grid, bc::BoundaryCondition{ConstantBoundaryData{T}}, params...) where T | |
16 closure, penalty = sat_tensors(op, grid, bc, params...) | |
17 b_sz = size(boundary_grid(grid, bc.id)) | |
18 g = fill(data(bc), b_sz) | |
19 if iszero(g) | |
20 return u -> closure(u) | |
21 else | |
22 return u -> closure(u) + penalty(g) | |
23 end | |
24 end | |
25 | |
26 """ | |
27 sat(op, grid, bc::BoundaryCondition{SpaceDependentBoundaryData{T}}, params...) | |
28 | |
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 | |
37 | |
38 """ | |
39 sat(op, grid, bc::BoundaryCondition{SpaceDependentBoundaryData{T}}, params...) | |
40 | |
41 Simultaneous-Approximation-Term for time-dependent boundary data. f = sat(op, grid, bc) returns | |
42 an anonymous function, such that f(u,t) is a `LazyTensorApplication` weakly imposing the BC at time t. | |
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 | |
52 """ | |
53 sat(op, grid, bc::BoundaryCondition{SpaceDependentBoundaryData{T}}, params...) | |
54 | |
55 Simultaneous-Approximation-Term for space-time-dependent boundary data. f = sat(op, grid, bc) returns | |
56 an anonymous function, such that f(u,t) is a `LazyTensorApplication` weakly imposing the BC at time t. | |
57 """ | |
58 function sat(op, grid, bc::BoundaryCondition{SpaceTimeDependentBoundaryData{T}}, params...) where T | |
59 closure, penalty = sat_tensors(op, grid, bc, params...) | |
60 g = data(bc) | |
61 return (u,t) -> closure(u) + penalty(g(t)) | |
62 end |