NiHu  2.0
kltria_surface_test.m
1 clear;
2 Le = 5e-2;
3 L = [1 1];
4 mesh = quad2tria(create_slab(L, ceil(L/Le)));
5 % mesh = quad2tria(create_circle(L(1), ceil(L(1)/Le)));
6 field_var = [2 1; 1 2];
7 space_var = [
8  10 .1 0
9  .1 .3 0
10  0 0 1
11  ];
12 [nodes, elements] = extract_core_mesh(mesh);
13 [D, B] = kltria_surface(nodes, elements, field_var, space_var);
14 D = (D + D') / 2;
15 B = (B + B') / 2;
16 nModes = 100;
17 [g, Lambda] = eigs(D, B, nModes);
18 lambda = diag(Lambda);
19 
20 %%
21 figure;
22 for n = 1 : 8
23  subplot(2,4,n);
24  plot_mesh(mesh, g(2:2:end,n));
25  shading interp;
26  hold on;
27  quiver(nodes(:,1), nodes(:,2), g(1:2:end,n), g(2:2:end,n), 'Color', 'black');
28  axis equal tight off
29 end
30 
31 %% generate random process
32 nReals = 8;
33 reals = g * diag(real(sqrt(lambda))) * randn(nModes, nReals);
34 figure;
35 for n = 1 : nReals
36  subplot(2,4,n);
37  p = reals(:,n);
38  p = reshape(p, 2, [])';
39  P = sqrt(dot(p,p,2));
40  plot_mesh(mesh, P);
41  shading interp;
42  hold on;
43  quiver(nodes(:,1), nodes(:,2), p(:,1), p(:,2), 'Color', 'black');
44  axis equal tight off
45  caxis([0 max(abs(P))]);
46 end