changeset 1817:d91a9f47380f feature/jet_aqua

Resolve ambiguity of mapped_grid and improve its signature
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 14 Oct 2024 23:28:12 +0200
parents 77f1b027d134
children e89e28fa9637
files src/Grids/mapped_grid.jl test/Grids/mapped_grid_test.jl
diffstat 2 files changed, 24 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/Grids/mapped_grid.jl	Mon Oct 14 23:26:49 2024 +0200
+++ b/src/Grids/mapped_grid.jl	Mon Oct 14 23:28:12 2024 +0200
@@ -94,25 +94,33 @@
 
 
 """
+    mapped_grid(x,J,size...)
+    mapped_grid(x,J,size...)
+"""
+function mapped_grid end
+"""
     mapped_grid(x, J, size::Vararg{Int})
 
 A `MappedGrid` with a default logical grid on the D-dimensional unit hyper 
-box [0,1]ᴰ. `x` and `J`are functions to be evaluated on the logical grid
+box [0,1]ᴰ. `x` and `J` are functions to be evaluated on the logical grid
 and `size` determines the size of the logical grid.
 """
 function mapped_grid(x, J, size::Vararg{Int})
     D = length(size)
     lg = equidistant_grid(ntuple(i->0., D), ntuple(i->1., D), size...)
-    return mapped_grid(lg, x, J)
+    return mapped_grid(x, J, lg)
+
+    # parameterspace = ...
+    # return mapped_grid(x, J, parameterspace, size...)
 end
 
 """
-    mapped_grid(lg::Grid, x, J)
+    mapped_grid(x, J, lg::Grid)
 
 A `MappedGrid` with logical grid `lg`. Physical coordinates and Jacobian are
 determined by the functions `x` and `J`.
 """
-function mapped_grid(lg::Grid, x, J)
+function mapped_grid(x, J, lg::Grid)
     return MappedGrid(
         lg,
         map(x,lg),
@@ -121,6 +129,17 @@
 end
 
 """
+    mapped_grid(x, J, lg::Grid)
+
+A `MappedGrid` with logical grid `lg`. Physical coordinates and Jacobian are
+determined by the functions `x` and `J`.
+"""
+function mapped_grid(x, J, parameterspace, size::Vararg{Int})
+    lg = equidistant_grid(parameterspace, size...)
+    return mapped_grid(x, J, lg)
+end
+
+"""
     metric_tensor(g::MappedGrid)
 
 The metric tensor of `g` as a grid function.
--- a/test/Grids/mapped_grid_test.jl	Mon Oct 14 23:26:49 2024 +0200
+++ b/test/Grids/mapped_grid_test.jl	Mon Oct 14 23:28:12 2024 +0200
@@ -282,7 +282,7 @@
     @test logical_grid(mg) == lg
     @test collect(mg) == map(x̄, lg)
 
-    @test mapped_grid(lg, x̄, J) == mg
+    @test mapped_grid(x̄, J, lg) == mg
 end
 
 @testset "metric_tensor" begin