API Overview

The public API is available from the top-level pysurfacefun namespace.

Quadrilateral patches

pysurfacefun.sphere(n[, nref, projection])

Build a six-patch Chebyshev discretization of the unit sphere.

pysurfacefun.torus(n[, nu, nv])

Build a Fourier-parametrized torus patch mesh.

pysurfacefun.stellarator(n[, nu, nv])

Build a Fourier-parametrized stellarator patch mesh.

pysurfacefun.surfacefun(func, dom)

Construct a scalar surface function on a SurfaceMesh.

pysurfacefun.surfaceop(dom, op[, rhs])

Construct a scalar elliptic surface operator.

pysurfacefun.lap(f)

pysurfacefun.grad(f)

pysurfacefun.normal(dom)

Surface unit normal.

pysurfacefun.write_vtu(filename, u[, point_name])

Write a VTU file with triangulated patch grids.

Triangular patches

pysurfacefun.icosphere_tri(n[, nref, family])

Convenience wrapper for a high-order triangular icosphere.

pysurfacefun.LevelSetSurface(mesh[, ...])

Notebook-friendly level-set surface constructor.

pysurfacefun.tri_surfacefun(func, dom)

Construct a scalar triangular surface function.

pysurfacefun.tri_surfaceop(dom, op[, rhs, ...])

Construct a triangular scalar surface operator.

pysurfacefun.tri_lap(f)

Surface Laplacian by repeated tangential Cartesian differentiation.

pysurfacefun.tri_surfacearea(dom)

Area of a triangular surface mesh.

pysurfacefun.write_tri_vtu(filename, u[, ...])

Write a triangular surface function to a ParaView VTU file.

pysurfacefun.write_triangle_meshio(filename, obj)

Write a triangular surface mesh or function with meshio.

Module reference

pysurfacefun

High-order patch-based tools for solving variable-coefficient elliptic partial differential equations on smooth surfaces.

The implementation uses Chebyshev surface patches, strong-form surface differentiation, local patch solution operators, and hierarchical Schur-complement merging for fast repeated elliptic solves.

pysurfacefun.LevelSetSurface(mesh: str | Path | ndarray, faces_or_phi=None, phi: Callable | None = None, grad_phi: Callable | None = None, n: int | None = None, **kwargs) TriangleSurfaceMesh | SurfaceMesh[source]

Notebook-friendly level-set surface constructor.

Examples

LevelSetSurface("mesh.mat", phi, grad_phi, n=12)

LevelSetSurface((vertices, cells), phi, grad_phi, n=12)

LevelSetSurface(vertices, faces, phi, grad_phi, n=12)

class pysurfacefun.PDO(dxx: 'float' = 0.0, dyy: 'float' = 0.0, dzz: 'float' = 0.0, dxy: 'float' = 0.0, dyx: 'float' = 0.0, dyz: 'float' = 0.0, dzy: 'float' = 0.0, dxz: 'float' = 0.0, dzx: 'float' = 0.0, dx: 'float' = 0.0, dy: 'float' = 0.0, dz: 'float' = 0.0, b: 'float' = 0.0)[source]

Bases: object

b: float = 0.0
dx: float = 0.0
dxx: float = 0.0
dxy: float = 0.0
dxz: float = 0.0
dy: float = 0.0
dyx: float = 0.0
dyy: float = 0.0
dyz: float = 0.0
dz: float = 0.0
dzx: float = 0.0
dzy: float = 0.0
dzz: float = 0.0
class pysurfacefun.SurfaceFunction(domain: 'SurfaceMesh', vals: 'list[Array]')[source]

Bases: object

static constant(domain: SurfaceMesh, value: float | complex) SurfaceFunction[source]
copy() SurfaceFunction[source]
domain: SurfaceMesh
static from_callable(domain: SurfaceMesh, func: Callable[[ndarray, ndarray, ndarray], ndarray]) SurfaceFunction[source]
mean2() float[source]
norm_inf() float[source]
remove_mean() SurfaceFunction[source]
vals: list[ndarray]
vec() ndarray[source]
class pysurfacefun.SurfaceMesh(x: 'list[Array]', y: 'list[Array]', z: 'list[Array]')[source]

