Mercurial > repos > public > sbplib_julia
changeset 1574:aeb561754248 feature/grids/manifolds
Implement mapped_grid for a chart
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 25 Apr 2024 14:38:15 +0200 |
parents | bbb9065834ce |
children | a7245343eb98 |
files | src/Grids/mapped_grid.jl test/Grids/mapped_grid_test.jl |
diffstat | 2 files changed, 14 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Grids/mapped_grid.jl Thu Apr 25 14:37:59 2024 +0200 +++ b/src/Grids/mapped_grid.jl Thu Apr 25 14:38:15 2024 +0200 @@ -61,6 +61,15 @@ ) end +function mapped_grid(c::Chart, size...) + lg = equidistant_grid(parameterspace(c), size...) + return MappedGrid( + lg, + map(c,lg), + map(jacobian(c), lg), + ) +end + function jacobian_determinant(g::MappedGrid) return map(jacobian(g)) do ∂x∂ξ det(∂x∂ξ)
--- a/test/Grids/mapped_grid_test.jl Thu Apr 25 14:37:59 2024 +0200 +++ b/test/Grids/mapped_grid_test.jl Thu Apr 25 14:38:15 2024 +0200 @@ -185,12 +185,13 @@ @test collect(mg) == map(x̄, lg) - @testset "mapped_grid(::Chart,J)" begin - c = ConcreteChart(unitsquare()) do (x,y) - @SVector[2x, 3y] + @testset "mapped_grid(::Chart)" begin + c = ConcreteChart(unitsquare()) do (ξ,η) + @SVector[2ξ, 3η] end + Grids.jacobian(c::typeof(c)) = x̄ -> @SMatrix[2 0; 0 3] ## TODO Maybe shouldn't return a function - @test mapped_grid(c, 5, 4) + @test mapped_grid(c, 5, 4) isa Grid end end