changeset 1584:d7483e8af705 feature/sbp_operators/laplace_curvilinear

Merge feature/grids/manifolds
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 26 Apr 2024 08:45:54 +0200
parents 6e910408c51a (diff) f77c5309dd2b (current diff)
children d359d0d7fb12
files src/Grids/Grids.jl
diffstat 2 files changed, 28 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/SbpOperators/volumeops/laplace/laplace.jl	Thu Apr 25 22:32:54 2024 +0200
+++ b/src/SbpOperators/volumeops/laplace/laplace.jl	Fri Apr 26 08:45:54 2024 +0200
@@ -52,3 +52,25 @@
     return Δ
 end
 laplace(g::EquidistantGrid, stencil_set) = second_derivative(g, stencil_set)
+
+
+function laplace(g::MappedGrid, stencil_set)
+    J = jacobian_determinant(g)
+    J⁻¹ = map(inv, J)
+
+    Jḡ = map(*, J, ggeometric_tensor_inverse(g))
+    lg = logicalgrid(g)
+
+    return mapreduce(+, CartesianIndices(first(ḡ))) do I
+        i,j = I[1], I[2]
+        Jgⁱʲ = componentview(Jḡ, I[1], I[2])
+
+        if i == j
+            J⁻¹∘second_derivative_variable(lg, Jgⁱʲ, stencil_set, i)
+        else
+            Dᵢ = first_derivative(lg, stencil_set, i)
+            Dⱼ = first_derivative(lg, stencil_set, j)
+            J⁻¹∘Dᵢ∘DiagonalTensor(Jgⁱʲ)∘Dⱼ
+        end
+    end
+end
--- a/test/SbpOperators/volumeops/laplace/laplace_test.jl	Thu Apr 25 22:32:54 2024 +0200
+++ b/test/SbpOperators/volumeops/laplace/laplace_test.jl	Fri Apr 26 08:45:54 2024 +0200
@@ -72,12 +72,12 @@
     g_1D = equidistant_grid(0.0, 1., 101)
     g_3D = equidistant_grid((0.0, -1.0, 0.0), (1., 1., 1.), 51, 101, 52)
 
-    @testset "1D" begin
+    @testset "EquidistantGrid" begin
         Δ = laplace(g_1D, stencil_set)
         @test Δ == second_derivative(g_1D, stencil_set)
         @test Δ isa LazyTensor{Float64,1,1}
     end
-    @testset "3D" begin
+    @testset "TensorGrid" begin
         Δ = laplace(g_3D, stencil_set)
         @test Δ isa LazyTensor{Float64,3,3}
         Dxx = second_derivative(g_3D, stencil_set, 1)
@@ -86,5 +86,9 @@
         @test Δ == Dxx + Dyy + Dzz
         @test Δ isa LazyTensor{Float64,3,3}
     end
+
+    @testset "MappedGrid" begin
+        @test_broken false
+    end
 end