changeset 1135:a0c6f060a105 feature/laplace_curvilinear_test

Add multiblock.Grid.expandFunc()
author Martin Almquist <malmquist@stanford.edu>
date Thu, 30 May 2019 12:07:40 -0700
parents 7259b3f3e227
children eee71789f13b
files +multiblock/Grid.m
diffstat 1 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
diff -r 7259b3f3e227 -r a0c6f060a105 +multiblock/Grid.m
--- a/+multiblock/Grid.m	Mon May 27 16:53:32 2019 -0700
+++ b/+multiblock/Grid.m	Thu May 30 12:07:40 2019 -0700
@@ -132,6 +132,27 @@
 
         end
 
+        % Pads a grid function that lives on a subgrid with
+        % zeros and gives it the size that mathces obj.
+        function gf = expandFunc(obj, gfSub, subGridId)
+            nComponents = length(gfSub)/obj.grids{subGridId}.N();
+            nBlocks = numel(obj.grids);
+
+            % Create sparse block matrix
+            gfs = cell(nBlocks,1);
+            for i = 1:nBlocks
+                N = obj.grids{i}.N()*nComponents;
+                gfs{i} = sparse(N, 1);
+            end
+
+            % Insert local gf
+            gfs{subGridId} = gfSub;
+
+            % Convert cell to vector
+            gf = blockmatrix.toMatrix(gfs);
+
+        end
+
         % Find all non interface boundaries of all blocks.
         % Return their grid.boundaryIdentifiers in a cell array.
         function bs = getBoundaryNames(obj)