Bases: object

static from_rhino(filename: str, n: int) SurfaceMesh[source]

Import a Rhino CSV patch mesh.

The file must have three numeric columns x,y,z and n*n consecutive rows per patch.

property n: int
property npatches: int
property order: int
static sphere(n: int, nref: int = 0, projection: str = 'quasiuniform') SurfaceMesh[source]

Build a six-patch Chebyshev discretization of the unit sphere.

static stellarator(n: int, nu: int = 8, nv: int | None = None) SurfaceMesh[source]

Build a Fourier-parametrized stellarator patch mesh.

static torus(n: int, nu: int = 8, nv: int | None = None) SurfaceMesh[source]

Build a Fourier-parametrized torus patch mesh.

x: list[ndarray]
y: list[ndarray]
z: list[ndarray]
class pysurfacefun.SurfaceOp(domain: SurfaceMesh, op: dict, rhs: SurfaceFunction | Callable | float = 0.0)[source]

Bases: object

apply(rhs: SurfaceFunction | Callable | float) SurfaceFunction[source]

Update the right-hand side and immediately solve.

build() None[source]
patches: list[Patch]
solve() SurfaceFunction[source]
update_rhs(rhs: SurfaceFunction | Callable | float) SurfaceOp[source]

Update only the right-hand side data of an already assembled operator.

The geometry, local differential matrices, and Schur-complement solution operators are reused. Only the particular solution data are recomputed and pushed up the merge tree.

class pysurfacefun.SurfaceVectorFunction(components: tuple[SurfaceFunction, SurfaceFunction, SurfaceFunction])[source]

Bases: object

Three-component vector field sampled on a surface mesh.

components: tuple[SurfaceFunction, SurfaceFunction, SurfaceFunction]
property domain: SurfaceMesh
norm_inf() float[source]
class pysurfacefun.TriangleSurfaceFunction(domain: TriangleSurfaceMesh, vals: list[ndarray])[source]

Bases: object

Scalar function sampled on a TriangleSurfaceMesh.

static constant(domain: TriangleSurfaceMesh, value: float | complex) TriangleSurfaceFunction[source]
copy() TriangleSurfaceFunction[source]
domain: TriangleSurfaceMesh
static from_callable(domain: TriangleSurfaceMesh, func: Callable[[ndarray, ndarray, ndarray], ndarray]) TriangleSurfaceFunction[source]
mean2() float[source]
norm_inf() float[source]
remove_mean() TriangleSurfaceFunction[source]
vals: list[ndarray]
class pysurfacefun.TriangleSurfaceMesh(x: list[ndarray], y: list[ndarray], z: list[ndarray], family: str = 'cheb2')[source]

Bases: object

High-order triangular surface patch mesh.

family: str = 'cheb2'
static icosphere(n: int, nref: int = 0, family: str = 'cheb2') TriangleSurfaceMesh[source]
property npatches: int
x: list[ndarray]
y: list[ndarray]
z: list[ndarray]
class pysurfacefun.TriangleSurfaceOp(domain: TriangleSurfaceMesh, op: dict, rhs: TriangleSurfaceFunction | Callable | float = 0.0, merge_idx: list[list[tuple[int, int | None]]] | None = None, merge_strategy: str = 'default')[source]

Bases: object

Scalar HPS-style operator for triangular surface patches.

apply(rhs: TriangleSurfaceFunction | Callable | float) TriangleSurfaceFunction[source]

Update the right-hand side and immediately solve.

build() None[source]
patches: list[Patch]
solve() TriangleSurfaceFunction[source]
update_rhs(rhs: TriangleSurfaceFunction | Callable | float) TriangleSurfaceOp[source]

