Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/boundaryops/boundary_operator.jl @ 1162:62aaed9cf76b feature/dissipation_operators
Merge default
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 29 Nov 2022 22:43:57 +0100 |
parents | 716e721ce3eb |
children | f1c2a4fa0ee1 1cc45207817e 102ebdaf7c11 |
comparison
equal
deleted
inserted
replaced
1098:6f51160c7ca7 | 1162:62aaed9cf76b |
---|---|
1 """ | |
2 boundary_operator(grid,closure_stencil,boundary) | |
3 | |
4 Creates a boundary operator on a `Dim`-dimensional grid for the | |
5 specified `boundary`. The action of the operator is determined by `closure_stencil`. | |
6 | |
7 When `Dim=1`, the corresponding `BoundaryOperator` tensor mapping is returned. | |
8 When `Dim>1`, the `BoundaryOperator` `op` is inflated by the outer product | |
9 of `IdentityTensors` in orthogonal coordinate directions, e.g for `Dim=3`, | |
10 the boundary restriction operator in the y-direction direction is `Ix⊗op⊗Iz`. | |
11 """ | |
12 function boundary_operator(grid::EquidistantGrid, closure_stencil, boundary::CartesianBoundary) | |
13 #TODO:Check that dim(boundary) <= Dim? | |
14 | |
15 d = dim(boundary) | |
16 op = BoundaryOperator(restrict(grid, d), closure_stencil, region(boundary)) | |
17 | |
18 # Create 1D IdentityTensors for each coordinate direction | |
19 one_d_grids = restrict.(Ref(grid), Tuple(1:dimension(grid))) | |
20 Is = IdentityTensor{eltype(grid)}.(size.(one_d_grids)) | |
21 | |
22 return LazyTensors.inflate(op, size(grid), d) | |
23 end | |
24 # TBD: Should the inflation happen here or should we remove this method and do it at the caller instead? | |
25 | |
26 """ | 1 """ |
27 BoundaryOperator{T,R,N} <: LazyTensor{T,0,1} | 2 BoundaryOperator{T,R,N} <: LazyTensor{T,0,1} |
28 | 3 |
29 Implements the boundary operator `op` for 1D as a `LazyTensor` | 4 Implements the boundary operator `op` for 1D as a `LazyTensor` |
30 | 5 |
35 struct BoundaryOperator{T,R<:Region,N} <: LazyTensor{T,0,1} | 10 struct BoundaryOperator{T,R<:Region,N} <: LazyTensor{T,0,1} |
36 stencil::Stencil{T,N} | 11 stencil::Stencil{T,N} |
37 size::Int | 12 size::Int |
38 end | 13 end |
39 | 14 |
40 BoundaryOperator{R}(stencil::Stencil{T,N}, size::Int) where {T,R,N} = BoundaryOperator{T,R,N}(stencil, size) | |
41 | |
42 """ | 15 """ |
43 BoundaryOperator(grid::EquidistantGrid{1}, closure_stencil, region) | 16 BoundaryOperator(grid::EquidistantGrid{1}, closure_stencil, region) |
44 | 17 |
45 Constructs the BoundaryOperator with stencil `closure_stencil` for a one-dimensional `grid`, restricting to | 18 Constructs the BoundaryOperator with stencil `closure_stencil` for a one-dimensional `grid`, restricting to |
46 to the boundary specified by `region`. | 19 to the boundary specified by `region`. |
49 return BoundaryOperator{T,typeof(region),N}(closure_stencil,size(grid)[1]) | 22 return BoundaryOperator{T,typeof(region),N}(closure_stencil,size(grid)[1]) |
50 end | 23 end |
51 | 24 |
52 """ | 25 """ |
53 closure_size(::BoundaryOperator) | 26 closure_size(::BoundaryOperator) |
27 | |
54 The size of the closure stencil. | 28 The size of the closure stencil. |
55 """ | 29 """ |
56 closure_size(::BoundaryOperator{T,R,N}) where {T,R,N} = N | 30 closure_size(::BoundaryOperator{T,R,N}) where {T,R,N} = N |
57 | 31 |
58 LazyTensors.range_size(op::BoundaryOperator) = () | 32 LazyTensors.range_size(op::BoundaryOperator) = () |