Geometry

7. Geometry#

st_point_collocation(npanels, nbasis, fn)#

Generate collocation points.

The struct that is returned contains the following fields

  • nodes.basis_sym: symbolic representation of each (Lagrange) basis function.

  • nodes.basis: cell array of size (nbasis,) of Lagrange polynomial basis function handles. Each function handles takes as an argument nodes from a reference element.

  • nodes.dbasis and nodes.ddbasis: cell array of size (nbasis,) of the first- and second-order derivatives of each element in basis.

  • nodes.unit_xi: array of size (nbasis,) of collocation nodes on a reference \([-1, 1]\) element.

  • npanels.

  • nbasis.

  • xi: array of size (1, npanels * (nbasis - 1) + 1) of collocation nodes on a uniform \([0, 0.5]\) parametrization. The size is due to the fact that collocation points at panel endpoints appear only once in the array.

  • panels: real array of size (npanels + 1,) of panel endpoints in xi.

  • x: complex array of size (1, npanels * (nbasis - 1) + 1) of points describing the curve in 2D. (only if fn is provided).

  • vertices: complex array of size (npanels + 1,) containing the panel endpoints on the 2D curve. (only if fn is provided)

Parameters:
  • npanels – number of panels (or elements).

  • nbasis – number of collocation points in each panel. In the case of collocation points, the end points are shared between panels. Should be an even number so that the quadrature and collocation sets of points don’t overlap.

  • fn@(xi) function handle defining the geometry that takes the parametrization \(\xi \in [0, 0.5]\) and returns the \(x\) coordinates of each point as a complex number.

Returns:

a struct describing the high-order surface.

st_point_quadrature(npanels, nnodes, fn, method, a, b)#

Generate quadrature nodes and weights.

The struct that is returned contains the following fields

  • quad.unit_xi: array of size, (nnodes,) of quadrature nodes on a reference \([-1, 1]\) element.

  • quad.unit_w: array of size (nnodes,) of quadrature weights on a reference \([-1, 1]\) element.

  • nnodes.

  • npanels.

  • xi: array of size (1, npanels * nnodes) of quarature nodes on a uniform \([0, 0.5]\) parametrization.

  • w: array of size (1, npanels * nnodes) of quadrature weights on a uniform \([0, 0.5]\) parametrization.

  • x: complex array of size (1, npanels * nnodes) describing the curve in 2D. (only if fn is provided)

  • vertices: complex array of size (1, npanels + 1) containing the panel endpoints on the 2D curve. (only if fn is provided)

Parameters:
  • npanels – number of panels.

  • nnodes – number of quadrature nodes per panel.

  • fn@(xi) function handle defining the geometry that takes the parametrization \(\xi \in [0, 0.5]\) and returns the \(x\) coordinates of each point as a complex number.

  • method – quadrature method that is used. The two regular quadrature rules supported are 'leggauss' for st_quad_leggauss() and 'fejer' for st_quad_fejer().

  • a (default 0.0) – xi interval start.

  • b (default 0.5) – xi interval end.

Returns:

a struct of describing the surface quadrature.

st_mesh_geometry(x, y)#

Compute geometry.

The resulting structs t and s contain all the fields normally added by st_mesh_target_geometry() and all the fields of x and y, if they are structs as well (uses st_struct_update()).

Generally, the user would want to generate all the required geometry information as follows:

shape_fn = @(xi) exp(2.0j * pi * xi);
x = st_point_collocation(npanels, nbasis, shape_fn);
y = st_point_quadrature(npanels, nnodes);
[x, y] = st_mesh_geometry(x, y);

to get all fields required in most functions.

Parameters:
  • x – target node information. It can be a complex array of collocation points or a struct with an x field (as returned by st_point_collocation()).

  • y – source node information. It can be a real array of points in \([0, 0.5]\), where the source geometry is evaluated, or a struct with a xi field (as returned by st_point_quadrature()).

Returns:

target geometry t, as returned by st_mesh_target_geometry() and evaluated at the collocation points, with any additional fields from the input x.

Returns:

source geometry s, evaluated at the quadrature points, if provided. The source geometry is computed by interpolating from the target geometry in st_mesh_source_geometry().

st_mesh_geometry_update(x, y, xnew, with_geometry)#

Update a given geometry to a new set of collocation points.

This function updates the new points and calls st_mesh_geometry() to recompute all the geometrical quantities on the new curve.

Parameters:
  • x – existing target geometry information.

  • y – existing source geometry information.

  • xnew – a new set of node coordinates with the same size as x.xi. This can also be a function handle, in which case it is just evaluated on the computational grid x.xi.

Returns:

a tuple (x, y) with the target and source geometries.

st_mesh_target_geometry(x)#

Compute geometry using Fourier-based interpolation.

The Fourier coefficients for the parametrization are also returned. Note that they describe the whole curve, not just the top half-plane, since they are required to be periodic. We can use them to sample different points in the following way:

