changeset 285:e21dcda55163 boundary_conditions

Add type representing an unknown dimension in the domain of tensormappings
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Fri, 19 Jun 2020 12:20:31 +0200
parents 0b8e041a1873
children 7247e85dc1e8 0c756922b195
files DiffOps/src/laplace.jl DiffOps/test/runtests.jl LazyTensors/src/tensor_mapping.jl
diffstat 3 files changed, 18 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/DiffOps/src/laplace.jl	Thu Jun 18 22:07:10 2020 +0200
+++ b/DiffOps/src/laplace.jl	Fri Jun 19 12:20:31 2020 +0200
@@ -102,9 +102,9 @@
 # Can we give special treatment to TensorMappings that go to a higher dim?
 function LazyTensors.range_size(e::BoundaryValue{T}, domain_size::NTuple{1,Integer}) where T
     if dim(e.bId) == 1
-        return (missing, domain_size[1])
+        return (UnknownDim, domain_size[1])
     elseif dim(e.bId) == 2
-        return (domain_size[1], missing)
+        return (domain_size[1], UnknownDim)
     end
 end
 LazyTensors.domain_size(e::BoundaryValue{T}, range_size::NTuple{2,Integer}) where T = (range_size[3-dim(e.bId)],)
@@ -139,9 +139,9 @@
 # Can we give special treatment to TensorMappings that go to a higher dim?
 function LazyTensors.range_size(e::NormalDerivative, domain_size::NTuple{1,Integer})
     if dim(e.bId) == 1
-        return (missing, domain_size[1])
+        return (UnknownDim, domain_size[1])
     elseif dim(e.bId) == 2
-        return (domain_size[1], missing)
+        return (domain_size[1], UnknownDim)
     end
 end
 LazyTensors.domain_size(e::NormalDerivative, range_size::NTuple{2,Integer}) = (range_size[3-dim(e.bId)],)
--- a/DiffOps/test/runtests.jl	Thu Jun 18 22:07:10 2020 +0200
+++ b/DiffOps/test/runtests.jl	Fri Jun 19 12:20:31 2020 +0200
@@ -129,10 +129,10 @@
     G_n = zeros(Float64, (4,5))
     G_n[:,5] = g_x
 
-    @test size(e_w*g_y) === (missing,5)
-    @test size(e_e*g_y) === (missing,5)
-    @test size(e_s*g_x) === (4,missing)
-    @test size(e_n*g_x) === (4,missing)
+    @test size(e_w*g_y) == (UnknownDim,5)
+    @test size(e_e*g_y) == (UnknownDim,5)
+    @test size(e_s*g_x) == (4,UnknownDim)
+    @test size(e_n*g_x) == (4,UnknownDim)
 
     # These tests should be moved to where they are possible (i.e we know what the grid should be)
     @test_broken collect(e_w*g_y) == G_w
@@ -206,10 +206,10 @@
     G_n = prod_matrix(g_x, d_y_u)
 
 
-    @test size(d_w*g_y) === (missing,6)
-    @test size(d_e*g_y) === (missing,6)
-    @test size(d_s*g_x) === (5,missing)
-    @test size(d_n*g_x) === (5,missing)
+    @test size(d_w*g_y) == (UnknownDim,6)
+    @test size(d_e*g_y) == (UnknownDim,6)
+    @test size(d_s*g_x) == (5,UnknownDim)
+    @test size(d_n*g_x) == (5,UnknownDim)
 
     # These tests should be moved to where they are possible (i.e we know what the grid should be)
     @test_broken collect(d_w*g_y) ≈ G_w
--- a/LazyTensors/src/tensor_mapping.jl	Thu Jun 18 22:07:10 2020 +0200
+++ b/LazyTensors/src/tensor_mapping.jl	Fri Jun 19 12:20:31 2020 +0200
@@ -62,7 +62,12 @@
 """
 function domain_size end
 
-export range_size, domain_size
+"""
+    Dummy type for representing dimensions of tensormappings when domain_size is unknown
+"""
+struct UnknownDim end
+export range_size, domain_size, TensorMappingDim, UnknownDim
+
 # TODO: Think about boundschecking!