Update only the right-hand side of an already built triangular operator.

The local inverses, Dirichlet-to-Neumann maps, and merge-tree Schur complements are reused. Only the particular solution is recomputed and propagated through the merge tree.

pysurfacefun.boundingbox(dom: SurfaceMesh) ndarray[source]

Bounding box [xmin, xmax, ymin, ymax, zmin, zmax].

pysurfacefun.chebpts(n: int, kind: int = 2, interval: tuple[float, float] = (-1.0, 1.0)) ndarray[source]

Chebyshev points, ordered from left to right.

pysurfacefun.chebpts2(nx: int, ny: int | None = None, D: ndarray | tuple[float, float, float, float] | None = None, kind: int = 2) tuple[ndarray, ndarray][source]

Tensor-product Chebyshev grid.

The domain mapping is included here because the sphere constructor calls chebpts2(n, n, [0, 1, 0, 1]).

pysurfacefun.compose(op: Callable, f: SurfaceFunction | float, g: SurfaceFunction | float | None = None) SurfaceFunction[source]

Compose a scalar function with one or two surface functions.

pysurfacefun.conj(f: SurfaceFunction) SurfaceFunction[source]
pysurfacefun.cos(f: SurfaceFunction) SurfaceFunction[source]
pysurfacefun.cross(f: SurfaceVectorFunction | ndarray | list[float], g: SurfaceVectorFunction | ndarray | list[float], *args) SurfaceVectorFunction[source]

Vector cross product for arrays or surface vector functions.

pysurfacefun.diff(f: SurfaceFunction, n: int | tuple[int, int, int] = 1, dim: int = 1) SurfaceFunction[source]

Differentiate a surface function in Cartesian surface directions.

dim=1 gives the tangential x derivative, dim=2 gives y, and dim=3 gives z. Passing n=(nx, ny, nz) applies mixed repeated derivatives.

pysurfacefun.diffmat(n: int) ndarray[source]

Dense Chebyshev nodal differentiation matrix.

pysurfacefun.diffx(f: SurfaceFunction, n: int = 1) SurfaceFunction[source]
pysurfacefun.diffy(f: SurfaceFunction, n: int = 1) SurfaceFunction[source]
pysurfacefun.diffz(f: SurfaceFunction, n: int = 1) SurfaceFunction[source]
pysurfacefun.div(f: SurfaceVectorFunction) SurfaceFunction[source]
pysurfacefun.divergence(f: SurfaceVectorFunction) SurfaceFunction[source]
pysurfacefun.dot(f: SurfaceVectorFunction, g: SurfaceVectorFunction) SurfaceFunction[source]
pysurfacefun.exp(f: SurfaceFunction) SurfaceFunction[source]
pysurfacefun.extract_tri_mesh_arrays(data, *, vertex_name: str | None = None, face_name: str | None = None, mesh_name: str | None = None) tuple[ndarray, ndarray][source]

Extract vertex and face arrays from a loaded mesh dictionary/struct.

pysurfacefun.from_rhino(filename: str, n: int) SurfaceMesh[source]

Load a Rhino-style CSV patch mesh.

pysurfacefun.grad(f: SurfaceFunction) SurfaceVectorFunction[source]
pysurfacefun.gradient(f: SurfaceFunction) SurfaceVectorFunction[source]

Return the surface gradient as a three-component vector function.

pysurfacefun.hodge(f: SurfaceVectorFunction) tuple[SurfaceFunction, SurfaceFunction, SurfaceVectorFunction, SurfaceVectorFunction, SurfaceVectorFunction][source]

Hodge decomposition of a vector surface function.

Returns u, v, w, curlfree, divfree such that

f = grad(u) + normal x grad(v) + w.

pysurfacefun.icosphere_tri(n: int, nref: int = 0, family: str = 'cheb2') TriangleSurfaceMesh[source]

Convenience wrapper for a high-order triangular icosphere.

