diff src/SbpOperators/volumeops/derivatives/second_derivative_variable.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 3684db043add e21c295fb2da
children
line wrap: on
line diff
--- a/src/SbpOperators/volumeops/derivatives/second_derivative_variable.jl	Wed Feb 25 14:33:42 2026 +0100
+++ b/src/SbpOperators/volumeops/derivatives/second_derivative_variable.jl	Mon Mar 02 15:58:27 2026 +0100
@@ -1,32 +1,42 @@
 """
-    second_derivative_variable(g, coeff ..., [direction])
+    second_derivative_variable(g, coeff, ..., [dim])
 
 The variable second derivative operator as a `LazyTensor` on the given grid.
 `coeff` is a grid function of the variable coefficient.
 
 Approximates the d/dξ c d/dξ on `g` along the coordinate dimension specified
-by `direction`.
+by `dim`.
 """
 function second_derivative_variable end
 
-function second_derivative_variable(g::TensorGrid, coeff, stencil_set, dir::Int)
+function second_derivative_variable(g::TensorGrid, coeff, stencil_set, dim::Int)
+    if dim ∉ 1:ndims(g)
+        throw(DomainError(dim, "Derivative direction must be in 1:$(ndims(g))."))
+    end
     inner_stencil    = parse_nested_stencil(eltype(coeff), stencil_set["D2variable"]["inner_stencil"])
     closure_stencils = parse_nested_stencil.(eltype(coeff), stencil_set["D2variable"]["closure_stencils"])
 
-    return second_derivative_variable(g, coeff, inner_stencil, closure_stencils, dir)
+    return second_derivative_variable(g, coeff, inner_stencil, closure_stencils, dim)
 end
 
 function second_derivative_variable(g::EquidistantGrid, coeff, stencil_set)
     return second_derivative_variable(TensorGrid(g), coeff, stencil_set, 1)
 end
 
-function second_derivative_variable(g::TensorGrid, coeff, inner_stencil::NestedStencil, closure_stencils, dir)
+function second_derivative_variable(g::EquidistantGrid, coeff, stencil_set, dim)
+    if dim != 1
+        throw(DomainError(dim, "Derivative direction must be 1."))
+    end
+    return second_derivative_variable(g, coeff, stencil_set)
+end
+
+function second_derivative_variable(g::TensorGrid, coeff, inner_stencil::NestedStencil, closure_stencils, dim)
     check_coefficient(g, coeff)
 
-    Δxᵢ = spacing(g.grids[dir])
+    Δxᵢ = spacing(g.grids[dim])
     scaled_inner_stencil = scale(inner_stencil, 1/Δxᵢ^2)
     scaled_closure_stencils = scale.(Tuple(closure_stencils), 1/Δxᵢ^2)
-    return SecondDerivativeVariable(coeff, scaled_inner_stencil, scaled_closure_stencils, dir)
+    return SecondDerivativeVariable(coeff, scaled_inner_stencil, scaled_closure_stencils, dim)
 end
 
 function check_coefficient(g, coeff)