Meshes
======
Before we can compute with functions and solve differential equations on
surfaces, we have to define the surface itself. The ``surfacemesh`` class
encapsulates the definition of the geometry.
A ``surfacemesh`` consists of a collection of high-order quadrilateral *patches*
whose union define the geometry. We choose to represent all patches of the
surface with respect to their embedding space---the three-dimensional Cartesian
coordinate system :math:`(x,y,z)`:
.. figure:: images/mapping.png
:width: 650px
:align: center
Derived quantities such as metric tensor information and Jacobian factors are
automatically computed and abstracted away from the user.
Surface representation
----------------------
Each patch of a ``surfacemesh`` is represented using a set of high-order
nodes---specifically tensor-product Chebyshev nodes.
.. figure:: images/surface_nodes.png
:width: 300px
:align: center
Let's construct the set of tensor-product Chebyshev nodes in :math:`[-1,1]^2`
and plot them:
.. code-block:: matlab
n = 16;
[u, v] = chebpts2(n);
plot(u, v, 'ko', markerfacecolor='k')
axis equal off
.. container:: output-image
.. figure:: images/chebyshev.png
:width: 200px
:align: center
.. raw:: html
ans =
1
Now let's make a surface consisting of a few elements arranged in a 4 x 4 grid
and map them to the graph of a given function.
.. code-block:: matlab
mx = 4;
my = 4;
x = cell(mx*my, 1);
y = cell(mx*my, 1);
z = cell(mx*my, 1);
% Create a random function to define the surface
rng(0)
f = 0.2*randnfun2;
k = 1;
for i = 1:mx
for j = 1:my
% Map the Chebyshev nodes to smaller squares inside [-1,1]^2
% and evaluate the given function
uk = (u+1)/mx + 2/mx*(i-1) - 1;
vk = (v+1)/my + 2/my*(j-1) - 1;
x{k} = uk;
y{k} = f(uk,vk);
z{k} = vk;
k = k+1;
end
end
% Construct the surfacemesh
dom = surfacemesh(x, y, z);
plot(dom), camlight
.. container:: output-image
.. figure:: images/4x4.png
:width: 300px
:align: center
.. raw:: html
ans =
16
Built-in surfaces
-----------------
The ``surfacemesh`` class provides a number of built-in surface generation tools
for creating simple surfaces. We'll start by creating a "cubed sphere" mesh,
which consists of a cube mesh that has been inflated to live on the sphere:
.. code-block:: matlab
% Create a sphere mesh of order p with two levels of refinement:
p = 16;
nref = 2;
dom = surfacemesh.sphere(p+1, nref);
plot(dom), camlight
.. container:: output-image
.. figure:: images/sphere.png
:width: 300px
:align: center
.. raw:: html
ans =
96
- The polynomial order of each patch:
.. code-block:: matlab
order(dom)
.. container:: output-text
.. raw:: html
ans =
16
- The total number of degrees of freedom in the ``surfacemesh``:
.. code-block:: matlab
numel(dom)
.. container:: output-text
.. raw:: html
ans =
27744
- The volume enclosed by a closed ``surfacemesh``:
.. code-block:: matlab
volume(dom) - 4/3*pi
.. container:: output-text
.. raw:: html
ans =
-3.552713678800501e-15
- The surface area of the ``surfacemesh``:
.. code-block:: matlab
surfacearea(dom) - 4*pi
.. container:: output-text
.. raw:: html
ans =
-3.552713678800501e-15
- The smallest box :math:`[x_\text{min}, x_\text{max}] \times [y_\text{min}, y_\text{max}] \times [z_\text{min}, z_\text{max}]`
that contains the ``surfacemesh``:
.. code-block:: matlab
boundingbox(dom)
.. container:: output-text
.. raw:: html
ans =
-1 1 -1 1 -1 1
.. raw:: html