pysurfacefun.imag(f: SurfaceFunction) SurfaceFunction[source]
pysurfacefun.integral(f: SurfaceFunction, reduce: bool = True) float | ndarray[source]
pysurfacefun.integral2(f: SurfaceFunction, reduce: bool = True) float | ndarray[source]

Surface integral of a scalar surface function.

pysurfacefun.koornwinder_pkd(degree: int, x: ndarray | None = None, y: ndarray | None = None) tuple[ndarray, ndarray, ndarray][source]

RecursiveNodes PKD Vandermonde matrix and unit-triangle derivatives.

The underlying RecursiveNodes routines evaluate orthonormal Proriol-Koornwinder-Dubiner polynomials on the biunit triangle with coordinates (r, s). This package uses the unit triangle (x, y), so this function applies

r = 2*x - 1,  s = 2*y - 1

and multiplies the returned gradients by 2. Thus Kx and Ky differentiate with respect to the unit reference coordinates.

pysurfacefun.lap(f: SurfaceFunction) SurfaceFunction[source]
pysurfacefun.laplacian(f: SurfaceFunction) SurfaceFunction[source]

Surface Laplacian.

pysurfacefun.levelset_surface(mesh, phi: Callable, grad_phi: Callable, n: int, *, family: str = 'cheb2', cell_type: str = 'auto', vertex_name: str | None = None, face_name: str | None = None, mesh_name: str | None = None, index_base: str | int = 'auto', nref: int = 0, orient_outward: bool = False, orientation_center: ndarray | None = None, max_iter: int = 30, tol: float = 1e-13, damping: float = 1.0) TriangleSurfaceMesh | SurfaceMesh[source]

Level-set surface constructor for triangular or quadrilateral coarse meshes.

mesh may be a MAT-file path, a (vertices, cells) tuple, a dictionary/struct-like loaded mesh, or an object with vertex/face fields. Three-node cells create a TriangleSurfaceMesh; four-node cells create a quadrilateral SurfaceMesh. nref refines the coarse mesh connectivity before high-order nodes are mapped and projected to the level set.

pysurfacefun.levelset_surface_quad(vertices: ndarray, cells: ndarray, phi: Callable, grad_phi: Callable, n: int, index_base: str | int = 'auto', max_iter: int = 30, tol: float = 1e-13, damping: float = 1.0) SurfaceMesh[source]

Build tensor-product Chebyshev patches by projecting quad cells to phi=0.

Each coarse quad is first mapped bilinearly from [0,1]^2 and then every Chebyshev node is projected to the implicit surface.

pysurfacefun.levelset_surface_tri(vertices: ndarray, faces: ndarray, phi: Callable, grad_phi: Callable, n: int, family: str = 'cheb2', index_base: str | int = 'auto', max_iter: int = 30, tol: float = 1e-13, damping: float = 1.0) TriangleSurfaceMesh[source]

Build high-order triangular patches by projecting a coarse mesh to phi=0.

Parameters:
  • vertices – Coarse triangular mesh. vertices has shape (nv, 3) and faces has shape (nf, 3). Faces may be zero-based or one-based when index_base='auto'.

  • faces – Coarse triangular mesh. vertices has shape (nv, 3) and faces has shape (nf, 3). Faces may be zero-based or one-based when index_base='auto'.

  • phi – Level-set function and gradient. Each may accept either one point p with shape (3,) or three scalars x, y, z.

  • grad_phi – Level-set function and gradient. Each may accept either one point p with shape (3,) or three scalars x, y, z.

  • n – Number of high-order nodes on each triangle edge.

Returns:

Curved triangular patch mesh with every node projected to the smooth implicit surface.

Return type:

TriangleSurfaceMesh

pysurfacefun.levelset_surface_tri_from_mat(filename: str | Path, phi: Callable, grad_phi: Callable, n: int, *, vertex_name: str | None = None, face_name: str | None = None, mesh_name: str | None = None, family: str = 'cheb2', index_base: str | int = 'auto', nref: int = 0, triangulate: bool = True, orient_outward: bool = False, orientation_center: ndarray | None = None, max_iter: int = 30, tol: float = 1e-13, damping: float = 1.0) TriangleSurfaceMesh[source]

