Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/volumeops/laplace/laplace.jl @ 755:36adc15d3935 feature/laplace_opset
Reduce the number of type perameters used by Laplace.
| author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
|---|---|
| date | Sun, 28 Mar 2021 15:48:06 +0200 |
| parents | dc38e57ebd1b |
| children | 1970ebceabe4 |
comparison
equal
deleted
inserted
replaced
| 754:dc38e57ebd1b | 755:36adc15d3935 |
|---|---|
| 1 """ | 1 """ |
| 2 Laplace{T, Dim, ...} <: TensorMapping{T,Dim,Dim} | 2 Laplace{T, Dim, TMdiffop} <: TensorMapping{T,Dim,Dim} |
| 3 Laplace(grid::AbstractGrid, fn; order) | 3 Laplace(grid::AbstractGrid, fn; order) |
| 4 | 4 |
| 5 Implements the Laplace operator, approximating ∑d²/xᵢ² , i = 1,...,`Dim` as a | 5 Implements the Laplace operator, approximating ∑d²/xᵢ² , i = 1,...,`Dim` as a |
| 6 `TensorMapping`. Additionally, `Laplace` stores the inner product and boundary | 6 `TensorMapping`. Additionally, `Laplace` stores the inner product and boundary |
| 7 operators relevant for constructing a SBP finite difference scheme as `TensorMapping`s. | 7 operators relevant for constructing a SBP finite difference scheme as `TensorMapping`s. |
| 8 | 8 |
| 9 Laplace(grid, fn; order) creates the Laplace operator defined on `grid`, | 9 Laplace(grid, fn; order) creates the Laplace operator defined on `grid`, |
| 10 where the operators are read from TOML. The differential operator is created | 10 where the operators are read from TOML. The differential operator is created |
| 11 using `laplace(grid::AbstractGrid,...)`. | 11 using `laplace(grid::AbstractGrid,...)`. |
| 12 | |
| 13 Note that all properties of Laplace, excluding the Differential operator `D`, are | |
| 14 abstract types. For performance reasons, they should therefore be | |
| 15 accessed via the provided getter functions (e.g `inner_product(::Laplace)`). | |
| 16 | |
| 12 """ | 17 """ |
| 13 struct Laplace{T, Dim, Rb, TMdiffop<:TensorMapping{T,Dim,Dim}, # Differential operator | 18 struct Laplace{T, Dim, TMdiffop<:TensorMapping{T,Dim,Dim}} <: TensorMapping{T,Dim,Dim} |
| 14 TMipop<:TensorMapping{T,Dim,Dim}, # Inner product operator | |
| 15 TMbop<:TensorMapping{T,Rb,Dim}, # Boundary operator | |
| 16 TMbqop<:TensorMapping{T,Rb,Rb}, # Boundary quadrature | |
| 17 BID<:BoundaryIdentifier} <: TensorMapping{T,Dim,Dim} | |
| 18 D::TMdiffop # Differential operator | 19 D::TMdiffop # Differential operator |
| 19 H::TMipop # Inner product operator | 20 H::TensorMapping # Inner product operator |
| 20 H_inv::TMipop # Inverse inner product operator | 21 H_inv::TensorMapping # Inverse inner product operator |
| 21 e::StaticDict{BID,TMbop} # Boundary restriction operators | 22 e::StaticDict{<:BoundaryIdentifier,<:TensorMapping} # Boundary restriction operators. |
| 22 d::StaticDict{BID,TMbop} # Normal derivative operators | 23 d::StaticDict{<:BoundaryIdentifier,<:TensorMapping} # Normal derivative operators |
| 23 H_boundary::StaticDict{BID,TMbqop} # Boundary quadrature operators | 24 H_boundary::StaticDict{<:BoundaryIdentifier,<:TensorMapping} # Boundary quadrature operators # TODO: Boundary inner product? |
| 24 end | 25 end |
| 25 export Laplace | 26 export Laplace |
| 26 | 27 |
| 27 function Laplace(grid::AbstractGrid, fn; order) | 28 function Laplace(grid::AbstractGrid, fn; order) |
| 28 # TODO: Removed once we can construct the volume and | 29 # TODO: Removed once we can construct the volume and |
| 48 Hᵧ_pairs = ntuple(i -> ids[i] => inner_product(boundary_grid(grid,ids[i]),H_closure_stencils),n_ids) | 49 Hᵧ_pairs = ntuple(i -> ids[i] => inner_product(boundary_grid(grid,ids[i]),H_closure_stencils),n_ids) |
| 49 | 50 |
| 50 return Laplace(Δ, H, H⁻¹, StaticDict(e_pairs), StaticDict(d_pairs), StaticDict(Hᵧ_pairs)) | 51 return Laplace(Δ, H, H⁻¹, StaticDict(e_pairs), StaticDict(d_pairs), StaticDict(Hᵧ_pairs)) |
| 51 end | 52 end |
| 52 | 53 |
| 54 | |
| 55 Base.show(io::IO, L::Laplace{T, Dim}) where {T,Dim} = print(io, "Laplace{$T, $Dim}(", L.D, L.H, L.H_inv, L.e, L.d, L.H_boundary, ")") | |
| 56 | |
| 53 LazyTensors.range_size(L::Laplace) = LazyTensors.range_size(L.D) | 57 LazyTensors.range_size(L::Laplace) = LazyTensors.range_size(L.D) |
| 54 LazyTensors.domain_size(L::Laplace) = LazyTensors.domain_size(L.D) | 58 LazyTensors.domain_size(L::Laplace) = LazyTensors.domain_size(L.D) |
| 55 LazyTensors.apply(L::Laplace, v::AbstractArray, I...) = LazyTensors.apply(L.D,v,I...) | 59 LazyTensors.apply(L::Laplace, v::AbstractArray, I...) = LazyTensors.apply(L.D,v,I...) |
| 56 | 60 |
| 61 | |
| 62 """ | |
| 63 inner_product(L::Lapalace) | |
| 64 | |
| 65 Returns the inner product operator associated with `L` | |
| 66 | |
| 67 """ | |
| 57 inner_product(L::Laplace) = L.H | 68 inner_product(L::Laplace) = L.H |
| 58 export inner_product | 69 export inner_product |
| 70 | |
| 71 | |
| 72 """ | |
| 73 inverse_inner_product(L::Lapalace) | |
| 74 | |
| 75 Returns the inverse of the inner product operator associated with `L` | |
| 76 | |
| 77 """ | |
| 59 inverse_inner_product(L::Laplace) = L.H_inv | 78 inverse_inner_product(L::Laplace) = L.H_inv |
| 60 export inverse_inner_product | 79 export inverse_inner_product |
| 80 | |
| 81 | |
| 82 """ | |
| 83 boundary_restriction(L::Lapalace,id::BoundaryIdentifier) | |
| 84 boundary_restriction(L::Lapalace,ids::NTuple{N,BoundaryIdentifier}) | |
| 85 boundary_restriction(L::Lapalace,ids...) | |
| 86 | |
| 87 Returns boundary restriction operator(s) associated with `L` for the boundary(s) | |
| 88 identified by id(s). | |
| 89 | |
| 90 """ | |
| 61 boundary_restriction(L::Laplace,id::BoundaryIdentifier) = L.e[id] | 91 boundary_restriction(L::Laplace,id::BoundaryIdentifier) = L.e[id] |
| 62 boundary_restriction(L::Laplace,ids::NTuple{N,BoundaryIdentifier}) where N = ntuple(i->L.e[ids[i]],N) | 92 boundary_restriction(L::Laplace,ids::NTuple{N,BoundaryIdentifier}) where N = ntuple(i->L.e[ids[i]],N) |
| 63 boundary_restriction(L::Laplace,ids::Vararg{BoundaryIdentifier,N}) where N = ntuple(i->L.e[ids[i]],N) | 93 boundary_restriction(L::Laplace,ids::Vararg{BoundaryIdentifier,N}) where N = ntuple(i->L.e[ids[i]],N) |
| 64 export boundary_restriction | 94 export boundary_restriction |
| 95 | |
| 96 | |
| 97 """ | |
| 98 normal_derivative(L::Lapalace,id::BoundaryIdentifier) | |
| 99 normal_derivative(L::Lapalace,ids::NTuple{N,BoundaryIdentifier}) | |
| 100 normal_derivative(L::Lapalace,ids...) | |
| 101 | |
| 102 Returns normal derivative operator(s) associated with `L` for the boundary(s) | |
| 103 identified by id(s). | |
| 104 | |
| 105 """ | |
| 65 normal_derivative(L::Laplace,id::BoundaryIdentifier) = L.d[id] | 106 normal_derivative(L::Laplace,id::BoundaryIdentifier) = L.d[id] |
| 66 normal_derivative(L::Laplace,ids::NTuple{N,BoundaryIdentifier}) where N = ntuple(i->L.d[ids[i]],N) | 107 normal_derivative(L::Laplace,ids::NTuple{N,BoundaryIdentifier}) where N = ntuple(i->L.d[ids[i]],N) |
| 67 normal_derivative(L::Laplace,ids::Vararg{BoundaryIdentifier,N}) where N = ntuple(i->L.d[ids[i]],N) | 108 normal_derivative(L::Laplace,ids::Vararg{BoundaryIdentifier,N}) where N = ntuple(i->L.d[ids[i]],N) |
| 68 export normal_derivative | 109 export normal_derivative |
| 110 | |
| 111 | |
| 69 # TODO: boundary_inner_product? | 112 # TODO: boundary_inner_product? |
| 113 """ | |
| 114 boundary_quadrature(L::Lapalace,id::BoundaryIdentifier) | |
| 115 boundary_quadrature(L::Lapalace,ids::NTuple{N,BoundaryIdentifier}) | |
| 116 boundary_quadrature(L::Lapalace,ids...) | |
| 117 | |
| 118 Returns boundary quadrature operator(s) associated with `L` for the boundary(s) | |
| 119 identified by id(s). | |
| 120 | |
| 121 """ | |
| 70 boundary_quadrature(L::Laplace,id::BoundaryIdentifier) = L.H_boundary[id] | 122 boundary_quadrature(L::Laplace,id::BoundaryIdentifier) = L.H_boundary[id] |
| 71 boundary_quadrature(L::Laplace,ids::NTuple{N,BoundaryIdentifier}) where N = ntuple(i->L.H_boundary[ids[i]],N) | 123 boundary_quadrature(L::Laplace,ids::NTuple{N,BoundaryIdentifier}) where N = ntuple(i->L.H_boundary[ids[i]],N) |
| 72 boundary_quadrature(L::Laplace,ids::Vararg{BoundaryIdentifier,N}) where N = ntuple(i->L.H_boundary[ids[i]],N) | 124 boundary_quadrature(L::Laplace,ids::Vararg{BoundaryIdentifier,N}) where N = ntuple(i->L.H_boundary[ids[i]],N) |
| 73 export boundary_quadrature | 125 export boundary_quadrature |
| 126 | |
| 74 | 127 |
| 75 """ | 128 """ |
| 76 laplace(grid, inner_stencil, closure_stencils) | 129 laplace(grid, inner_stencil, closure_stencils) |
| 77 | 130 |
| 78 Creates the Laplace operator operator `Δ` as a `TensorMapping` | 131 Creates the Laplace operator operator `Δ` as a `TensorMapping` |
