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.
 
 
 
 

56 lines
1.7 KiB

%--------------------------
% @Author: Jingqiao Hu
% @Date: 2021-12-10 14:30:54
% @LastEditTime: 2021-12-15 11:11:39
%--------------------------
function plotting_MMC(MMCs, maxx, minx, maxy, miny, pb,optDesign,loop)
globaly = (maxy - miny) * 2;
globalx = (maxx - minx) * 2;
dx = (maxx - minx) / globalx;
[coorx, coory] = meshgrid(dx * [-globalx/2 : globalx/2], dx * [-globaly/2 :globaly/2]);
phi_max = repmat(-1e5, globaly+1, globalx+1);
% phi0 = 0;
parfor ele = 1 : size(MMCs, 1)
mmc = MMCs(ele, :);
nc = size(mmc, 1);
for i = 1:nc
phi = tPhi(mmc(i, :), coorx, coory);
phi_max = max(phi_max, phi);
% phi0 = phi0 + exp(pb * phi);
end
end
% phi_max = log(phi0) / pb;
figure(2); clf; contourf(coorx, coory, reshape(phi_max, globaly+1, globalx+1), [0,0], 'LineWidth',1);
% plot bounding box
if strcmp(optDesign, 'Lshape')
bbx_x = [minx,maxx,maxx,0,0, minx,minx]';
bbx_y = [miny,miny,0, 0,maxy,maxy,miny]';
else
bbx_x = [minx,maxx,maxx,minx,minx]';
bbx_y = [miny,miny,maxy,maxy,miny]';
end
hold on; plot(bbx_x,bbx_y,'k','LineWidth',1);
axis equal; axis off; pause(1e-6);
colormap(gray); caxis([-2,1]);
% datapath = "data/fig/"+optDesign+"_"+loop+".pdf";
% saveas(gcf, datapath);
end
function H = Heaviside(phi, epsilon)
alpha=1e-3; % parameter alpha in the Heaviside function
phi = phi(:);
num_all=[1 : length(phi)]';
num1=find(phi>epsilon);
H(num1)=1;
num2=find(phi<-epsilon);
H(num2)=alpha;
num3=setdiff(num_all,[num1;num2]);
H(num3)=3*(1-alpha)/4*(phi(num3)/epsilon-phi(num3).^3/(3*(epsilon)^3))+ (1+alpha)/2;
end