-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathrunme.m
More file actions
75 lines (53 loc) · 1.33 KB
/
runme.m
File metadata and controls
75 lines (53 loc) · 1.33 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
clear all;
clc;
close all;
%% Initialize a two component PDE model.
model = createpde();
%% Computational domain, defined by polygon.
gd = [2; 4
0; 1; 1; 0;
0; 0; 1; 1;
];
[dl, bt] = decsg(gd);
% Plot the computational domain.
figure(1);
pdegplot(dl, 'EdgeLabels', 'on', 'FaceLabels', 'on')
axis equal
%% Attach the computational domain to the PDE model.
geometryFromEdges(model, dl);
%% Specify the kind of model from the generic formula.
specifyCoefficients(model, ...
'm', 0, ...
'd', 1, ...
'c', 1, ...
'a', 0, ...
'f', @fn_fxy ...
);
%% Boundary conditions
applyBoundaryCondition(model, ...
'dirichlet', ...
'edge', [1, 2, 3, 4], ...
'u', 0);
%% Initial conditions.
setInitialConditions(model, @fn_u0);
%% Generate mesh.
generateMesh(model, 'Hmax', 0.1);
figure(2)
pdeplot(model)
axis equal
%% Time domain
t = 0:10:100;
%% Solve the PDE
result = solvepde(model, t);
u = result.NodalSolution;
%% Visualize the solution
fig = figure(3);
for i=1:length(t)
pdeplot(model, 'XYData', u(:, i), 'ZData', u(:,i), 'FaceAlpha', 0.5, 'ColorMap', 'default', 'Mesh', 'on')
title("Poisson");
xlabel("x");
ylabel("y");
zlabel("u(x,y,t)");
drawnow limitrate;
F(i)=getframe(fig);
end