跳转到主要内容

raygeo.mesh.gradient

Functions

compute_gradient_field()

compute_gradient_field(
mesh: types.TriangleMesh,
u_field: Sequence[float],
) -> Sequence[tuple[float, float]]

Compute the gradient of the scalar field on each triangle.

Given the solution u to the Laplace equation, computes ∇u = (∂u/∂x, ∂u/∂y) in the interior of each triangle of the mesh (piecewise constant).

ParameterTypeDescription
meshtypes.TriangleMeshTriangleMesh with the same vertex count as u_field.
u_fieldSequence[float]Scalar field values, one per vertex.
ReturnsSequence[tuple[float, float]]List of (gx, gy) pairs, one per triangle in mesh order.
ComplexityO(n) where n = number of triangles

Gradient field ∇u (red) and perpendicular flow ∇u⊥ (blue) on the Laplace solution

Gradient field ∇u (red) and perpendicular flow ∇u⊥ (blue) on the Laplace solution

Gradient field ∇u (red) and perpendicular flow ∇u⊥ (blue) on a multi-island domain

Gradient field ∇u (red) and perpendicular flow ∇u⊥ (blue) on a multi-island domain