/ concept-collection / numbl-surfacefun-intro
Sign in
concept-collection / numbl-surfacefun-intro
numbl-surfacefun-intro / pde_laplace_beltrami.m
37 lines · 1.0 KBBlameHistoryRaw
1% pde_laplace_beltrami.m — Solving a PDE on a surface (surfaceop).
2%
3% surfaceop is a fast direct solver for second-order linear elliptic PDEs
4% on surfaces. Here we solve a Laplace-Beltrami problem on the sphere,
5% where the spherical harmonics give an exact solution to check against.
7mip load --install flatironinstitute/flatironinstitute/surfacefun
9p = 16;
10nref = 2;
11dom = surfacemesh.sphere(p + 1, nref);
13% Exact solution: a spherical harmonic Y_lm is an eigenfunction of the
14% Laplace-Beltrami operator with eigenvalue -l(l+1).
15l = 3;
16m = 2;
17sol = spherefun.sphharm(l, m);
18sol = surfacefun(@(x, y, z) sol(x, y, z), dom);
19f = -l*(l + 1)*sol;
21% Define the operator (pdo.lap = 1 is the Laplace-Beltrami operator).
22pdo = [];
23pdo.lap = 1;
25L = surfaceop(dom, pdo, f);
27% The closed-surface problem is rank-deficient by one; impose the
28% mean-zero condition.
29L.rankdef = true;
31u = L.solve();
33figure(1);
34plot(u), colorbar
35title('Laplace-Beltrami solution on the sphere');
37fprintf('error || u - sol || = %.3e\n', norm(u - sol));
moveopenescclose