Build a level-set triangular surface directly from a MAT-file mesh.

The mesh file may store arrays as vertices/faces, xs/surfs, V/F, or inside a struct. Use vertex_name and face_name when the file uses different variable names.

pysurfacefun.load_mat_surface_mesh(filename: str | Path, *, vertex_name: str | None = None, face_name: str | None = None, mesh_name: str | None = None, index_base: str | int = 'auto') tuple[ndarray, ndarray][source]

Extract vertices and surface cells from a MAT-file.

The returned cell array is zero-based for direct Python use. Supported common names include vertices/faces, xs/surfs, V/F, nodes/elements, and p/t.

pysurfacefun.load_mat_tri_mesh(filename: str | Path, *, vertex_name: str | None = None, face_name: str | None = None, mesh_name: str | None = None, index_base: str | int = 'auto') tuple[ndarray, ndarray][source]

Backward-compatible alias for load_mat_surface_mesh.

pysurfacefun.log(f: SurfaceFunction) SurfaceFunction[source]
pysurfacefun.log10(f: SurfaceFunction) SurfaceFunction[source]
pysurfacefun.maxEst(f: SurfaceFunction) float[source]

Estimate the maximum sampled value.

pysurfacefun.mean2(f: SurfaceFunction) float[source]
pysurfacefun.minEst(f: SurfaceFunction) float[source]

Estimate the minimum sampled value.

pysurfacefun.node_family_points(count: int, family: str = 'cheb2') ndarray[source]

One-dimensional node family on [0, 1] used by RecursiveNodes.

pysurfacefun.norm(f: SurfaceFunction | SurfaceVectorFunction, p: int | float | str = 2, reduce: bool = True) float | ndarray | SurfaceFunction[source]

Surface function norms.

Supported: 1, 2, positive integer p, "inf", "max", "H1", and "lap".

pysurfacefun.normal(dom: SurfaceMesh) SurfaceVectorFunction[source]

Surface unit normal.

pysurfacefun.normalize(f: SurfaceVectorFunction) SurfaceVectorFunction[source]
pysurfacefun.orient_tri_faces_outward(vertices: ndarray, faces: ndarray, center: ndarray | None = None) ndarray[source]

Orient triangular faces so normals point away from center.

This is intended for closed, star-shaped surfaces such as the sphere mesh used in the triangular notebook.

pysurfacefun.plot_surface(u: SurfaceFunction, title: str = '', vmin: float | None = None, vmax: float | None = None, colorbar: bool = True) None[source]

Basic Matplotlib visualization of the patch values.

pysurfacefun.plot_tri_surface(u: TriangleSurfaceFunction, title: str = '', vmin: float | None = None, vmax: float | None = None, colorbar: bool = True) None[source]

Basic Matplotlib visualization of a triangular surface function.

pysurfacefun.plot_vector_field(f: SurfaceVectorFunction, title: str = '', stride: int = 2, scale: float = 0.6) None[source]

Plot vector magnitude on the surface with sparse 3D quiver arrows.

pysurfacefun.plot_wireframe(dom: TriangleSurfaceMesh | SurfaceMesh, *args, **kwargs)[source]

Alias for wireframe.

pysurfacefun.project_to_levelset(points: ndarray, phi: Callable, grad_phi: Callable, max_iter: int = 30, tol: float = 1e-13, damping: float = 1.0) ndarray[source]

Project points to an implicit surface using normal Newton correction.

The update is

p <- p - damping * phi(p) * grad_phi(p) / |grad_phi(p)|^2.

pysurfacefun.prolong(f: SurfaceFunction, n: int | None = None) SurfaceFunction[source]

Prolong/restrict a surface function to a new polynomial grid.

