diff src/SbpOperators/volumeops/derivatives/first_derivative.jl @ 1395:bdcdbd4ea9cd feature/boundary_conditions

Merge with default. Comment out broken tests for boundary_conditions at sat
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Wed, 26 Jul 2023 21:35:50 +0200
parents 08f06bfacd5c
children
line wrap: on
line diff
--- a/src/SbpOperators/volumeops/derivatives/first_derivative.jl	Tue Feb 07 21:55:07 2023 +0100
+++ b/src/SbpOperators/volumeops/derivatives/first_derivative.jl	Wed Jul 26 21:35:50 2023 +0200
@@ -1,46 +1,42 @@
 """
-    first_derivative(grid::EquidistantGrid, inner_stencil, closure_stencils, direction)
+    first_derivative(g, ..., [direction])
+
+The first derivative operator `D1` as a `LazyTensor` on the given grid.
 
-Creates the first-derivative operator `D1` as a `LazyTensor`
-
-`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.
+`D1` approximates the first-derivative d/dξ on `g` along the coordinate
+dimension specified by `direction`.
+"""
+function first_derivative end
 
-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 `IdentityTensor`s in orthogonal coordinate dirrections.
+"""
+    first_derivative(g::TensorGrid, stencil_set, direction)
 
-See also: [`volume_operator`](@ref).
+See also: [`VolumeOperator`](@ref), [`LazyTensors.inflate`](@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)
+function first_derivative(g::TensorGrid, stencil_set, direction)
+    D₁ = first_derivative(g.grids[direction], stencil_set)
+    return LazyTensors.inflate(D₁, size(g), direction)
 end
 
-
 """
-    first_derivative(grid, inner_stencil, closure_stencils)
+    first_derivative(g::EquidistantGrid, stencil_set::StencilSet)
 
-Creates a `first_derivative` operator on a 1D `grid` given `inner_stencil` and `closure_stencils`.
+The first derivative operator on an `EquidistantGrid`. 
+Uses the `D1` stencil in `stencil_set`.
 """
-first_derivative(grid::EquidistantGrid{1}, inner_stencil::Stencil, closure_stencils) = first_derivative(grid, inner_stencil, closure_stencils, 1)
-
+function first_derivative(g::EquidistantGrid, stencil_set::StencilSet)
+    inner_stencil = parse_stencil(stencil_set["D1"]["inner_stencil"])
+    closure_stencils = parse_stencil.(stencil_set["D1"]["closure_stencils"])
+    return first_derivative(g, inner_stencil, closure_stencils);
+end
 
 """
-    first_derivative(grid, stencil_set::StencilSet, direction)
+    first_derivative(g::EquidistantGrid, inner_stencil::Stencil, closure_stencils)
 
-Creates a `first_derivative` operator on `grid` along coordinate dimension `direction` given a `stencil_set`.
+The first derivative operator on an `EquidistantGrid` given an
+`inner_stencil` and `closure_stencils`.
 """
-function first_derivative(grid::EquidistantGrid, stencil_set::StencilSet, direction)
-    inner_stencil = parse_stencil(stencil_set["D1"]["inner_stencil"])
-    closure_stencils = parse_stencil.(stencil_set["D1"]["closure_stencils"])
-    first_derivative(grid,inner_stencil,closure_stencils,direction);
+function first_derivative(g::EquidistantGrid, inner_stencil::Stencil, closure_stencils)
+    h⁻¹ = inverse_spacing(g)
+    return VolumeOperator(g, scale(inner_stencil,h⁻¹), scale.(closure_stencils,h⁻¹), odd)
 end
-
-
-"""
-    first_derivative(grid, stencil_set)
-
-Creates a `first_derivative` operator on a 1D `grid` given a `stencil_set`.
-"""
-first_derivative(grid::EquidistantGrid{1}, stencil_set::StencilSet) = first_derivative(grid, stencil_set, 1)