Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/volumeops/laplace/laplace.jl @ 926:47425442bbc5 feature/laplace_opset
Fix tests after refactoring
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Mon, 21 Feb 2022 23:33:29 +0100 |
parents | 12e8e431b43c |
children | 22c80fb36400 |
comparison
equal
deleted
inserted
replaced
925:6b47a9ee1632 | 926:47425442bbc5 |
---|---|
1 """ | 1 """ |
2 Laplace{T, DiffOp} <: TensorMapping{T,Dim,Dim} | 2 Laplace{T, Dim, DiffOp} <: TensorMapping{T, Dim, Dim} |
3 Laplace(grid::Equidistant, stencil_set) | |
4 | 3 |
5 Implements the Laplace operator, approximating ∑d²/xᵢ² , i = 1,...,`Dim` as a | 4 Implements the Laplace operator, approximating ∑d²/xᵢ² , i = 1,...,`Dim` as a |
6 `TensorMapping`. Additionally `Laplace` stores the stencil set (parsed from TOML) | 5 `TensorMapping`. Additionally `Laplace` stores the stencil set (parsed from TOML) |
7 used to construct the `TensorMapping`. | 6 used to construct the `TensorMapping`. |
8 """ | 7 """ |
9 struct Laplace{T, DiffOp<:TensorMapping{T,Dim,Dim}} <: TensorMapping{T,Dim,Dim} | 8 struct Laplace{T, Dim, DiffOp<:TensorMapping{T, Dim, Dim}} <: TensorMapping{T, Dim, Dim} |
10 D::DiffOp# Differential operator | 9 D::DiffOp# Differential operator |
11 stencil_set # Stencil set of the operator | 10 stencil_set # Stencil set of the operator |
12 end | 11 end |
13 | 12 |
14 """ | 13 """ |
15 `Laplace(grid::Equidistant, stencil_set)` | 14 `Laplace(grid::Equidistant, stencil_set)` |
16 | 15 |
17 Creates the `Laplace`` operator `Δ` on `grid` given a parsed TOML | 16 Creates the `Laplace`` operator `Δ` on `grid` given a parsed TOML |
18 `stencil_set`. See also [`laplace`](@ref). | 17 `stencil_set`. See also [`laplace`](@ref). |
19 """ | 18 """ |
20 function Laplace(grid::Equidistant, stencil_set) | 19 function Laplace(grid::EquidistantGrid, stencil_set) |
21 inner_stencil = parse_stencil(stencil_set["D2"]["inner_stencil"]) | 20 inner_stencil = parse_stencil(stencil_set["D2"]["inner_stencil"]) |
22 closure_stencils = parse_stencil.(stencil_set["D2"]["closure_stencils"]) | 21 closure_stencils = parse_stencil.(stencil_set["D2"]["closure_stencils"]) |
23 Δ = laplace(grid, inner_stencil,closure_stencils) | 22 Δ = laplace(grid, inner_stencil,closure_stencils) |
24 return Laplace(Δ,stencil_set) | 23 return Laplace(Δ,stencil_set) |
25 end | 24 end |
42 | 41 |
43 On a one-dimensional `grid`, `Δ` is equivalent to `second_derivative`. On a | 42 On a one-dimensional `grid`, `Δ` is equivalent to `second_derivative`. On a |
44 multi-dimensional `grid`, `Δ` is the sum of multi-dimensional `second_derivative`s | 43 multi-dimensional `grid`, `Δ` is the sum of multi-dimensional `second_derivative`s |
45 where the sum is carried out lazily. See also [`second_derivative`](@ref). | 44 where the sum is carried out lazily. See also [`second_derivative`](@ref). |
46 """ | 45 """ |
47 function laplace(grid::Equidistant, inner_stencil, closure_stencils) | 46 function laplace(grid::EquidistantGrid, inner_stencil, closure_stencils) |
48 second_derivative(grid, inner_stencil, closure_stencils, 1) | 47 Δ = second_derivative(grid, inner_stencil, closure_stencils, 1) |
49 for d = 2:dimension(grid) | 48 for d = 2:dimension(grid) |
50 Δ += second_derivative(grid, inner_stencil, closure_stencils, d) | 49 Δ += second_derivative(grid, inner_stencil, closure_stencils, d) |
51 end | 50 end |
52 return Δ | 51 return Δ |
53 end | 52 end |