/ concept-collection / numbl-surfacefun-intro
Sign in
concept-collection / numbl-surfacefun-intro
numbl-surfacefun-intro / pde_open_surface.m
36 lines · 1.0 KBCodeBlameHistory
12d8453Intro to surfacefun: interactive numbl example projectJeremy Magland 1% pde_open_surface.m — A PDE on an open surface, with boundary data.
2%
3% On an open surface, surfaceop.solve takes Dirichlet boundary data. And
4% because surfaceop is a direct solver, one factorization can be reused
5% for many right-hand sides — much cheaper than rebuilding it each time.
7mip load --install flatironinstitute/flatironinstitute/surfacefun
9% Build an open surface by keeping a subset of a blob's patches.
10rng(0)
11p = 16;
12nref = 2;
13dom = surfacemesh.blob(p + 1, nref);
14dom = surfacemesh(dom.x(1:16), dom.y(1:16), dom.z(1:16));
16figure(1);
17plot(dom), view(-110, 30), camlight
18title('Open surface (subset of a blob)');
20% Solve Delta_Gamma u = -1 with zero Dirichlet data on the boundary.
21pdo = [];
22pdo.lap = 1;
23L = surfaceop(dom, pdo, -1);
24u = L.solve(0);
26figure(2);
27plot(u), view(-110, 30), colorbar
28title('Solution, rhs = -1, u = 0 on boundary');
30% Reuse the same factorization with a new right-hand side.
31L.rhs = @(x, y, z) sin(x .* y);
32u = L.solve(0);
34figure(3);
35plot(u), view(-110, 30), colorbar
36title('Reused solver, rhs = sin(xy)');
moveopenescclose