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).
| Parameter | Type | Description |
|---|---|---|
mesh | types.TriangleMesh | TriangleMesh with the same vertex count as u_field. |
u_field | Sequence[float] | Scalar field values, one per vertex. |
| Returns | Sequence[tuple[float, float]] | List of (gx, gy) pairs, one per triangle in mesh order. |
| Complexity | O(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 a multi-island domain