-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.m
30 lines (30 loc) · 871 Bytes
/
main.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
%%
% More documentation here:
% help pLaplaceSolverNew
% help NesterovPathFollowingNew
p = 1.0; % The p of the p-Laplacian
% This next bit is a quick-and-dirty way of generating a FEM mesh
G = numgrid('S',52);
[I,J] = find(G);
V = [I J];
V = V-repmat(min(V),size(V,1),1);
V = V./repmat(max(V),size(V,1),1);
T = delaunay(V);
% Make up some boundary conditions
d = find(((V(:,2)>=0.25) & (V(:,2)<=0.75) & (V(:,1)==0)) | ((V(:,1)>0.6) & (V(:,2)>=0.25)));
g = zeros(size(V,1),1);
g(d) = 1;
% Zero forcing
f = zeros(size(T,1),1);
% Solve
[ u,SOL ] = pLaplaceSolverNew( T,V,f,p,g );
% Plot solution
close all;
disp(sprintf('done, its = %d, elapsed=%.3fs',length(SOL.lambda),SOL.elapsed));
patch('Faces',T,'Vertices',V,'FaceColor','interp','FaceVertexCData',u,'EdgeColor','none');
hold on;
plot(V(:,1),V(:,2),'.k','markers',0.5);
hold off;
colorbar;
axis square;
drawnow;