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.
66 lines
2.0 KiB
66 lines
2.0 KiB
3 years ago
|
%--------------------------
|
||
|
% @Author: Jingqiao Hu
|
||
|
% @Date: 2021-12-29 10:34:40
|
||
|
% @LastEditTime: 2022-01-30 20:34:27
|
||
|
|
||
|
% only update the projection of the neighbor cell of curr_idx, for efficiency
|
||
|
%--------------------------
|
||
|
function [c_rho1, interEles] = update_projection(nodes_cell, faces_cell, MMCs, ...
|
||
|
epsilon, c_rho, c_phi, c_nnbEdgeIDX, c_interPolySeed, local_idx)
|
||
|
|
||
|
npnts = length(local_idx);
|
||
|
|
||
|
% CHECK: is it possible this pgon is effected by other MMC not here?
|
||
|
[c_phi, interEles] = init_phi(local_idx, c_interPolySeed, c_phi); % important
|
||
|
|
||
|
for i = 1 : npnts
|
||
|
sid = local_idx(i); % seed-id
|
||
|
pid = c_interPolySeed{sid}; % pgon-id intersected with this seed
|
||
|
mid = c_nnbEdgeIDX{i}; % MMCs-id corresponding this seed
|
||
|
|
||
|
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
|
||
|
|
||
|
c_rho1 = c_rho;
|
||
|
|
||
|
% Heaviside
|
||
|
% figure; clf
|
||
|
for i = 1 : length(interEles)
|
||
|
ele = interEles(i);
|
||
|
|
||
|
H = Heaviside_simply(c_phi{ele}, epsilon);
|
||
|
|
||
|
faces = faces_cell{ele};
|
||
|
c_rho1{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);
|
||
|
end
|
||
|
|
||
|
function [phi_cell, interEles] = init_phi(local_idx, c_interPolySeed, phi_cell)
|
||
|
|
||
|
interEles = [];
|
||
|
for i = 1:length(local_idx)
|
||
|
sid = local_idx(i);
|
||
|
pid = c_interPolySeed{sid}; % pgon-id intersected with this seed
|
||
|
|
||
|
for j = 1 : length(pid)
|
||
|
ele = pid(j);
|
||
|
phi_cell{ele}(:) = -1e5;
|
||
|
end
|
||
|
interEles = [interEles; pid];
|
||
|
end
|
||
|
interEles = unique(interEles);
|
||
|
end
|