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