diff +multiblock/Grid.m @ 881:67228a10dfad feature/poroelastic

Add method expandFunc to multiblock.Grid
author Martin Almquist <malmquist@stanford.edu>
date Fri, 26 Oct 2018 15:41:26 -0700
parents a55d3c1e1f83
children e54c2f54dbfe ce422ba8964e
line wrap: on
line diff
--- a/+multiblock/Grid.m	Wed Oct 24 16:17:32 2018 -0700
+++ b/+multiblock/Grid.m	Fri Oct 26 15:41:26 2018 -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)