You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.0 KiB

3 years ago
%--------------------------
% @Author: Jingqiao Hu
% @Date: 2021-12-28 21:34:40
% @LastEditTime: 2022-01-08 22:41:19
% the mesh and MMCs are independent,
% which means the MMCs is moving and the mesh remains unchanged
% c_interPolyMMC: the intersected polygon for each mmc
% c_interPolySeed: the intersected polygon for each seed
%--------------------------
function [c_rho, c_phi] = projection_independent(nodes_cell, faces_cell, ...
MMCs, epsilon, c_nnbEdgeIDX, c_interPolySeed)
ncvt = size(nodes_cell, 1);
c_phi = init_phi(ncvt, nodes_cell);
c_rho = cell(ncvt, 1);
for i = 1 : ncvt
pid = c_interPolySeed{i};
mid = c_nnbEdgeIDX{i};
for j = 1 : length(mid)
mmc = MMCs(mid(j), :);
for k = 1 : length(pid)
ele = pid(k);
nodes = nodes_cell{ele};
phi = tPhi(mmc, nodes(:,1), nodes(:,2));
c_phi{ele} = max(phi, c_phi{ele});
end
end
end
% Heaviside
% figure; clf
parfor ele = 1 : ncvt
H = Heaviside_simply(c_phi{ele}, epsilon);
faces = faces_cell{ele};
c_rho{ele} = sum(H(faces), 2) / 3;
% nodes = nodes_cell{ele};
% patch('Faces',faces,'Vertices',nodes,'FaceVertexCData',1 - H','FaceColor','interp','EdgeColor','interp'); hold on;
end
% colormap("gray"); axis equal; axis off; pause(1e-6);
% % projection of signed distance
% for i = 1 : nmmcs
% mmc = MMCs(i, :);
% r = c_interPolyMMC{i};
% % for all intersected cell
% for k = 1 : length(r)
% ele = r(k);
% nodes = nodes_cell{ele};
% phi = tPhi(mmc, nodes(:,1), nodes(:,2));
% c_phi{ele} = max(phi, c_phi{ele});
% end
% end
end
function phi_cell = init_phi(ncvt, nodes_cell)
phi_cell = cell(ncvt, 1);
parfor ele = 1:ncvt
phi_cell{ele} = repmat(-1e5, size(nodes_cell{ele}, 1), 1);
end
end