changeset 972:803f60f461c1 feature/first_derivative

Start adding the first derivative
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 14 Mar 2022 16:01:33 +0100
parents 84ca744f2f06
children 4c17a7d6ae5e
files src/SbpOperators/volumeops/derivatives/first_derivative.jl test/SbpOperators/volumeops/derivatives/first_derivative_test.jl
diffstat 2 files changed, 27 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/SbpOperators/volumeops/derivatives/first_derivative.jl	Mon Mar 14 16:01:33 2022 +0100
@@ -0,0 +1,22 @@
+export first_derivative
+
+"""
+    first_derivative(grid::EquidistantGrid, inner_stencil, closure_stencils, direction)
+
+Creates the first-derivative operator `D1` as a `TensorMapping`
+
+`D1` approximates the first-derivative d/dξ on `grid` along the coordinate dimension specified by
+`direction`, using the stencil `inner_stencil` in the interior and a set of stencils `closure_stencils`
+for the points in the closure regions.
+
+On a one-dimensional `grid`, `D1` is a `VolumeOperator`. On a multi-dimensional `grid`, `D1` is the outer product of the
+one-dimensional operator with the `IdentityMapping`s in orthogonal coordinate dirrections.
+
+See also: [`SbpOperators.volume_operator`](@ref).
+"""
+function first_derivative(grid::EquidistantGrid, inner_stencil, closure_stencils, direction)
+    h_inv = inverse_spacing(grid)[direction]
+    return SbpOperators.volume_operator(grid, scale(inner_stencil,h_inv), scale.(closure_stencils,h_inv), odd, direction)
+end
+first_derivative(grid::EquidistantGrid{1}, inner_stencil, closure_stencils) = first_derivative(grid,inner_stencil,closure_stencils,1)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/SbpOperators/volumeops/derivatives/first_derivative_test.jl	Mon Mar 14 16:01:33 2022 +0100
@@ -0,0 +1,5 @@
+using Test
+
+using Sbplib.SbpOperators
+using Sbplib.Grids
+