Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/volumeops/laplace/laplace.jl @ 723:c16abc564b82 feature/laplace_opset
Change from EquidistantGrid to AbstractGrid in Laplace interface
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Wed, 17 Mar 2021 10:20:05 +0100 |
parents | 0402b9042adc |
children | f94feb005e7d |
comparison
equal
deleted
inserted
replaced
722:0402b9042adc | 723:c16abc564b82 |
---|---|
1 """ | 1 """ |
2 Laplace{T, Dim, ...} <: TensorMapping{T,Dim,Dim} | 2 Laplace{T, Dim, ...} <: TensorMapping{T,Dim,Dim} |
3 Laplace(grid::EquidistantGrid, 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::EquidistantGrid, fn; order) creates the Laplace operator on an | 9 Laplace(grid, fn; order) creates the Laplace operator defined on `grid`, |
10 equidistant grid, where the operators are read from TOML. The differential operator | 10 where the operators are read from TOML. The differential operator is created |
11 is created using `laplace(grid,...)`. | 11 using `laplace(grid::AbstractGrid,...)`. |
12 """ | 12 """ |
13 struct Laplace{T, Dim, Rb, TMdiffop<:TensorMapping{T,Dim,Dim}, # Differential operator | 13 struct Laplace{T, Dim, Rb, TMdiffop<:TensorMapping{T,Dim,Dim}, # Differential operator |
14 TMipop<:TensorMapping{T,Dim,Dim}, # Inner product operator | 14 TMipop<:TensorMapping{T,Dim,Dim}, # Inner product operator |
15 TMbop<:TensorMapping{T,Rb,Dim}, # Boundary operator | 15 TMbop<:TensorMapping{T,Rb,Dim}, # Boundary operator |
16 TMbqop<:TensorMapping{T,Rb,Rb}, # Boundary quadrature | 16 TMbqop<:TensorMapping{T,Rb,Rb}, # Boundary quadrature |
22 d::Dict{BID,TMbop} # Normal derivative operators | 22 d::Dict{BID,TMbop} # Normal derivative operators |
23 H_boundary::Dict{BID,TMbqop} # Boundary quadrature operators | 23 H_boundary::Dict{BID,TMbqop} # Boundary quadrature operators |
24 end | 24 end |
25 export Laplace | 25 export Laplace |
26 | 26 |
27 function Laplace(grid::EquidistantGrid, fn; order) | 27 function Laplace(grid::AbstractGrid, fn; order) |
28 # TODO: Removed once we can construct the volume and | 28 # TODO: Removed once we can construct the volume and |
29 # boundary operators by op(grid, fn; order,...). | 29 # boundary operators by op(grid, fn; order,...). |
30 # Read stencils | 30 # Read stencils |
31 op = read_D2_operator(fn; order) | 31 op = read_D2_operator(fn; order) |
32 D_inner_stecil = op.innerStencil | 32 D_inner_stecil = op.innerStencil |
65 # TODO: boundary_inner_product? | 65 # TODO: boundary_inner_product? |
66 boundary_quadrature(L::Laplace,bid::BoundaryIdentifier) = L.H_boundary[bid] | 66 boundary_quadrature(L::Laplace,bid::BoundaryIdentifier) = L.H_boundary[bid] |
67 export boundary_quadrature | 67 export boundary_quadrature |
68 | 68 |
69 """ | 69 """ |
70 laplace(grid::EquidistantGrid, inner_stencil, closure_stencils) | 70 laplace(grid, inner_stencil, closure_stencils) |
71 | 71 |
72 Creates the Laplace operator operator `Δ` as a `TensorMapping` | 72 Creates the Laplace operator operator `Δ` as a `TensorMapping` |
73 | 73 |
74 `Δ` approximates the Laplace operator ∑d²/xᵢ² , i = 1,...,N on the N-dimensional | 74 `Δ` approximates the Laplace operator ∑d²/xᵢ² , i = 1,...,N on the N-dimensional |
75 `grid`, using the stencil `inner_stencil` in the interior and a set of stencils | 75 `grid`, using the stencil `inner_stencil` in the interior and a set of stencils |
77 | 77 |
78 On a one-dimensional `grid`, `Δ` is equivalent to `second_derivative`. On a | 78 On a one-dimensional `grid`, `Δ` is equivalent to `second_derivative`. On a |
79 multi-dimensional `grid`, `Δ` is the sum of multi-dimensional `second_derivative`s | 79 multi-dimensional `grid`, `Δ` is the sum of multi-dimensional `second_derivative`s |
80 where the sum is carried out lazily. | 80 where the sum is carried out lazily. |
81 """ | 81 """ |
82 function laplace(grid::EquidistantGrid, inner_stencil, closure_stencils) | 82 function laplace(grid::AbstractGrid, inner_stencil, closure_stencils) |
83 Δ = second_derivative(grid, inner_stencil, closure_stencils, 1) | 83 Δ = second_derivative(grid, inner_stencil, closure_stencils, 1) |
84 for d = 2:dimension(grid) | 84 for d = 2:dimension(grid) |
85 Δ += second_derivative(grid, inner_stencil, closure_stencils, d) | 85 Δ += second_derivative(grid, inner_stencil, closure_stencils, d) |
86 end | 86 end |
87 return Δ | 87 return Δ |