surfgeopy package

Submodules

surfgeopy.quadrature_points module

surfgeopy.quadrature_points.quadrule_on_flat(deg)[source]

Quadrature rule

Parameters:

deg (int) – Algebraic degree of precision of the rule.

Returns:

  • weights_ps (ndarray) – n-by-1 array of single or double, weights of quadrature points.

  • quad_ps (ndarray) – n-by-3 array of single or double, natural coordinates of quadrature points.

surfgeopy.quadrature_points.quadrule_on_simplex(deg)[source]
Parameters:
  • deg (Algebraic degree of precision of the rule.) – Algebraic degree of precision of the rule.

  • 0] (CUBATURE RULE ON THE SIMPLEX [0 0; 0 1; 1)

  • Legend

  • #DEG (algebraic degree of precision.)

  • #CARD (cardinality of the pointset.)

  • #W- (negative weights.)

  • #PT.O (points outside the simplex [0 0; 1 0; 0 1].)

  • #M.E. (maximum moment error in inf norm.)

  • points (Statistics of quadrature)

  • M.E. (# | DEG | CARD | W- | PT.O|)

  • #------------------------------------

  • 1.92e-16 (# | 1 | 1 | 0 | 0 |)

  • 1.18e-16 (# | 2 | 3 | 0 | 0 |)

  • 2.15e-16 (# | 3 | 4 | 0 | 0 |)

  • 1.39e-16 (# | 4 | 6 | 0 | 0 |)

  • 1.60e-16 (# | 5 | 7 | 0 | 0 |)

  • 1.08e-15 (# | 6 | 11 | 0 | 0 |)

  • 5.07e-16 (# | 7 | 12 | 0 | 0 |)

  • 8.05e-16 (# | 8 | 16 | 0 | 0 |)

  • 3.26e-16 (# | 9 | 19 | 0 | 0 |)

  • 7.22e-16 (# | 10 | 24 | 0 | 0 |)

  • 3.64e-15 (# | 11 | 27 | 0 | 0 |)

  • 1.61e-15 (# | 12 | 32 | 0 | 0 |)

  • 3.05e-16 (# | 13 | 36 | 0 | 0 |)

  • 4.37e-16 (# | 14 | 42 | 0 | 0 |)

  • 5.00e-16 (# | 15 | 46 | 0 | 0 |)

  • 5.67e-16 (# | 16 | 52 | 0 | 0 |)

  • 5.83e-16 (# | 17 | 57 | 0 | 0 |)

  • 6.11e-16 (# | 18 | 66 | 0 | 0 |)

  • 4.16e-16 (# | 19 | 70 | 0 | 0 |)

  • 4.89e-16 (# | 20 | 78 | 0 | 0 |)

  • 4.64e-16 (# | 21 | 85 | 0 | 0 |)

  • 7.56e-16 (# | 22 | 93 | 0 | 0 |)

  • 6.66e-16 (# | 23 | 100 | 0 | 0 |)

  • 7.81e-16 (# | 24 | 109 | 0 | 0 |)

  • 5.41e-16 (# | 25 | 117 | 0 | 0 |)

  • 0]. (CUBATURE RULE ON THE SIMPLEX [0 0; 0 1; 1)

  • --------------------------------------------------------------------

  • Input

  • ----------

  • deg

Returns:

  • weights_ps (N-by-1 array (single or double), weights of quadrature points)

  • quad_ps (N-by-2 array (single or double),) – natural coordinates of quadrature points

surfgeopy.quadrature_points_gl module

gauss_legendre.py

Gauss-Legendre quadrature and cubature rules implementation.

surfgeopy.quadrature_points_gl.gauss_legendre_square(deg)[source]

Gauss-Legendre cubature rule on the square [-1, 1]^2.

Parameters:

deg (int) – Algebraic degree of precision of the rule.

Returns:

  • weights_ps (ndarray) – n-by-1 array of single or double, weights of quadrature points.

  • quad_ps (ndarray) – n-by-2 array of single or double, natural coordinates of quadrature points.

surfgeopy.quadrature_points_gl.q_gauss_legendre(n, Domain=array([-1, 1]))[source]

Generate quadrature weights and nodes for Gauss-Legendre quadrature rule.

An n-point Gauss-Legendre quadrature rule is of degree 2n-1; that is, it integrates all polynomials up to degree 2n-1 exactly.

Parameters:
  • n (int) – Number of sample points and weights. It must be >= 1.

  • Domain (ndarray, optional) – Refers to the domain of integration [a, b]. The default domain is the bi-unit interval [-1, 1].

Returns:

  • x (ndarray) – 1-D ndarray containing the sample points.

  • w (ndarray) – 1-D ndarray containing the weights.

Notes

The function constructs the symmetric tridiagonal matrix and computes the eigenvalues and eigenvectors to obtain the quadrature points and weights.

The next steps ensure that zero is zero, and the points and weights are symmetric.

If the integration domain [a, b] is different from the default [-1, 1], the points and weights are transformed accordingly.

surfgeopy.remesh module

remesh.py

Deal with re-triangulation of existing meshes.

surfgeopy.remesh.faces_to_edges(faces, return_index=False)[source]

Given a list of faces (n,3), return a list of edges (n*3,2)

Parameters:

faces ((n, 3) int) – Vertex indices representing faces

Returns:

edges – Vertex indices representing edges

Return type:

(n*3, 2) int

surfgeopy.remesh.hashable_rows(data, digits=None)[source]

Convert array rows into a hashable format.

Parameters:
  • data ((n, m) array) – Input data

  • digits (int or None, optional) – Number of digits to add to hash if data is floating point

Returns:

hashable – Custom data type which can be sorted or used as hash keys

Return type:

(n,) array

surfgeopy.remesh.subdivide(vertices, faces, face_index=None, vertex_attributes=None, return_index=False)[source]

Subdivide a mesh into smaller triangles. Note that if face_index is passed, only those faces will be subdivided and their neighbors won’t be modified, making the mesh no longer β€œwatertight.”

Parameters:
  • vertices ((n, 3) float) – Vertices in space

  • faces ((m, 3) int) – Indices of vertices which make up triangular faces

  • face_index (array_like, optional) – Indices of faces to subdivide. If None, all faces of the mesh will be subdivided.

  • vertex_attributes (dict, optional) – Contains (n, d) attribute data

  • return_index (bool, optional) – If True, return index of original face for new faces

Returns:

  • new_vertices ((q, 3) float) – Vertices in space

  • new_faces ((p, 3) int) – Remeshed faces

  • index_dict (dict, optional) – Only returned if return_index is True. {index of original face : index of new faces}.

surfgeopy.remesh.unique_ordered(data, return_index=False, return_inverse=False)[source]

Returns the same as np.unique, but ordered as per the first occurrence of the unique value in data.

Parameters:
  • data (array-like) – Input data

  • return_index (bool, optional) – Return indices of unique values

  • return_inverse (bool, optional) – Return the inverse of the unique array

Returns:

  • unique (array-like) – The sorted unique values

  • index (array-like, optional) – The indices of the unique values

  • inverse (array-like, optional) – The indices to reconstruct the original data

surfgeopy.remesh.unique_rows(data, digits=None, keep_order=False)[source]

Returns indices of unique rows. It will return the first occurrence of a row that is duplicated: [[1,2], [3,4], [1,2]] will return [0,1]

Parameters:
  • data ((n, m) array) – Floating point data

  • digits (int or None, optional) – Number of digits to consider for uniqueness

Returns:

  • unique ((j,) int) – Index in data which is a unique row

  • inverse ((n,) int) – Array to reconstruct original Example: data[unique][inverse] == data

surfgeopy.surf_integration module

surfgeopy.surf_integration.compute_surf_quadrature(ls_function: Callable[[ndarray], float], ls_grad_func: Callable[[ndarray], ndarray], vertices: ndarray, faces: ndarray, interp_deg: int, lp_dgr: int, Refinement: int, fun_handle: Callable[[ndarray], float], deg_integration: int = 14, quadrature_rule: str = 'Pull_back_Gauss') Tuple[ndarray, ndarray, ndarray][source]

Compute quadrature points and weights on curved triangles.

Parameters:
  • ls_function – Callable[[np.ndarray], float]: Zero-levelset function.

  • ls_grad_func – Callable[[np.ndarray], np.ndarray]: Gradient of zero-levelset function.

  • vertices – np.ndarray: Array of vertex coordinates.

  • faces – np.ndarray: Array of face connectivity.

  • interp_deg – int: Interpolation degree.

  • lp_dgr – int: \(l_p\)-norm, which is used to define the polynomial degree.

  • Refinement – int: Refinement level.

  • fun_handle – Callable[[np.ndarray], float]: Function to be evaluated on each quadrature point.

  • deg_integration – int: Degree of integration (default: 14).

  • quadrature_rule – str: Quadrature rule type (β€˜Gauss_Legendre’ or β€˜Gauss_Simplex’).

Returns:

Quadrature points, weights, and offset array.

Return type:

Tuple[np.ndarray, np.ndarray, np.ndarray]

surfgeopy.surf_integration.integration(ls_function: ~typing.Callable[[~numpy.ndarray], float], ls_grad_func: ~typing.Callable[[~numpy.ndarray], ~numpy.ndarray], mesh: str, interp_deg: int, lp_dgr: int, Refinement: int, fun_handle: ~typing.Callable[[~numpy.ndarray], float] = <function <lambda>>, deg_integration: int = -1, quadrature_rule: str | None = None) ndarray[source]

Compute the integration of a function over curved triangles.

Parameters:
  • ls_function (Callable[[np.ndarray], float]) – Zero-levelset function.

  • ls_grad_func (Callable[[np.ndarray], np.ndarray]) – Gradient of the zero-levelset function.

  • mesh (str) – The file path to the MAT file containing mesh data.

  • interp_deg (int) – Interpolation degree.

  • lp_dgr (int) – The l_p-norm used to define the polynomial degree.

  • Refinement (int) – Refinement level.

  • fun_handle (Callable[[np.ndarray], float], optional) – Function to be evaluated on each quadrature point. Defaults to a constant function.

  • deg_integration (int, optional) – Degree of integration. Defaults to -1 (use default configuration).

  • quadrature_rule (Optional[str], optional) – Quadrature rule type. Can be β€˜Gauss_Legendre’ or β€˜Gauss_Simplex’. Defaults to None.

Returns:

Integration values for each curved triangle.

Return type:

np.ndarray

surfgeopy.surf_integration.quadrature_split_surf_tri(ls_function: Callable[[ndarray], float], ls_grad_func: Callable[[ndarray], ndarray], vertices: ndarray, faces: ndarray, interp_deg: int, lp_dgr: int, Refinement: int, fun_handle: Callable[[ndarray], float], deg_integration: int, quadrature_rule: str, pnts: ndarray, ws: ndarray, index: int) int[source]

For a mixed mesh, find the cell integration of the test function f.

Parameters:
  • ls_function – Callable[[np.ndarray], float]: Zero-levelset function.

  • ls_grad_func – Callable[[np.ndarray], np.ndarray]: Gradient of the zero-levelset function.

  • vertices – np.ndarray: Array of vertex coordinates.

  • faces – np.ndarray: Array of face connectivity.

  • interp_deg – int: Interpolation degree.

  • lp_dgr – int: \(l_p\)-norm, which is used to define the polynomial degree.

  • deg_integration – int: Degree of integration.

  • quadrature_rule – str: Quadrature rule type (β€˜Gauss_Legendre’ or β€˜Gauss_Simplex’).

  • pnts – np.ndarray: Quadrature points array.

  • ws – np.ndarray: Quadrature weights array.

  • index – int: Current index in the arrays.

Returns:

Updated index value.

Return type:

int

surfgeopy.surf_integration.quadrature_surf_tri(ls_function: Callable[[ndarray], float], ls_grad_func: Callable[[ndarray], ndarray], vertices: ndarray, faces: ndarray, interp_deg: int, lp_dgr: int, fun_handle: Callable[[ndarray], float], deg_integration: int, quadrature_rule: str, pnts: ndarray, ws: ndarray, index: int) int[source]

For a mixed mesh, find the cell integration of the test function f.

Parameters:
  • ls_function – Callable[[np.ndarray], float]: Zero-levelset function.

  • ls_grad_func – Callable[[np.ndarray], np.ndarray]: Gradient of zero-levelset function.

  • vertices – np.ndarray: Array of vertex coordinates.

  • faces – np.ndarray: Array of face connectivity.

  • interp_deg – int: Interpolation degree.

  • lp_dgr – int: \(l_p\)-norm, which is used to define the polynomial degree.

  • fun_handle – Callable[[np.ndarray], float]: Function to be evaluated on each quadrature point.

  • deg_integration – int: Degree of integration.

  • quadrature_rule – str: Quadrature rule type (β€˜Gauss_Legendre’ or β€˜Gauss_Simplex’).

  • pnts – np.ndarray: Quadrature points array.

  • ws – np.ndarray: Quadrature weights array.

  • index – int: Current index in the arrays.

Returns:

Updated index value.

Return type:

int

surfgeopy.utils module

surfgeopy.utils.SimpleImplicitSurfaceProjection(phi: Callable[[ndarray], float], dphi: Callable[[ndarray], ndarray], x: ndarray, max_iter: int = 10) ndarray[source]

Closest-point projection to surface given by an implicit function.

Parameters:
  • phi (Callable[[np.ndarray], float]) – Zero-levelset function.

  • dphi (Callable[[np.ndarray], np.ndarray]) – Gradient of zero-levelset function.

  • x (np.ndarray) – The point to be projected.

  • max_iter (int, default=10) – Maximum number of iterations for the projection.

Returns:

The projection point.

Return type:

np.ndarray

surfgeopy.utils.compute_norm(vec: ndarray) float[source]

Compute the Euclidean norm of a given vector.

Parameters:

vec (numpy.ndarray) – Input vector for which the Euclidean norm needs to be computed.

Returns:

Euclidean norm of the input vector.

Return type:

float

surfgeopy.utils.decimal_to_digits(decimal: float, min_digits: int | None = None) int[source]

Return the number of digits to the first nonzero decimal.

Parameters:
  • decimal (float) – The decimal number to analyze.

  • min_digits (Optional[int], default=None) – Minimum number of digits to return.

Returns:

Number of digits to the first nonzero decimal.

Return type:

int

surfgeopy.utils.float_to_int(data: ndarray, digits: int | None = None, dtype=<class 'numpy.int32'>) ndarray[source]

Convert a numpy array of float/bool/int to integers.

Parameters:
  • data (np.ndarray) – Input data array.

  • digits (Optional[int], default=None) – Precision for float conversion.

  • dtype (np.dtype, default=np.int32) – Datatype for the result.

Returns:

Data converted to integers.

Return type:

np.ndarray

surfgeopy.utils.max_edge_length(xs: ndarray) float[source]

Compute the maximum edge length of a triangle defined by its vertices.

Parameters:

xs (numpy.ndarray) – Array of shape (3, N) representing N triangles, where each row contains the coordinates of the vertices of a triangle in 3D space.

Returns:

Maximum edge length among all the triangles.

Return type:

float

surfgeopy.utils.pullback(qpoint_triangle: ndarray, duffy_transform: bool = False) ndarray[source]

Transform quadrature points from the reference simplex to a unit square.

Parameters:
  • qpoint_triangle (np.ndarray) – Quadrature points on the reference simplex.

  • duffy_transform (bool, default=False) – Whether to apply Duffy’s transform.

Returns:

Transformed points on the [-1, 1]^2.

Return type:

np.ndarray

surfgeopy.utils.pushforward(unisolvent_nodes: ndarray, duffy_transform: bool = False) ndarray[source]

Transform Chebyshev points from [-1, 1]^2 to a reference simplex.

Parameters:
  • unisolvent_nodes (np.ndarray) – Chebyshev points on the square.

  • duffy_transform (bool, default=False) – Whether to apply Duffy’s transform.

Returns:

Transformed points on the simplex.

Return type:

np.ndarray

surfgeopy.utils.read_mesh_data(mesh_path: str) Tuple[ndarray | None, ndarray | None][source]

Read mesh data from a MAT file.

Parameters:

mesh_path (str) – The file path to the MAT file containing mesh data.

Returns:

Vertices and faces data from the MAT file.

Return type:

Tuple[Optional[np.ndarray], Optional[np.ndarray]]

Raises:
  • FileNotFoundError – If the specified file does not exist.

  • Exception – If an error occurs during file reading.

surfgeopy.version module

Module contents

This is the curved_integration package initialization file.

It imports all necessary submodules and defines the package’s public API.

surfgeopy.SimpleImplicitSurfaceProjection(phi: Callable[[ndarray], float], dphi: Callable[[ndarray], ndarray], x: ndarray, max_iter: int = 10) ndarray[source]

Closest-point projection to surface given by an implicit function.

Parameters:
  • phi (Callable[[np.ndarray], float]) – Zero-levelset function.

  • dphi (Callable[[np.ndarray], np.ndarray]) – Gradient of zero-levelset function.

  • x (np.ndarray) – The point to be projected.

  • max_iter (int, default=10) – Maximum number of iterations for the projection.

Returns:

The projection point.

Return type:

np.ndarray

surfgeopy.compute_norm(vec: ndarray) float[source]

Compute the Euclidean norm of a given vector.

Parameters:

vec (numpy.ndarray) – Input vector for which the Euclidean norm needs to be computed.

Returns:

Euclidean norm of the input vector.

Return type:

float

surfgeopy.compute_surf_quadrature(ls_function: Callable[[ndarray], float], ls_grad_func: Callable[[ndarray], ndarray], vertices: ndarray, faces: ndarray, interp_deg: int, lp_dgr: int, Refinement: int, fun_handle: Callable[[ndarray], float], deg_integration: int = 14, quadrature_rule: str = 'Pull_back_Gauss') Tuple[ndarray, ndarray, ndarray][source]

Compute quadrature points and weights on curved triangles.

Parameters:
  • ls_function – Callable[[np.ndarray], float]: Zero-levelset function.

  • ls_grad_func – Callable[[np.ndarray], np.ndarray]: Gradient of zero-levelset function.

  • vertices – np.ndarray: Array of vertex coordinates.

  • faces – np.ndarray: Array of face connectivity.

  • interp_deg – int: Interpolation degree.

  • lp_dgr – int: \(l_p\)-norm, which is used to define the polynomial degree.

  • Refinement – int: Refinement level.

  • fun_handle – Callable[[np.ndarray], float]: Function to be evaluated on each quadrature point.

  • deg_integration – int: Degree of integration (default: 14).

  • quadrature_rule – str: Quadrature rule type (β€˜Gauss_Legendre’ or β€˜Gauss_Simplex’).

Returns:

Quadrature points, weights, and offset array.

Return type:

Tuple[np.ndarray, np.ndarray, np.ndarray]

surfgeopy.decimal_to_digits(decimal: float, min_digits: int | None = None) int[source]

Return the number of digits to the first nonzero decimal.

Parameters:
  • decimal (float) – The decimal number to analyze.

  • min_digits (Optional[int], default=None) – Minimum number of digits to return.

Returns:

Number of digits to the first nonzero decimal.

Return type:

int

surfgeopy.faces_to_edges(faces, return_index=False)[source]

Given a list of faces (n,3), return a list of edges (n*3,2)

Parameters:

faces ((n, 3) int) – Vertex indices representing faces

Returns:

edges – Vertex indices representing edges

Return type:

(n*3, 2) int

surfgeopy.float_to_int(data: ndarray, digits: int | None = None, dtype=<class 'numpy.int32'>) ndarray[source]

Convert a numpy array of float/bool/int to integers.

Parameters:
  • data (np.ndarray) – Input data array.

  • digits (Optional[int], default=None) – Precision for float conversion.

  • dtype (np.dtype, default=np.int32) – Datatype for the result.

Returns:

Data converted to integers.

Return type:

np.ndarray

surfgeopy.gauss_legendre_square(deg)[source]

Gauss-Legendre cubature rule on the square [-1, 1]^2.

Parameters:

deg (int) – Algebraic degree of precision of the rule.

Returns:

  • weights_ps (ndarray) – n-by-1 array of single or double, weights of quadrature points.

  • quad_ps (ndarray) – n-by-2 array of single or double, natural coordinates of quadrature points.

surfgeopy.hashable_rows(data, digits=None)[source]

Convert array rows into a hashable format.

Parameters:
  • data ((n, m) array) – Input data

  • digits (int or None, optional) – Number of digits to add to hash if data is floating point

Returns:

hashable – Custom data type which can be sorted or used as hash keys

Return type:

(n,) array

surfgeopy.integration(ls_function: ~typing.Callable[[~numpy.ndarray], float], ls_grad_func: ~typing.Callable[[~numpy.ndarray], ~numpy.ndarray], mesh: str, interp_deg: int, lp_dgr: int, Refinement: int, fun_handle: ~typing.Callable[[~numpy.ndarray], float] = <function <lambda>>, deg_integration: int = -1, quadrature_rule: str | None = None) ndarray[source]

Compute the integration of a function over curved triangles.

Parameters:
  • ls_function (Callable[[np.ndarray], float]) – Zero-levelset function.

  • ls_grad_func (Callable[[np.ndarray], np.ndarray]) – Gradient of the zero-levelset function.

  • mesh (str) – The file path to the MAT file containing mesh data.

  • interp_deg (int) – Interpolation degree.

  • lp_dgr (int) – The l_p-norm used to define the polynomial degree.

  • Refinement (int) – Refinement level.

  • fun_handle (Callable[[np.ndarray], float], optional) – Function to be evaluated on each quadrature point. Defaults to a constant function.

  • deg_integration (int, optional) – Degree of integration. Defaults to -1 (use default configuration).

  • quadrature_rule (Optional[str], optional) – Quadrature rule type. Can be β€˜Gauss_Legendre’ or β€˜Gauss_Simplex’. Defaults to None.

Returns:

Integration values for each curved triangle.

Return type:

np.ndarray

surfgeopy.max_edge_length(xs: ndarray) float[source]

Compute the maximum edge length of a triangle defined by its vertices.

Parameters:

xs (numpy.ndarray) – Array of shape (3, N) representing N triangles, where each row contains the coordinates of the vertices of a triangle in 3D space.

Returns:

Maximum edge length among all the triangles.

Return type:

float

surfgeopy.pullback(qpoint_triangle: ndarray, duffy_transform: bool = False) ndarray[source]

Transform quadrature points from the reference simplex to a unit square.

Parameters:
  • qpoint_triangle (np.ndarray) – Quadrature points on the reference simplex.

  • duffy_transform (bool, default=False) – Whether to apply Duffy’s transform.

Returns:

Transformed points on the [-1, 1]^2.

Return type:

np.ndarray

surfgeopy.pushforward(unisolvent_nodes: ndarray, duffy_transform: bool = False) ndarray[source]

Transform Chebyshev points from [-1, 1]^2 to a reference simplex.

Parameters:
  • unisolvent_nodes (np.ndarray) – Chebyshev points on the square.

  • duffy_transform (bool, default=False) – Whether to apply Duffy’s transform.

Returns:

Transformed points on the simplex.

Return type:

np.ndarray

surfgeopy.q_gauss_legendre(n, Domain=array([-1, 1]))[source]

Generate quadrature weights and nodes for Gauss-Legendre quadrature rule.

An n-point Gauss-Legendre quadrature rule is of degree 2n-1; that is, it integrates all polynomials up to degree 2n-1 exactly.

Parameters:
  • n (int) – Number of sample points and weights. It must be >= 1.

  • Domain (ndarray, optional) – Refers to the domain of integration [a, b]. The default domain is the bi-unit interval [-1, 1].

Returns:

  • x (ndarray) – 1-D ndarray containing the sample points.

  • w (ndarray) – 1-D ndarray containing the weights.

Notes

The function constructs the symmetric tridiagonal matrix and computes the eigenvalues and eigenvectors to obtain the quadrature points and weights.

The next steps ensure that zero is zero, and the points and weights are symmetric.

If the integration domain [a, b] is different from the default [-1, 1], the points and weights are transformed accordingly.

surfgeopy.quadrature_split_surf_tri(ls_function: Callable[[ndarray], float], ls_grad_func: Callable[[ndarray], ndarray], vertices: ndarray, faces: ndarray, interp_deg: int, lp_dgr: int, Refinement: int, fun_handle: Callable[[ndarray], float], deg_integration: int, quadrature_rule: str, pnts: ndarray, ws: ndarray, index: int) int[source]

For a mixed mesh, find the cell integration of the test function f.

Parameters:
  • ls_function – Callable[[np.ndarray], float]: Zero-levelset function.

  • ls_grad_func – Callable[[np.ndarray], np.ndarray]: Gradient of the zero-levelset function.

  • vertices – np.ndarray: Array of vertex coordinates.

  • faces – np.ndarray: Array of face connectivity.

  • interp_deg – int: Interpolation degree.

  • lp_dgr – int: \(l_p\)-norm, which is used to define the polynomial degree.

  • deg_integration – int: Degree of integration.

  • quadrature_rule – str: Quadrature rule type (β€˜Gauss_Legendre’ or β€˜Gauss_Simplex’).

  • pnts – np.ndarray: Quadrature points array.

  • ws – np.ndarray: Quadrature weights array.

  • index – int: Current index in the arrays.

Returns:

Updated index value.

Return type:

int

surfgeopy.quadrature_surf_tri(ls_function: Callable[[ndarray], float], ls_grad_func: Callable[[ndarray], ndarray], vertices: ndarray, faces: ndarray, interp_deg: int, lp_dgr: int, fun_handle: Callable[[ndarray], float], deg_integration: int, quadrature_rule: str, pnts: ndarray, ws: ndarray, index: int) int[source]

For a mixed mesh, find the cell integration of the test function f.

Parameters:
  • ls_function – Callable[[np.ndarray], float]: Zero-levelset function.

  • ls_grad_func – Callable[[np.ndarray], np.ndarray]: Gradient of zero-levelset function.

  • vertices – np.ndarray: Array of vertex coordinates.

  • faces – np.ndarray: Array of face connectivity.

  • interp_deg – int: Interpolation degree.

  • lp_dgr – int: \(l_p\)-norm, which is used to define the polynomial degree.

  • fun_handle – Callable[[np.ndarray], float]: Function to be evaluated on each quadrature point.

  • deg_integration – int: Degree of integration.

  • quadrature_rule – str: Quadrature rule type (β€˜Gauss_Legendre’ or β€˜Gauss_Simplex’).

  • pnts – np.ndarray: Quadrature points array.

  • ws – np.ndarray: Quadrature weights array.

  • index – int: Current index in the arrays.

Returns:

Updated index value.

Return type:

int

surfgeopy.quadrule_on_flat(deg)[source]

Quadrature rule

Parameters:

deg (int) – Algebraic degree of precision of the rule.

Returns:

  • weights_ps (ndarray) – n-by-1 array of single or double, weights of quadrature points.

  • quad_ps (ndarray) – n-by-3 array of single or double, natural coordinates of quadrature points.

surfgeopy.quadrule_on_simplex(deg)[source]
Parameters:
  • deg (Algebraic degree of precision of the rule.) – Algebraic degree of precision of the rule.

  • 0] (CUBATURE RULE ON THE SIMPLEX [0 0; 0 1; 1)

  • Legend

  • #DEG (algebraic degree of precision.)

  • #CARD (cardinality of the pointset.)

  • #W- (negative weights.)

  • #PT.O (points outside the simplex [0 0; 1 0; 0 1].)

  • #M.E. (maximum moment error in inf norm.)

  • points (Statistics of quadrature)

  • M.E. (# | DEG | CARD | W- | PT.O|)

  • #------------------------------------

  • 1.92e-16 (# | 1 | 1 | 0 | 0 |)

  • 1.18e-16 (# | 2 | 3 | 0 | 0 |)

  • 2.15e-16 (# | 3 | 4 | 0 | 0 |)

  • 1.39e-16 (# | 4 | 6 | 0 | 0 |)

  • 1.60e-16 (# | 5 | 7 | 0 | 0 |)

  • 1.08e-15 (# | 6 | 11 | 0 | 0 |)

  • 5.07e-16 (# | 7 | 12 | 0 | 0 |)

  • 8.05e-16 (# | 8 | 16 | 0 | 0 |)

  • 3.26e-16 (# | 9 | 19 | 0 | 0 |)

  • 7.22e-16 (# | 10 | 24 | 0 | 0 |)

  • 3.64e-15 (# | 11 | 27 | 0 | 0 |)

  • 1.61e-15 (# | 12 | 32 | 0 | 0 |)

  • 3.05e-16 (# | 13 | 36 | 0 | 0 |)

  • 4.37e-16 (# | 14 | 42 | 0 | 0 |)

  • 5.00e-16 (# | 15 | 46 | 0 | 0 |)

  • 5.67e-16 (# | 16 | 52 | 0 | 0 |)

  • 5.83e-16 (# | 17 | 57 | 0 | 0 |)

  • 6.11e-16 (# | 18 | 66 | 0 | 0 |)

  • 4.16e-16 (# | 19 | 70 | 0 | 0 |)

  • 4.89e-16 (# | 20 | 78 | 0 | 0 |)

  • 4.64e-16 (# | 21 | 85 | 0 | 0 |)

  • 7.56e-16 (# | 22 | 93 | 0 | 0 |)

  • 6.66e-16 (# | 23 | 100 | 0 | 0 |)

  • 7.81e-16 (# | 24 | 109 | 0 | 0 |)

  • 5.41e-16 (# | 25 | 117 | 0 | 0 |)

  • 0]. (CUBATURE RULE ON THE SIMPLEX [0 0; 0 1; 1)

  • --------------------------------------------------------------------

  • Input

  • ----------

  • deg

Returns:

  • weights_ps (N-by-1 array (single or double), weights of quadrature points)

  • quad_ps (N-by-2 array (single or double),) – natural coordinates of quadrature points

surfgeopy.read_mesh_data(mesh_path: str) Tuple[ndarray | None, ndarray | None][source]

Read mesh data from a MAT file.

Parameters:

mesh_path (str) – The file path to the MAT file containing mesh data.

Returns:

Vertices and faces data from the MAT file.

Return type:

Tuple[Optional[np.ndarray], Optional[np.ndarray]]

Raises:
  • FileNotFoundError – If the specified file does not exist.

  • Exception – If an error occurs during file reading.

surfgeopy.subdivide(vertices, faces, face_index=None, vertex_attributes=None, return_index=False)[source]

Subdivide a mesh into smaller triangles. Note that if face_index is passed, only those faces will be subdivided and their neighbors won’t be modified, making the mesh no longer β€œwatertight.”

Parameters:
  • vertices ((n, 3) float) – Vertices in space

  • faces ((m, 3) int) – Indices of vertices which make up triangular faces

  • face_index (array_like, optional) – Indices of faces to subdivide. If None, all faces of the mesh will be subdivided.

  • vertex_attributes (dict, optional) – Contains (n, d) attribute data

  • return_index (bool, optional) – If True, return index of original face for new faces

Returns:

  • new_vertices ((q, 3) float) – Vertices in space

  • new_faces ((p, 3) int) – Remeshed faces

  • index_dict (dict, optional) – Only returned if return_index is True. {index of original face : index of new faces}.

surfgeopy.unique_ordered(data, return_index=False, return_inverse=False)[source]

Returns the same as np.unique, but ordered as per the first occurrence of the unique value in data.

Parameters:
  • data (array-like) – Input data

  • return_index (bool, optional) – Return indices of unique values

  • return_inverse (bool, optional) – Return the inverse of the unique array

Returns:

  • unique (array-like) – The sorted unique values

  • index (array-like, optional) – The indices of the unique values

  • inverse (array-like, optional) – The indices to reconstruct the original data

surfgeopy.unique_rows(data, digits=None, keep_order=False)[source]

Returns indices of unique rows. It will return the first occurrence of a row that is duplicated: [[1,2], [3,4], [1,2]] will return [0,1]

Parameters:
  • data ((n, m) array) – Floating point data

  • digits (int or None, optional) – Number of digits to consider for uniqueness

Returns:

  • unique ((j,) int) – Index in data which is a unique row

  • inverse ((n,) int) – Array to reconstruct original Example: data[unique][inverse] == data