diff src/LazyTensors/lazy_tensor_operations.jl @ 1022:bbbc31953367 refactor/sbpoperators/inflation

Introduce an inflate function in lazy tensors and use it in volume_operator and boundary_operator
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 18 Mar 2022 16:57:00 +0100
parents 043d13ef8898
children 52f07c77299d
line wrap: on
line diff
--- a/src/LazyTensors/lazy_tensor_operations.jl	Wed Mar 16 18:39:00 2022 +0100
+++ b/src/LazyTensors/lazy_tensor_operations.jl	Fri Mar 18 16:57:00 2022 +0100
@@ -413,6 +413,19 @@
 ⊗(a::TensorMapping, b::TensorMapping) = LazyOuterProduct(a,b)
 
 
+"""
+    inflate(tm, sz, dir)
+
+Inflate `tm` with identity tensors in all directions `d` for `d != dir`.
+
+# TODO: Describe when it is useful
+"""
+function inflate(tm::TensorMapping, sz, dir)
+    Is = IdentityMapping{eltype(tm)}.(sz)
+    parts = Base.setindex(Is, tm, dir)
+    return foldl(⊗, parts)
+end
+
 function check_domain_size(tm::TensorMapping, sz)
     if domain_size(tm) != sz
         throw(SizeMismatch(tm,sz))