-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdemo1.m
58 lines (41 loc) · 1.2 KB
/
demo1.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
50
51
52
53
54
55
56
% DEMO1
%
% Description
% Move an interface in a "pinching" velocity field. Phi is kept relatively
% close to a signed distance function.
%
% This demo shows the merging and separation of two interfaces, as well as
% the interfaces leaving the grid.
% Print out help message.
help demo1
%
% Initialize grid.
%
lset_grid([80 80]);
%
% Construct the initial structure/interface.
%
phi = lset_circle([-10 0], 3);
phi = lset_union(phi, lset_circle([10 0], 3));
%
% Construct the signed distance function for the interface.
%
[phi, err] = signed_distance(phi, 1e-1);
%
% Construct a "pinching" velocity field.
%
V = lset_velfield(@(x, y) -(x+0.1).^-1 .* (abs(y)+1).^-1, @(x, y) 0.2*sign(y));
%
% 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, V, 0, 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