Mercurial > repos > public > sbplib_julia
changeset 1999:a1b2453c02c9 feature/grids/manifolds
Add check in jacobian for the coordinate to be in the parameterspace of the chart
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 25 Apr 2025 16:05:58 +0200 |
parents | 6dd00ea0511a |
children | f45d32022e4f |
files | src/Grids/manifolds.jl test/Grids/manifolds_test.jl |
diffstat | 2 files changed, 12 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Grids/manifolds.jl Fri Apr 25 08:28:34 2025 +0200 +++ b/src/Grids/manifolds.jl Fri Apr 25 16:05:58 2025 +0200 @@ -36,7 +36,12 @@ ``` which will both allow calling `jacobian(c,ξ)`. """ -jacobian(c::Chart, ξ) = jacobian(c.mapping, ξ) +function jacobian(c::Chart, ξ) + if ξ ∉ parameterspace(c) + throw(DomainError(ξ, "jacobian was called with logical coordinates outside the parameterspace of the chart. If this was inteded, use the `mapping` field from the Chart struct instead.")) + end + return jacobian(c.mapping, ξ) +end boundary_identifiers(c::Chart) = boundary_identifiers(parameterspace(c))
--- a/test/Grids/manifolds_test.jl Fri Apr 25 08:28:34 2025 +0200 +++ b/test/Grids/manifolds_test.jl Fri Apr 25 16:05:58 2025 +0200 @@ -15,7 +15,7 @@ @testset "Chart" begin X(ξ) = 2ξ - Grids.jacobian(::typeof(X), ξ) = @SVector[2,2] + Grids.jacobian(::typeof(X), ξ) = @SMatrix[2 0; 0 2] c = Chart(X, unitsquare()) @test c isa Chart{2} @test parameterspace(c) == unitsquare() @@ -27,7 +27,11 @@ @test_throws DomainError c([3,2]) end - @test jacobian(c, [3,2]) == [2,2] + @testset "jacobian(::Chart, ⋅)" begin + c = Chart(X, unitsquare()) + @test_throws DomainError jacobian(c, [3,2]) + @test jacobian(c, [.3,.2]) == [2 0; 0 2] + end @test Set(boundary_identifiers(Chart(X,unitsquare()))) == Set([east(),west(),south(),north()]) end