From 75070fbf0e3ae8e0bdfc0cc491c89b871766b1f6 Mon Sep 17 00:00:00 2001 From: Ivar Stefansson <ist050@uib.no> Date: Wed, 21 Dec 2016 18:28:31 +0100 Subject: [PATCH] Replace combine_faces.m --- scripts/combine_faces.m | 46 ++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/scripts/combine_faces.m b/scripts/combine_faces.m index c77bd9d..70b4a75 100644 --- a/scripts/combine_faces.m +++ b/scripts/combine_faces.m @@ -1,23 +1,23 @@ -function [cell_vertices_on, vertices_p] = combine_faces(cell_vertices_on, vertices_p,isvertical) -%UNTITLED2 calculates the average of the two pressure values for the faces -% which coincide with the line - -if isvertical - cell_xory = sort([cell_vertices_on(:,2),cell_vertices_on(:,4),],2); -else - cell_xory = sort([cell_vertices_on(:,1),cell_vertices_on(:,3),],2); -end -for i = 1:length(vertices_p)/2 % two values for each face - ind = ismember(cell_xory(:,1),cell_xory(i,1)); - r = find(ind); - n = length(ind); - % remove the second cell - cell_vertices_on = [cell_vertices_on(1:r(2)-1,:);cell_vertices_on(r(2)+1:n,:)]; - cell_xory = [cell_xory(1:r(2)-1,:); cell_xory(r(2)+1:n, :)]; - % replace the first pressure by the mean of the two - vertices_p(r(1)) = mean(vertices_p(ind)); - % and remove the second one - vertices_p = [vertices_p(1:r(2)-1);vertices_p(r(2)+1:n)]; - -end -end +function [cellVerticesOn, verticesP] = combine_faces(cellVerticesOn, verticesP,isVertical) +%combine_faces calculates the average of the two pressure values for the faces +% which coincide with the line + +if isVertical + cellXOrY = sort([cellVerticesOn(:,2),cellVerticesOn(:,4),],2); +else + cellXOrY = sort([cellVerticesOn(:,1),cellVerticesOn(:,3),],2); +end +for i = 1:length(verticesP)/2 % two values for each face + ind = ismember(cellXOrY(:,1),cellXOrY(i,1)); + r = find(ind); + n = length(ind); + % remove the second cell + cellVerticesOn = [cellVerticesOn(1:r(2)-1,:);cellVerticesOn(r(2)+1:n,:)]; + cellXOrY = [cellXOrY(1:r(2)-1,:); cellXOrY(r(2)+1:n, :)]; + % replace the first pressure by the mean of the two + verticesP(r(1)) = mean(verticesP(ind)); + % and remove the second one + verticesP = [verticesP(1:r(2)-1);verticesP(r(2)+1:n)]; + +end +end -- GitLab