changeset 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 607c631f175e
children 14fee299ada2
files +multiblock/Grid.m
diffstat 1 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
diff -r 607c631f175e -r 67228a10dfad +multiblock/Grid.m
--- 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)