Mercurial > repos > public > sbplib_julia
changeset 1976:34a7e3919e9a feature/grids/geometry_functions
Implement Grids.jacobian for Circle
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 25 Feb 2025 22:48:42 +0100 |
parents | 79adad4a15d6 |
children | 270675bb97be |
files | src/Grids/geometry.jl test/Grids/geometry_test.jl |
diffstat | 2 files changed, 35 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Grids/geometry.jl Tue Feb 25 22:42:14 2025 +0100 +++ b/src/Grids/geometry.jl Tue Feb 25 22:48:42 2025 +0100 @@ -63,6 +63,11 @@ c + r*@SVector[cos(θ), sin(θ)] end +function Grids.jacobian(C::Circle, θ) + (;r) = C + r*@SVector[-sin(θ), cos(θ)] +end + struct TransfiniteInterpolationSurface{T1,T2,T3,T4} c₁::T1 c₂::T2
--- a/test/Grids/geometry_test.jl Tue Feb 25 22:42:14 2025 +0100 +++ b/test/Grids/geometry_test.jl Tue Feb 25 22:48:42 2025 +0100 @@ -130,6 +130,36 @@ @test c(3π/2) ≈ [0,-2] @test c(π/4) ≈ [√(2),√(2)] end + + @testset "Grids.jacobian" begin + c = Circle([0,0], 1) + @test Grids.jacobian(c, 0) ≈ [0,1] + @test Grids.jacobian(c, π/2) ≈ [-1,0] + @test Grids.jacobian(c, π) ≈ [0,-1] + @test Grids.jacobian(c, 3π/2) ≈ [1,0] + @test Grids.jacobian(c, π/4) ≈ [-1/√(2),1/√(2)] + + c = Circle([0,0], 2) + @test Grids.jacobian(c, 0) ≈ [0,2] + @test Grids.jacobian(c, π/2) ≈ [-2,0] + @test Grids.jacobian(c, π) ≈ [0,-2] + @test Grids.jacobian(c, 3π/2) ≈ [2,0] + @test Grids.jacobian(c, π/4) ≈ [-√(2),√(2)] + + c = Circle([-1,1], 1) + @test Grids.jacobian(c, 0) ≈ [0,1] + @test Grids.jacobian(c, π/2) ≈ [-1,0] + @test Grids.jacobian(c, π) ≈ [0,-1] + @test Grids.jacobian(c, 3π/2) ≈ [1,0] + @test Grids.jacobian(c, π/4) ≈ [-1/√(2),1/√(2)] + + c = Circle([-1,1], 2) + @test Grids.jacobian(c, 0) ≈ [0,2] + @test Grids.jacobian(c, π/2) ≈ [-2,0] + @test Grids.jacobian(c, π) ≈ [0,-2] + @test Grids.jacobian(c, 3π/2) ≈ [2,0] + @test Grids.jacobian(c, π/4) ≈ [-√(2),√(2)] + end end @testset "TransfiniteInterpolationSurface" begin