This implementation uses barycentric patch interpolation, which is stable for the smooth resolved functions used in the examples.

pysurfacefun.randnfun3(length_scale: float, bbox: ndarray | tuple[float, float, float, float, float, float], seed: int | None = None, nmodes: int = 64) Callable[[ndarray, ndarray, ndarray], ndarray][source]

Smooth deterministic 3D random field.

This returns a finite smooth random Fourier field on the supplied physical bounding box. It is meant for reproducible initial data in time-dependent examples.

pysurfacefun.real(f: SurfaceFunction) SurfaceFunction[source]
pysurfacefun.real_spherical_harmonic(l: int, m: int, x: ndarray, y: ndarray, z: ndarray) ndarray[source]

Real, unnormalized spherical harmonic Y_l^m on the unit sphere.

This avoids a scipy dependency. Normalization is irrelevant for convergence tests because the error is relative.

pysurfacefun.recursive_nodes(dim: int, degree: int, family: str = 'cheb2', domain: str = 'barycentric', interior: int = 0) ndarray[source]

Recursive interpolation nodes on a simplex.

This follows the definition in the RecursiveNodes documentation. For dim=2 and domain='unit' the returned columns are the coordinates (x, y) on the unit reference triangle.

pysurfacefun.reference_triangle_quadrature_weights(n: int, family: str = 'cheb2') ndarray[source]

Nodal quadrature weights on the reference triangle.

pysurfacefun.refine_quad_mesh(vertices: ndarray, cells: ndarray, nref: int = 1) tuple[ndarray, ndarray][source]

Split each quadrilateral into four quadrilaterals nref times.

pysurfacefun.refine_surface_mesh(vertices: ndarray, cells: ndarray, nref: int = 1, cell_type: str = 'auto') tuple[ndarray, ndarray][source]

Uniformly refine triangular or quadrilateral surface connectivity.

This refinement is purely geometric and linear. It is intended to be used before level-set projection: new edge/center vertices are introduced in the coarse mesh, and the subsequent LevelSetSurface call projects the high-order patch nodes to the smooth surface.

pysurfacefun.refine_tri_mesh(vertices: ndarray, faces: ndarray, nref: int = 1) tuple[ndarray, ndarray][source]

Split each triangle into four triangles nref times.

pysurfacefun.resample(obj, n: int)[source]

Resample a scalar surface function or surface mesh.

pysurfacefun.resample_mesh(dom, n: int)[source]

Resample a quadrilateral or triangular surface mesh.

pysurfacefun.shifted_lobatto_nodes(degree: int) ndarray[source]

Shifted Lobatto-Gauss-Legendre nodes on [0, 1].

pysurfacefun.sin(f: SurfaceFunction) SurfaceFunction[source]
pysurfacefun.smooth_random_function_3d(length_scale: float, bbox: ndarray | tuple[float, float, float, float, float, float], seed: int | None = None, nmodes: int = 64) Callable[[ndarray, ndarray, ndarray], ndarray][source]

Descriptive alias for randnfun3.

pysurfacefun.solve_laplace_beltrami_sphere(f: SurfaceFunction | Callable, n: int = 9, nref: int = 0, c: float = 0.0, rankdef: bool = True) SurfaceFunction[source]

Solve Delta_Gamma u + c u = f on S^2.

For c=0 this is rank deficient; use a mean-zero RHS and rankdef=True.

pysurfacefun.sphere(n: int, nref: int = 0, projection: str = 'quasiuniform') SurfaceMesh[source]

Build a six-patch Chebyshev discretization of the unit sphere.

pysurfacefun.sqrt(f: SurfaceFunction) SurfaceFunction[source]
pysurfacefun.stellarator(n: int, nu: int = 8, nv: int | None = None) SurfaceMesh[source]

Build a Fourier-parametrized stellarator patch mesh.

