Mercurial > repos > public > sbplib_julia
diff 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 |
line wrap: on
line diff
--- a/src/BoundaryConditions/sat.jl Wed Dec 07 21:56:00 2022 +0100 +++ b/src/BoundaryConditions/sat.jl Tue Feb 07 21:55:07 2023 +0100 @@ -1,65 +1,41 @@ """ - sat_tensors(op, grid, bc::BoundaryCondition{T}, params...) + sat_tensors(op, grid, bc::BoundaryCondition, params...) -Returns the `LazyTensor`s used to construct a SAT for the SBP operator `op` on -`grid` associated with the boundary condition `bc`. +Returns the functions `closure(u)` and `penalty(g)` used to construct a SAT for the +`LazyTensor` operator `op` on `grid` associated with the boundary condition `bc`, +where g is the discretized data of `bc`. """ function sat_tensors end -# TODO: Docs must be more specific in what this function does... + """ sat(op, grid, bc::BoundaryCondition, params...) -Simultaneous-Approximation-Term for general BoundaryCondition bc. f = sat(op, grid, bc) returns -an anonymous function, such that f(t,u) is a `LazyTensorApplication` weakly imposing bc -at time t. +Simultaneous-Approximation-Term for a general `BoundaryCondition` `bc` to `LazyTensor` `op`. +The function returns a function `f`, where f(t,u)` returns a `LazyTensorApplication` +weakly imposing the boundary condition at time `t`, when added to `op*u`. + +`op` must implement the function `sat_tensors`. `f` is then constructed as +`f(t,u) = closure(u) + `penalty(g(t))`. """ function sat(op, grid, bc::BoundaryCondition, params...) closure, penalty = sat_tensors(op, grid, bc, params...) - data_array = discretize(data(bc),boundary_grid(grid, bc.id)) - return (t,u) -> closure(u) + penalty(data_array(t)) -end - -function sat(op, grid, bc::BoundaryCondition{ZeroBoundaryData}, params...) - closure = sat_tensors(op, grid, bc, params...) - return (t,u) -> closure(u) + g = discretize(data(bc),boundary_grid(grid, bc.id)) + return (t,u) -> closure(u) + penalty(g(t)) end -# """ -# sat(op, grid, bc::BoundaryCondition{SpaceDependentBoundaryData{T}}, params...) +""" + sat(op, grid, bc::BoundaryCondition{ZeroBoundaryData}, params...) -# Simultaneous-Approximation-Term for space-dependent boundary data. f = sat(op, grid, bc) returns -# an anonymous function, such that f(u) is a `LazyTensorApplication` weakly imposing the BC. -# """ -# function sat(op, grid, bc::BoundaryCondition{SpaceDependentBoundaryData{T}}, params...) where T -# closure, penalty = sat_tensors(op, grid, bc, params...) -# g = data(bc) -# return u -> closure(u) + penalty(g) -# end - -# """ -# sat(op, grid, bc::BoundaryCondition{SpaceDependentBoundaryData{T}}, params...) +Simultaneous-Approximation-Term for a general `BoundaryCondition` `bc` to `LazyTensor` `op`. +The function returns a function `f`, where f(t,u)` returns a `LazyTensorApplication` +weakly imposing a homogenous boundary condition, when added to `op*u`. -# Simultaneous-Approximation-Term for time-dependent boundary data. f = sat(op, grid, bc) returns -# an anonymous function, such that f(u,t) is a `LazyTensorApplication` weakly imposing the BC at time t. -# """ -# function sat(op, grid, bc::BoundaryCondition{TimeDependentBoundaryData{T}}, params...) where T -# closure, penalty = sat_tensors(op, grid, bc, params...) -# b_sz = size(boundary_grid(grid, bc.id)) -# b_vec = ones(eltype(grid), b_sz) -# g = data(bc) -# return (u,t) -> closure(u) + g(t)*penalty(b_vec) -# end - -# """ -# sat(op, grid, bc::BoundaryCondition{SpaceDependentBoundaryData{T}}, params...) - -# Simultaneous-Approximation-Term for space-time-dependent boundary data. f = sat(op, grid, bc) returns -# an anonymous function, such that f(u,t) is a `LazyTensorApplication` weakly imposing the BC at time t. -# """ -# function sat(op, grid, bc::BoundaryCondition{SpaceTimeDependentBoundaryData{T}}, params...) where T -# closure, penalty = sat_tensors(op, grid, bc, params...) -# g = data(bc) -# return (u,t) -> closure(u) + penalty(g(t)) -# end \ No newline at end of file +`op` must implement the function `sat_tensors`. `f` is then constructed as +`f(t,u) = closure(u)`. +""" +function sat(op, grid, bc::BoundaryCondition{ZeroBoundaryData}, params...) + closure = sat_tensors(op, grid, bc, params...) + return (t,u) -> closure(u) +end \ No newline at end of file