-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdemo3.m
51 lines (37 loc) · 1.09 KB
/
demo3.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
% DEMO3
%
% Description
% Demonstrate interface movement in the normal direction.
%
% Godunov's scheme is used to choose the most appropriate spatial
% derivative. This is an attempt to correctly handle characteristics such
% as the shock that forms where the two circles meet.
% Print out help message.
help demo3
%
% Initialize grid.
%
lset_grid([160 160]);
%
% Construct the initial structure/interface.
%
phi = lset_circle([-35 0], 15);
phi = lset_union(phi, lset_circle([35 0], 15));
%
% Construct the signed distance function for the interface.
%
[phi, err] = signed_distance(phi, 1e-1);
%
% Move the surface within the velocity field, keep phi "close" to a
% signed distance function.
%
while (true)
lset_plot(phi); drawnow; % Visualize.
phi = update_interface(phi, [], 1, 0); % Move the interface.
try
[phi, err] = signed_distance(phi, 1e-3); % Make phi more sdf-like.
catch
lset_plot(phi); % Visualize.
break; % If signed_distance failed, we have no more interfaces.
end
end