diff src/SbpOperators/volumeops/derivatives/first_derivative.jl @ 2096:5af7534e5b3c feature/sbp_operators/laplace_curvilinear tip

Merge default
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 02 Mar 2026 15:58:27 +0100
parents e21c295fb2da
children
line wrap: on
line diff
--- a/src/SbpOperators/volumeops/derivatives/first_derivative.jl	Wed Feb 25 14:33:42 2026 +0100
+++ b/src/SbpOperators/volumeops/derivatives/first_derivative.jl	Mon Mar 02 15:58:27 2026 +0100
@@ -1,23 +1,27 @@
 """
-    first_derivative(g, ..., [direction])
+    first_derivative(g, ..., [dim])
 
 The first derivative operator `D1` as a `LazyTensor` on the given grid.
 
 `D1` approximates the first-derivative d/dξ on `g` along the coordinate
-dimension specified by `direction`.
+dimension specified by `dim`.
 """
 function first_derivative end
 
 """
-    first_derivative(g::TensorGrid, stencil_set, direction)
+    first_derivative(g::TensorGrid, stencil_set, dim)
 
 See also: [`VolumeOperator`](@ref), [`LazyTensors.inflate`](@ref).
 """
-function first_derivative(g::TensorGrid, stencil_set, direction)
-    D₁ = first_derivative(g.grids[direction], stencil_set)
-    return LazyTensors.inflate(D₁, size(g), direction)
+function first_derivative(g::TensorGrid, stencil_set, dim)
+    if dim ∉ 1:ndims(g)
+        throw(DomainError(dim, "Derivative direction must be in 1:$(ndims(g))."))
+    end
+    D₁ = first_derivative(g.grids[dim], stencil_set)
+    return LazyTensors.inflate(D₁, size(g), dim)
 end
 
+
 """
     first_derivative(g::EquidistantGrid, stencil_set::StencilSet)
 
@@ -30,6 +34,13 @@
     return first_derivative(g, inner_stencil, closure_stencils);
 end
 
+function first_derivative(g::EquidistantGrid, stencil_set, dim)
+    if dim != 1
+        throw(DomainError(dim, "Derivative direction must be 1."))
+    end
+    return first_derivative(g, stencil_set)
+end
+
 """
     first_derivative(g::EquidistantGrid, inner_stencil::Stencil, closure_stencils)