Skip to content
Snippets Groups Projects
Commit 75070fbf authored by Ivar Stefansson's avatar Ivar Stefansson
Browse files

Replace combine_faces.m

parent 228ab67c
No related branches found
No related tags found
No related merge requests found
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment