concept-collection / numbl-surfacefun-intro
numbl-surfacefun-intro / mesh_refine.m
28 lines · 776 BBlameHistoryRaw
1% mesh_refine.m — Changing a mesh's resolution.
2%
3% A mesh can be modified by changing the polynomial degree per patch
4% ("p-refinement", via resample) or by splitting patches ("h-refinement",
5% via refine).
7mip load --install flatironinstitute/flatironinstitute/surfacefun
9p = 16;
10dom = surfacemesh.sphere(p + 1, 1);
12figure(1);
13plot(dom, surface='off')
14title(sprintf('Original: %d patches, order %d', length(dom), order(dom)));
16% p-refinement: resample each patch down to 4 nodes per dimension.
17dom2 = resample(dom, 4);
19figure(2);
20plot(dom2, surface='off')
21title(sprintf('Resampled to order %d', order(dom2)));
23% h-refinement: split each patch into four.
24dom3 = refine(dom2);
26figure(3);
27plot(dom3, surface='off')
28title(sprintf('Refined: %d patches', length(dom3)));