n = length(zhat);
xi_new = sort(rand(0.5, n + 10));
x_new = zhat * exp(-zk' * xi_new) / n;

The resulting geometry struct contains the following fields

  • x: points: complex array (npoints,).

  • n: normal: complex array (npoints,).

  • t: tangent: complex array (npoints,).

  • kappa: mean curvature: real array``(npoints,)``.

  • kappa_x: first principal curvature (xy plane): real array (npoints,).

  • kappa_p: second principal curvature: real array (npoints,).

  • J: Jacobian of the transformation \(s(\xi)\), from arc length to a uniform parametrization \(\xi \in [0, 0.5]\).

  • zk: wavenumber corresponding to the Fourier coefficients.

  • zhat: Fourier coefficients for the coordinates.

  • any fields copied from x that are not in the above list.

Parameters:

x – point coordinates in counter-clockwise order. Can be an array of size (1, npoints) of complex numbers (which transform to 2D coordinates in the usual way \((\Re\{x\}, \Im\{x\})\)) or a struct containing a field x, which is such a complex array.

Returns:

a struct containing geometry information.

st_mesh_source_geometry(x, y, method)#

Compute geometry at source points.

The source geometry is computed at quadrature points. Since the quadrature points are non-uniform, we cannot use the standard FFT to also compute the source geometry spectrally, like the target geometry in st_mesh_target_geometry().

For this reason, the source geometry is computed by interpolation from the target geometry with the method given by method:

Parameters:
  • x – target point information.

  • y – source point coordinates on the computational grid shared with the target points.

  • method (default 'fft'.) – interpolation method to use.

Returns:

source geometry with the same fields as st_mesh_target_geometry().

st_mesh_target_associate(x, y)#

Associate targets to source panels.

Target association is done in the following way:

  • first we construct an array of source points and panel endpoints from the information in Y. By construction, we know in which panel each of these source points resides.

  • then we compute the minimum distance from each target point to the points in the constructed array.

  • using the index of the closest source point, we associate a panel to each target.

Note that target points that are closest to a panel endpoint, get associated to its two neighboring panels. Otherwise, each target is associated with a single panel.

Parameters:
  • x – target point information.

  • y – source point information.

Returns:

array of size (2, ntargets) of panel ids containing the indices of the two nearest panels to the target point.

Returns:

an array of source point closest to the target point.

st_mesh_h_max(x, y)#

Compute a maximum panel size in the mesh.

Parameters:
  • x – target point information.

  • y – source point information.

st_mesh_h_min(x, y)#

Compute a minimum panel size in the mesh.

Parameters:
  • x – target point information.

  • y – source point information.

st_mesh_volume(~, y)#

Compute the volume of a shape.

The volume is computed using the divergence theorem as follows:

\[\int_{\Omega} \,\mathrm{d}V = \int_{\Omega} \frac{1}{3} \nabla \cdot \mathbf{x} \,\mathrm{d}V = \int_{\Sigma} \frac{1}{3} \mathbf{x} \cdot \mathbf{n} \,\, \mathrm{d}S.\]
Parameters:
  • x – target point information.

  • y – source point information.

Returns:

the full 3D volume of the axisymmetric shape.

st_mesh_centroid(x, y)#

Compute the centroid of a closed curve.

The centroid is usually given in terms of the volume formula

\[\mathbf{x}_c = \frac{1}{|\Omega|} \int_\Omega \mathbf{x} \,\mathrm{d}V.\]

This can be rewritten as a surface integral using the divergence theorem to obtain

\[\mathbf{x}_c = \frac{1}{|V|} \int_\Sigma \frac{1}{2} \|\mathbf{x}\|^2 \mathbf{n} \,\mathrm{d} S,\]

where the volume is obtained by st_mesh_volume(). Note that the centroid components in the \((y, z)\) directions are always zero by symmetry.

Parameters:
  • x – target point information.

  • y – source point information.

Returns:

the centroid of the 3D axisymmetric shape.

st_mesh_curve(xi, name, varargin)#

Construct a 2D curve.

All curves returned by this function are axisymmetric, i.e. the full closed curve can be reconstructed using st_array_ax().

The curves are

  • 'circle': with radius R.

  • 'ellipse': with axes a and b.

  • 'starfish': with radius R an number of arms narms.

  • 'flower': with radius R.

  • 'ufo': with radius R and parameters k, a, b.

  • 'spheroid': with radius R and perturbation epsilon.

Parameters:
  • xi – parametrization in \([0, 0.5]\) or number of points.

  • name – name of the curve.

  • varargin – option key-value pairs for each curve.

Returns:

complex array representing the \((x, \rho)\) coordinates of the curve.

st_mesh_equidistance(x, y, method, varargin)#

Equidistance a set of points.

This function computes a new set of the same number of points that is equidistant along the curve, with respect to arc length.

The supported methods are:

  • 'interp': computes the arclength and then interpolated to a grid with uniform arclength.

  • 'fft': uses the MATLAB2020a nfft function to do the arclength interpolation.

  • 'optim': minimizes a cost functional to get the point distribution.

Parameters:
  • x – target point information.

  • y – source point information.

  • method – method used for equidistancing.

  • varargin – additional options.

Returns:

equidistant point coordinates.