changeset 925:6b47a9ee1632 feature/laplace_opset

Add functionality for creating operators from a stencil set. Note: Tests are not updated yet!
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Mon, 21 Feb 2022 13:13:37 +0100
parents 12e8e431b43c
children 47425442bbc5
files src/SbpOperators/boundaryops/boundary_restriction.jl src/SbpOperators/boundaryops/normal_derivative.jl src/SbpOperators/volumeops/derivatives/second_derivative.jl src/SbpOperators/volumeops/inner_products/inner_product.jl src/SbpOperators/volumeops/inner_products/inverse_inner_product.jl
diffstat 5 files changed, 50 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/SbpOperators/boundaryops/boundary_restriction.jl	Mon Feb 21 13:12:47 2022 +0100
+++ b/src/SbpOperators/boundaryops/boundary_restriction.jl	Mon Feb 21 13:13:37 2022 +0100
@@ -1,16 +1,22 @@
 """
-    boundary_restriction(grid::EquidistantGrid, closure_stencil::Stencil, boundary::CartesianBoundary)
-    boundary_restriction(grid::EquidistantGrid{1}, closure_stencil::Stencil, region::Region)
+    boundary_restriction(grid, closure_stencil::Stencil, boundary)
 
-Creates the boundary restriction operator `e` as a `TensorMapping`
+Creates boundary restriction operators `e` as `TensorMapping`s on `boundary`
 
-`e` is the restriction of a grid function to the boundary specified by `boundary` or `region` using some `closure_stencil`.
-`e'` is the prolongation of a grid function on the boundary to the whole grid using the same `closure_stencil`.
+`e` is the restriction of a grid function to `boundary` using a `Stencil` `closure_stencil`.
+`e'` is the prolongation of a grid function on `boundary`` to the whole grid using the same `closure_stencil`.
 On a one-dimensional `grid`, `e` is a `BoundaryOperator`. On a multi-dimensional `grid`, `e` is the inflation of
-a `BoundaryOperator`. Also see the documentation of `SbpOperators.boundary_operator(...)` for more details.
+a `BoundaryOperator`. See also [`SbpOperators.boundary_operator`](@ref).
 """
-function boundary_restriction(grid::EquidistantGrid, closure_stencil, boundary::CartesianBoundary)
+function boundary_restriction(grid, closure_stencil::Stencil, boundary)
     converted_stencil = convert(Stencil{eltype(grid)}, closure_stencil)
     return SbpOperators.boundary_operator(grid, converted_stencil, boundary)
 end
-boundary_restriction(grid::EquidistantGrid{1}, closure_stencil, region::Region) = boundary_restriction(grid, closure_stencil, CartesianBoundary{1,typeof(region)}())
+
+"""
+    boundary_restriction(grid, stencil_set, boundary)
+
+Creates a `boundary_restriction` operator on `grid` given a parsed TOML
+`stencil_set`.
+"""
+boundary_restriction(grid, stencil_set, boundary) = boundary_restriction(grid, parse_stencil(stencil_set["e"]["closure"]), boundary)
--- a/src/SbpOperators/boundaryops/normal_derivative.jl	Mon Feb 21 13:12:47 2022 +0100
+++ b/src/SbpOperators/boundaryops/normal_derivative.jl	Mon Feb 21 13:13:37 2022 +0100
@@ -1,17 +1,23 @@
 """
-    normal_derivative(grid::EquidistantGrid, closure_stencil::Stencil, boundary::CartesianBoundary)
-    normal_derivative(grid::EquidistantGrid{1}, closure_stencil::Stencil, region::Region)
+    normal_derivative(grid, closure_stencil::Stencil, boundary)
 
 Creates the normal derivative boundary operator `d` as a `TensorMapping`
 
-`d` is the normal derivative of a grid function at the boundary specified by `boundary` or `region` using some `closure_stencil`.
+`d` computes the normal derivative of a grid function  on `boundary` a `Stencil` `closure_stencil`.
 `d'` is the prolongation of the normal derivative of a grid function to the whole grid using the same `closure_stencil`.
 On a one-dimensional `grid`, `d` is a `BoundaryOperator`. On a multi-dimensional `grid`, `d` is the inflation of
-a `BoundaryOperator`. Also see the documentation of `SbpOperators.boundary_operator(...)` for more details.
+a `BoundaryOperator`. See also [`SbpOperators.boundary_operator`](@ref).
 """
