geometric_kernels.spaces.mesh

This module provides the Mesh space.

Module Contents

class geometric_kernels.spaces.mesh.Mesh(vertices, faces)[source]

Bases: geometric_kernels.spaces.base.DiscreteSpectrumSpace

The GeometricKernels space representing the node set of any user-provided mesh.

The elements of this space are represented by node indices, integer values from 0 to Nv-1, where Nv is the number of nodes in the user-provided mesh.

Each individual eigenfunction constitutes a level.

Note

We only support the commonly used 2-dimensional meshes (discrete counterparts of surfaces, 2-dimensional manifolds in a 3-dimensional ambient space).

Note

A tutorial on how to use this space is available in the Mesh.ipynb notebook.

Note

We use potpourri3d to load meshes and mimic the interface of PyMesh.

Parameters:
  • vertices (numpy.ndarray) – A [Nv, 3] array of vertex coordinates, Nv is the number of vertices.

  • faces (numpy.ndarray) –

    A [Nf, 3] array of vertex indices that represents a generalized array of faces, where Nf is the number of faces.

Citation

If you use this GeometricKernels space in your research, please consider citing Borovitskiy et al. [2020].

get_eigenfunctions(num)[source]

Returns the EigenfunctionsFromEigenvectors object with num levels (i.e., in this case, num eigenpairs).

Parameters:

num (int) – Number of levels.

Return type:

geometric_kernels.spaces.eigenfunctions.Eigenfunctions

get_eigensystem(num)[source]

Returns the first num eigenvalues and eigenvectors of the robust Laplacian. Caches the solution to prevent re-computing the same values.

Note

If the adjacency_matrix was a sparse SciPy array, requesting all eigenpairs will lead to a conversion of the sparse matrix to a dense one due to scipy.sparse.linalg.eigsh limitations.

Warning

Always uses SciPy (thus CPU) for internal computations. We will need to fix this in the future.

Parameters:

num (int) – Number of eigenpairs to return. Performs the computation at the first call. Afterwards, fetches the result from cache.

Returns:

A tuple of eigenvectors [nv, num], eigenvalues [num, 1].

Return type:

beartype.typing.Tuple[numpy.ndarray, numpy.ndarray]

get_eigenvalues(num)[source]
Parameters:

num (int) – Number of eigenvalues to return.

Returns:

Array of eigenvalues, with shape [num, 1].

Return type:

lab.Numeric

get_eigenvectors(num)[source]
Parameters:

num (int) – Number of eigenvectors to return.

Returns:

Array of eigenvectors, with shape [Nv, num].

Return type:

lab.Numeric

get_repeated_eigenvalues(num)[source]

Same as get_eigenvalues().

Parameters:

num (int) – Same as get_eigenvalues().

Return type:

lab.Numeric

classmethod load_mesh(filename)[source]

Construct Mesh by loading a mesh from the file at filename.

Parameters:

filename (str) – Path to read the file from. Supported formats: obj, ply, off, and stl. Format inferred automatically from the file extension.

Returns:

And object of class Mesh representing the loaded mesh.

Return type:

Mesh

random(key, number)[source]

Sample uniformly random points in the space.

Parameters:
  • key – Either np.random.RandomState, tf.random.Generator, torch.Generator or jax.tensor (representing random state).

  • number – Number of samples to draw.

Returns:

An array of number uniformly random samples on the space.

property dimension: int
Returns:

Return type:

int

property element_shape
Returns:

[1].

property faces: numpy.ndarray

A [Nf, 3] array of vertex indices that represents a generalized array of faces, where Nf is the number of faces.

Return type:

numpy.ndarray

property num_faces: int

Number of faces in the mesh, Nf.

Return type:

int

property num_vertices: int

Number of vertices in the mesh, Nv.

Return type:

int

property vertices: numpy.ndarray

A [Nv, 3] array of vertex coordinates, Nv is the number of vertices.

Return type:

numpy.ndarray