Mercurial > repos > public > sbplib
view surfSym.m @ 1037:2d7ba44340d0 feature/burgers1d
Pass scheme specific parameters as cell array. This will enabale constructDiffOps to be more general. In addition, allow for schemes returning function handles as diffOps, which is currently how non-linear schemes such as Burgers1d are implemented.
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Fri, 18 Jan 2019 09:02:02 +0100 |
parents | bcddbc2beef4 |
children |
line wrap: on
line source
function h = surfSym(X,Y,Z) if isvector(X) && isvector(Y) [X,Y] = meshgrid(X,Y); end V_nodes = [X(:), Y(:), Z(:)]; X_centers = neighbourMean(X); Y_centers = neighbourMean(Y); Z_centers = neighbourMean(Z); V_centers = [X_centers(:), Y_centers(:), Z_centers(:)]; N = prod(size(X)); nodeIndecies = reshape(1:N, size(X)); centerIndecies = reshape(N+(1:prod(size(X)-[1,1])), size(X) - [1,1]); % figure() % h = line(V_nodes(:,1),V_nodes(:,2),V_nodes(:,3)); % h.LineStyle = 'none'; % h.Marker = '.'; % h = line(V_centers(:,1),V_centers(:,2),V_centers(:,3)); % h.LineStyle = 'none'; % h.Marker = '.'; % h.Color = Color.red; % axis equal I_0 = nodeIndecies(1:end-1, 1:end-1); I_1 = nodeIndecies(2:end, 1:end-1); I_2 = nodeIndecies(2:end, 2:end); I_3 = nodeIndecies(1:end-1, 2:end); I_C = centerIndecies; S.Vertices = [ V_nodes; V_centers; ]; S.Faces = [ I_0(:), I_1(:), I_C(:); I_1(:), I_2(:), I_C(:); I_2(:), I_3(:), I_C(:); I_3(:), I_0(:), I_C(:); ]; % figure() h = patch(S, 'FaceVertexCData', S.Vertices(:,3),'FaceColor','flat'); end % Calculate the mean of four neighbours around a patch function M = neighbourMean(A) M = (A(1:end-1, 1:end-1) + A(2:end, 1:end-1) + A(1:end-1, 2:end) + A(2:end, 2:end))/4; end