pysurfacefun.sum2(f: SurfaceFunction, reduce: bool = True) float | ndarray[source]
pysurfacefun.surface_mesh_arrays(mesh, *, vertex_name: str | None = None, face_name: str | None = None, mesh_name: str | None = None, index_base: str | int = 'auto') tuple[ndarray, ndarray][source]

Return (vertices, cells) from a path, tuple, dict, or mesh-like object.

pysurfacefun.surfacearea(dom: SurfaceMesh) float[source]
pysurfacefun.surfacefun(func: Callable[[ndarray, ndarray, ndarray], ndarray] | float | list[ndarray], dom: SurfaceMesh) SurfaceFunction[source]

Construct a scalar surface function on a SurfaceMesh.

pysurfacefun.surfacefunv(fx: Callable[[ndarray, ndarray, ndarray], ndarray] | SurfaceFunction | float | list[ndarray], fy: Callable[[ndarray, ndarray, ndarray], ndarray] | SurfaceFunction | float | list[ndarray] | None = None, fz: Callable[[ndarray, ndarray, ndarray], ndarray] | SurfaceFunction | float | list[ndarray] | None = None, dom: SurfaceMesh | None = None) SurfaceVectorFunction[source]

Construct a three-component vector surface function.

pysurfacefun.surfaceop(dom: SurfaceMesh, op: dict, rhs: SurfaceFunction | Callable | float = 0.0) SurfaceOp[source]

Construct a scalar elliptic surface operator.

pysurfacefun.torus(n: int, nu: int = 8, nv: int | None = None) SurfaceMesh[source]

Build a Fourier-parametrized torus patch mesh.

pysurfacefun.tri_diff(f: TriangleSurfaceFunction, dim: int = 1) TriangleSurfaceFunction[source]

Tangential Cartesian derivative on triangular patches.

pysurfacefun.tri_edge_indices(n: int, family: str = 'cheb2') tuple[ndarray, ndarray, ndarray][source]

Triangle edge node indices determined from reference coordinates.

pysurfacefun.tri_integral2(f: TriangleSurfaceFunction, reduce: bool = True) float | ndarray[source]

Surface integral on triangular patches.

pysurfacefun.tri_lap(f: TriangleSurfaceFunction) TriangleSurfaceFunction[source]

Surface Laplacian by repeated tangential Cartesian differentiation.

pysurfacefun.tri_patch_boundary_segments(dom: TriangleSurfaceMesh, nvis: int | None = None, deduplicate: bool = True) list[ndarray][source]

Return line segments following the curved high-order patch boundaries.

pysurfacefun.tri_reference_nodes(n: int, family: str = 'cheb2') tuple[ndarray, ndarray][source]

Reference triangle nodes with n points on each edge.

The polynomial degree is n - 1 and the total number of nodes is n * (n + 1) / 2.

pysurfacefun.tri_resample(u: TriangleSurfaceFunction, n: int, family: str | None = None) TriangleSurfaceFunction[source]

Resample a triangular surface function using the PKD interpolation basis.

pysurfacefun.tri_resample_mesh(dom: TriangleSurfaceMesh, n: int, family: str | None = None) TriangleSurfaceMesh[source]

Resample every triangular patch to order n.

pysurfacefun.tri_resampled_patch_geometry(dom: TriangleSurfaceMesh, nvis: int | None = None, family: str | None = None) tuple[list[ndarray], list[ndarray], list[ndarray], int][source]

Return patch geometry sampled on a display triangle grid.

pysurfacefun.tri_resampled_patch_values(u: TriangleSurfaceFunction, nvis: int | None = None, family: str | None = None) tuple[list[ndarray], list[ndarray], list[ndarray], list[ndarray], int][source]

Return patch geometry and values sampled on a display triangle grid.

pysurfacefun.tri_strong_diffmat(degree: int, x: ndarray | None = None, y: ndarray | None = None, basis: str = 'pkd') tuple[ndarray, ndarray, ndarray][source]

Strong-form reference-triangle differentiation matrices.

