changeset 1910:15be190a40cd feature/grids/parameter_spaces

Add boundary_intifiers(::Interval) and boundary_identifiers(::HyperBox)
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 07 Feb 2025 15:29:05 +0100
parents 4209290cb377
children 449cce897da9 48c49c04f3b2
files src/Grids/parameter_space.jl test/Grids/parameter_space_test.jl
diffstat 2 files changed, 31 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
diff -r 4209290cb377 -r 15be190a40cd src/Grids/parameter_space.jl
--- a/src/Grids/parameter_space.jl	Fri Feb 07 15:28:01 2025 +0100
+++ b/src/Grids/parameter_space.jl	Fri Feb 07 15:29:05 2025 +0100
@@ -45,6 +45,8 @@
 """
 limits(i::Interval) = (i.a, i.b)
 
+boundary_identifiers(::Interval) = (LowerBoundary(), UpperBoundary())
+
 """
     unitinterval(T=Float64)
 
@@ -91,6 +93,16 @@
 """
 limits(box::HyperBox) = (box.a, box.b)
 
+function boundary_identifiers(box::HyperBox)
+    mapreduce(vcat, 1:ndims(box)) do d
+        [
+            CartesianBoundary{d, LowerBoundary}(),
+            CartesianBoundary{d, UpperBoundary}(),
+        ]
+    end
+end
+
+
 """
     unitsquare(T=Float64)
 
diff -r 4209290cb377 -r 15be190a40cd test/Grids/parameter_space_test.jl
--- a/test/Grids/parameter_space_test.jl	Fri Feb 07 15:28:01 2025 +0100
+++ b/test/Grids/parameter_space_test.jl	Fri Feb 07 15:29:05 2025 +0100
@@ -20,6 +20,8 @@
     @test unitinterval(Int) isa Interval{Int}
     @test unitinterval(Int) == Interval(0,1)
     @test limits(unitinterval(Int)) == (0,1)
+
+    @test boundary_identifiers(unitinterval()) == (LowerBoundary(), UpperBoundary())
 end
 
 @testset "HyperBox" begin
@@ -40,6 +42,23 @@
 
     @test unithyperbox(4) isa HyperBox{Float64,4}
     @test limits(unithyperbox(4)) == ([0,0,0,0],[1,1,1,1])
+
+
+    @test boundary_identifiers(unitsquare()) == [
+        CartesianBoundary{1,LowerBoundary}(),
+        CartesianBoundary{1,UpperBoundary}(),
+        CartesianBoundary{2,LowerBoundary}(),
+        CartesianBoundary{2,UpperBoundary}(),
+    ]
+
+    @test boundary_identifiers(unitcube()) == [
+        CartesianBoundary{1,LowerBoundary}(),
+        CartesianBoundary{1,UpperBoundary}(),
+        CartesianBoundary{2,LowerBoundary}(),
+        CartesianBoundary{2,UpperBoundary}(),
+        CartesianBoundary{3,LowerBoundary}(),
+        CartesianBoundary{3,UpperBoundary}(),
+    ]
 end
 
 @testset "Simplex" begin