-function normal_derivative(grid::EquidistantGrid, closure_stencil, boundary::CartesianBoundary)
+function normal_derivative(grid, closure_stencil::Stencil, boundary)
     direction = dim(boundary)
     h_inv = inverse_spacing(grid)[direction]
     return SbpOperators.boundary_operator(grid, scale(closure_stencil,h_inv), boundary)
 end
-normal_derivative(grid::EquidistantGrid{1}, closure_stencil, region::Region) = normal_derivative(grid, closure_stencil, CartesianBoundary{1,typeof(region)}())
+
+"""
+    normal_derivative(grid, stencil_set, boundary)
+
+Creates a `normal_derivative` operator on `grid` given a parsed TOML
+`stencil_set`.
+"""
+normal_derivative(grid, stencil_set, boundary) = normal_derivative(grid, parse_stencil(stencil_set["e"]["closure"]), boundary)
--- a/src/SbpOperators/volumeops/derivatives/second_derivative.jl	Mon Feb 21 13:12:47 2022 +0100
+++ b/src/SbpOperators/volumeops/derivatives/second_derivative.jl	Mon Feb 21 13:13:37 2022 +0100
@@ -16,4 +16,3 @@
     return SbpOperators.volume_operator(grid, scale(inner_stencil,h_inv^2), scale.(closure_stencils,h_inv^2), even, direction)
 end
 second_derivative(grid::EquidistantGrid{1}, inner_stencil, closure_stencils) = second_derivative(grid,inner_stencil,closure_stencils,1)
-export second_derivative
--- a/src/SbpOperators/volumeops/inner_products/inner_product.jl	Mon Feb 21 13:12:47 2022 +0100
+++ b/src/SbpOperators/volumeops/inner_products/inner_product.jl	Mon Feb 21 13:13:37 2022 +0100
@@ -31,3 +31,15 @@
 end
 
 inner_product(grid::EquidistantGrid{0}, interior_weight, closure_weights) = IdentityMapping{eltype(grid)}()
+
+"""
+    inner_product(grid, stencil_set)
+
+Creates a `inner_product` operator on `grid` given a parsed TOML
+`stencil_set`.
+"""
+function inner_product(grid, stencil_set)
+    inner_stencil = parse_scalar(stencil_set["H"]["inner"])
+    closure_stencils = parse_tuple(stencil_set["H"]["closure"])
+    return inner_product(grid, inner_stencil, closure_stencils)
+end
\ No newline at end of file
--- a/src/SbpOperators/volumeops/inner_products/inverse_inner_product.jl	Mon Feb 21 13:12:47 2022 +0100
+++ b/src/SbpOperators/volumeops/inner_products/inverse_inner_product.jl	Mon Feb 21 13:13:37 2022 +0100
@@ -27,3 +27,15 @@
 end
 
 inverse_inner_product(grid::EquidistantGrid{0}, interior_weight, closure_weights) = IdentityMapping{eltype(grid)}()
+
+"""
+    inverse_inner_product(grid, stencil_set)
+
+Creates a `inverse_inner_product` operator on `grid` given a parsed TOML
+`stencil_set`.
+"""
+function inverse_inner_product(grid, stencil_set)
+    inner_stencil = parse_scalar(stencil_set["H"]["inner"])
+    closure_stencils = parse_tuple(stencil_set["H"]["closure"])
+    return inverse_inner_product(grid, inner_stencil, closure_stencils)
+end 
\ No newline at end of file