Du @ f and Dv @ f differentiate nodal values with respect to the reference coordinates u=x and v=y.

pysurfacefun.tri_surfacearea(dom: TriangleSurfaceMesh) float[source]

Area of a triangular surface mesh.

pysurfacefun.tri_surfacefun(func: Callable[[ndarray, ndarray, ndarray], ndarray] | float | list[ndarray], dom: TriangleSurfaceMesh) TriangleSurfaceFunction[source]

Construct a scalar triangular surface function.

pysurfacefun.tri_surfaceop(dom: TriangleSurfaceMesh, op: dict, rhs: TriangleSurfaceFunction | Callable | float = 0.0, merge_idx: list[list[tuple[int, int | None]]] | None = None, merge_strategy: str = 'default') TriangleSurfaceOp[source]

Construct a triangular scalar surface operator.

pysurfacefun.tri_wireframe_edge_indices(n: int) tuple[ndarray, ndarray, ndarray][source]

Triangle edge node indices for patch-boundary wireframes.

pysurfacefun.triangle_boundary_meshio_mesh(dom: TriangleSurfaceMesh, nvis: int | None = None, deduplicate: bool = True)[source]

Convert high-order triangular patch boundaries to a meshio.Mesh with line cells.

pysurfacefun.triangle_meshio_mesh(obj: TriangleSurfaceMesh | TriangleSurfaceFunction, point_name: str = 'u', nvis: int | None = None)[source]

Convert a triangular surface mesh or function to a meshio.Mesh.

pysurfacefun.triangle_surface_mesh_arrays(dom: TriangleSurfaceMesh, nvis: int | None = None) tuple[ndarray, ndarray][source]

Return concatenated points and triangle connectivity for a triangular surface mesh.

pysurfacefun.triangulate_faces(faces: ndarray, *, vertices: ndarray | None = None, orient_outward: bool = False, center: ndarray | None = None) ndarray[source]

Convert triangular or polygonal surface cells to triangle connectivity.

Rows with three entries are kept. Rows with more entries are split by a fan from the first vertex. When orient_outward=True, the triangles are flipped so their normals point away from center. If center is not supplied, the origin is used.

pysurfacefun.trilattice(n: int) ndarray[source]

Triangle connectivity for the regular lattice ordering.

pysurfacefun.vector_norm(f: SurfaceVectorFunction) SurfaceFunction[source]
pysurfacefun.wireframe(dom: TriangleSurfaceMesh | SurfaceMesh, surface: str = 'auto', edges: str = 'auto', ax=None, color: str = 'k', linestyle: str = '-', linewidth: float = 1.0, surface_color: str = 'w', shrink: float = 0.005, nvis: int | None = None, line_offset: float = 0.0, deduplicate: bool = True, visible_only: bool = False, view_vector: ndarray | None = None, **line_kwargs)[source]

Plot high-order patch boundaries.

pysurfacefun.write_tri_patch_boundaries_vtp(filename: str, dom: TriangleSurfaceMesh, nvis: int | None = None) None[source]

Write high-order triangular patch boundaries as ParaView PolyData lines.

pysurfacefun.write_tri_vtp(filename: str, u: TriangleSurfaceFunction, point_name: str = 'u', nvis: int | None = None) None[source]

Write a triangular surface function to a ParaView VTP PolyData file.

pysurfacefun.write_tri_vtu(filename: str, u: TriangleSurfaceFunction, point_name: str = 'u', nvis: int | None = None) None[source]

Write a triangular surface function to a ParaView VTU file.

pysurfacefun.write_triangle_meshio(filename: str | Path, obj: TriangleSurfaceMesh | TriangleSurfaceFunction, point_name: str = 'u', nvis: int | None = None) None[source]

Write a triangular surface mesh or function with meshio.

pysurfacefun.write_vtu(filename: str, u: SurfaceFunction, point_name: str = 'u') None[source]

Write a VTU file with triangulated patch grids.

Requires meshio. Install with: pip install meshio