diff +multiblock/Grid.m @ 1331:60c875c18de3 feature/D2_boundary_opt

Merge with feature/poroelastic for Elastic schemes
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Thu, 10 Mar 2022 16:54:26 +0100
parents ce422ba8964e
children
line wrap: on
line diff
--- a/+multiblock/Grid.m	Thu Feb 17 18:55:11 2022 +0100
+++ b/+multiblock/Grid.m	Thu Mar 10 16:54:26 2022 +0100
@@ -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)
@@ -155,16 +176,16 @@
         end
 
         % Return coordinates for the given boundary/boundaryGroup
-        function b = getBoundary(obj, boundary)
+        function b = getBoundary(obj, boundary, varargin)
             switch class(boundary)
                 case 'cell'
                     I = boundary{1};
                     name = boundary{2};
-                    b = obj.grids{I}.getBoundary(name);
+                    b = obj.grids{I}.getBoundary(name, varargin{:});
                 case 'multiblock.BoundaryGroup'
                     b = sparse(0,obj.D());
                     for i = 1:length(boundary)
-                        b = [b; obj.getBoundary(boundary{i})];
+                        b = [b; obj.getBoundary(boundary{i}, varargin{:})];
                     end
                 otherwise
                     error('Unknown boundary indentifier')