concept-collection / numbl-surfacefun-intro
numbl-surfacefun-intro / mesh_sphere.m
23 lines · 815 BBlameHistoryRaw
1% mesh_sphere.m — The built-in "cubed sphere".
2%
3% surfacemesh.sphere inflates a cube mesh onto the sphere. The first
4% argument is the number of nodes per dimension (order p plus one); the
5% second is the number of refinement levels.
7mip load --install flatironinstitute/flatironinstitute/surfacefun
9p = 16;
10nref = 2;
11dom = surfacemesh.sphere(p + 1, nref);
13figure(1);
14plot(dom), camlight
15title('Cubed sphere');
17% A few queries about the mesh:
18fprintf('patches: %d\n', length(dom));
19fprintf('order per patch: %d\n', order(dom));
20fprintf('degrees of freedom:%d\n', numel(dom));
21fprintf('surface area err: %.2e (vs 4*pi)\n', surfacearea(dom) - 4*pi);
22fprintf('enclosed vol err: %.2e (vs 4/3*pi)\n', volume(dom) - 4/3*pi);
23fprintf('bounding box: [%g %g %g %g %g %g]\n', boundingbox(dom));