changeset 2089:1bc63fa55145 refactor/sbp_operators/direction_check

Change variable name from `direction` to `dim`
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 02 Mar 2026 14:11:32 +0100
parents 438dc7664c1f
children 67d8fbbb9e58
files src/SbpOperators/volumeops/derivatives/first_derivative.jl src/SbpOperators/volumeops/derivatives/second_derivative.jl src/SbpOperators/volumeops/derivatives/second_derivative_variable.jl
diffstat 3 files changed, 31 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/src/SbpOperators/volumeops/derivatives/first_derivative.jl	Mon Mar 02 14:06:41 2026 +0100
+++ b/src/SbpOperators/volumeops/derivatives/first_derivative.jl	Mon Mar 02 14:11:32 2026 +0100
@@ -1,28 +1,28 @@
 """
-    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)
-    if direction ∉ 1:ndims(g)
-        throw(DomainError(direction, "Direction must be inside [0, $(ndims(g))]."))
+function first_derivative(g::TensorGrid, stencil_set, dim)
+    if dim ∉ 1:ndims(g)
+        throw(DomainError(dim, "Direction must be inside [0, $(ndims(g))]."))
     end
-    D₁ = first_derivative(g.grids[direction], stencil_set)
-    return LazyTensors.inflate(D₁, size(g), direction)
+    D₁ = first_derivative(g.grids[dim], stencil_set)
+    return LazyTensors.inflate(D₁, size(g), dim)
 end
 
-function first_derivative(g::EquidistantGrid, stencil_set, direction)
-    return first_derivative(TensorGrid(g), stencil_set, direction)
+function first_derivative(g::EquidistantGrid, stencil_set, dim)
+    return first_derivative(TensorGrid(g), stencil_set, dim)
 end
 
 """
--- a/src/SbpOperators/volumeops/derivatives/second_derivative.jl	Mon Mar 02 14:06:41 2026 +0100
+++ b/src/SbpOperators/volumeops/derivatives/second_derivative.jl	Mon Mar 02 14:11:32 2026 +0100
@@ -1,24 +1,24 @@
 """
-second_derivative(g::TensorGrid, stencil_set, direction)    
-second_derivative(g::EquidistantGrid, stencil_set, direction)
+second_derivative(g::TensorGrid, stencil_set, dim)
+second_derivative(g::EquidistantGrid, stencil_set, dim)
 
 Creates the second derivative operator `D2` as a `LazyTensor`
 
 `D2` approximates the second-derivative d²/dξ² on `g` along the coordinate
-dimension specified by `direction`.
+dimension specified by `dim`.
 
 See also: [`VolumeOperator`](@ref), [`LazyTensors.inflate`](@ref).
 """
-function second_derivative(g::TensorGrid, stencil_set, direction)
-    if direction ∉ 1:ndims(g)
-        throw(DomainError(direction, "Direction must be inside [0, $(ndims(g))]."))
+function second_derivative(g::TensorGrid, stencil_set, dim)
+    if dim ∉ 1:ndims(g)
+        throw(DomainError(dim, "Direction must be inside [0, $(ndims(g))]."))
     end
-    D₂ = second_derivative(g.grids[direction], stencil_set)
-    return LazyTensors.inflate(D₂, size(g), direction)
+    D₂ = second_derivative(g.grids[dim], stencil_set)
+    return LazyTensors.inflate(D₂, size(g), dim)
 end
 
-function second_derivative(g::EquidistantGrid, stencil_set::StencilSet, direction)
-    return second_derivative(TensorGrid(g), stencil_set, direction)
+function second_derivative(g::EquidistantGrid, stencil_set::StencilSet, dim)
+    return second_derivative(TensorGrid(g), stencil_set, dim)
 end
 
 """
--- a/src/SbpOperators/volumeops/derivatives/second_derivative_variable.jl	Mon Mar 02 14:06:41 2026 +0100
+++ b/src/SbpOperators/volumeops/derivatives/second_derivative_variable.jl	Mon Mar 02 14:11:32 2026 +0100
@@ -1,39 +1,39 @@
 """
-    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, direction::Int)
-    if direction ∉ 1:ndims(g)
-        throw(DomainError(direction, "Direction must be inside [0, $(ndims(g))]."))
+function second_derivative_variable(g::TensorGrid, coeff, stencil_set, dim::Int)
+    if dim ∉ 1:ndims(g)
+        throw(DomainError(dim, "Direction must be inside [0, $(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, direction)
+    return second_derivative_variable(g, coeff, inner_stencil, closure_stencils, dim)
 end
 
-function second_derivative_variable(g::EquidistantGrid, coeff, stencil_set, direction)
-    return second_derivative_variable(TensorGrid(g), coeff, stencil_set, direction)
+function second_derivative_variable(g::EquidistantGrid, coeff, stencil_set, dim)
+    return second_derivative_variable(TensorGrid(g), coeff, stencil_set, dim)
 end
 
 function second_derivative_variable(g::EquidistantGrid, coeff, stencil_set)
     return second_derivative_variable(g::EquidistantGrid, coeff, stencil_set, 1)
 end
 
-function second_derivative_variable(g::TensorGrid, coeff, inner_stencil::NestedStencil, closure_stencils, direction)
+function second_derivative_variable(g::TensorGrid, coeff, inner_stencil::NestedStencil, closure_stencils, dim)
     check_coefficient(g, coeff)
 
-    Δxᵢ = spacing(g.grids[direction])
+    Δ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, direction)
+    return SecondDerivativeVariable(coeff, scaled_inner_stencil, scaled_closure_stencils, dim)
 end
 
 function check_coefficient(g, coeff)