Skip to content

Commit

Permalink
Example updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
wonjunee committed Jan 19, 2021
1 parent c11dade commit ec938f2
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions example_incompressible.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
% Parameters
n = 512; % The size of the grid
maxIters = 300; % Maximum iterations for the Back-and-Forth method
TOL = 4e-2; % Tolerance for the Back-and-Forth method
TOL = 3e-2; % Tolerance for the Back-and-Forth method
nt = 200; % The number of outer iterations
tau = 0.01; % Time step for JKO scheme
tau = 0.005; % Time step for JKO scheme
verbose = 1; % print out logs
folder = 'data'; % Set the filename

Expand Down Expand Up @@ -35,37 +35,35 @@
subplot(1,2,1)
imagesc(mu);
title("initial density")
colormap bone
% colormap bone
axis square

hold on
subplot(1,2,2)
imagesc(result);
title("final density")
colormap bone
% colormap bone
axis square
hold off

saveas(gcf, "./figures/initial-final.png");

subplot(1,3,1)
imagesc(mu);
contourf(x,y,mu);
title("initial density")
% colormap bone
axis square

hold on
subplot(1,3,2)
imagesc(V);
contourf(x,y,V);
title("V")
% colormap bone
axis square

hold on
subplot(1,3,3)
imagesc(obstacle);
contourf(x,y,obstacle);
title("Obstacle")
% colormap bone
colormap(gca, 'copper')
axis square

hold off
Expand All @@ -79,18 +77,18 @@
for i = 0:nt
file = fopen(sprintf("%s/rho-%04d.dat", folder, i), 'r');
rho = fread(file, [n n], 'double');
imagesc(rho);
colormap bone
imagesc(rho)
axis square
set(gca,'XTickLabel',[], 'YTickLabel',[])

frame = getframe(fig);
im = frame2im(frame);
[X,cmap] = rgb2ind(im, 256);

% Write to the GIF file
if i == 0
imwrite(X, cmap, movieName, 'gif', 'DelayTime', 0.000, 'Loopcount', inf);
imwrite(X, cmap, movieName, 'gif', 'Loopcount',inf, 'DelayTime',0.03);
else
imwrite(X, cmap, movieName, 'gif', 'DelayTime', 0.000, 'WriteMode', 'append');
imwrite(X, cmap, movieName, 'gif', 'WriteMode','append', 'DelayTime',0.03);
end
end

0 comments on commit ec938f2

Please sign in to comment.