Core Functions¶
    This file contains the core functions needed for the local update.
For readability we sometimes include the shape of arrays, with the following meaning: N: number of elements in mesh (i.e. triangles) d_e: number of points in one element M: number of points in mesh d: dimension of the underlying space
    dataclass for holding everything that belongs to the mesh.
Note that this only supports keyword arguments due to Chex.
Use it like:
mesh = Mesh(points=points, elements=elements)
N: Number of elements in a mesh (i.e. triangles) d_e: Number of points in an element M: Number of points in a mesh d: Dimension of the underlying space
Attributes:
| Name | Type | Description | 
|---|---|---|
| points | np.ndarray | [M, d] array of points | 
| elements | np.ndarray | [N, d_e] array of indices into points that correspond to elements in a mesh | 
| points_triangle | np.ndarray | [N, d_e, d] like elements, but with the points instead of indices | 
    Constructor.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| points | np.ndarray | [M, d] array of points | required | 
| elements | np.ndarray | [N] array of | required | 
    Custom vectorized implementation of :math:\\left<A \\mathbf{x}_1, \\mathbf{x}_2 \\right>.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| A | np.ndarray | [N, d, d] Array of tensors | required | 
| x1 | np.ndarray | [N, d] Point 1 | required | 
| x2 | np.ndarray | [N, d] Point 2 | required | 
Returns:
| Type | Description | 
|---|---|
| np.ndarray | [N] array of norm values | 
    Custom vectorized implementation of:math:\\sqrt{\\left<A \\mathbf{x}_1, \\mathbf{x}_2 \\right>}.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| A | np.ndarray | [N, d, d] Array of tensors | required | 
| x1 | np.ndarray | [N, d] Point 1 | required | 
| x2 | np.ndarray | [N, d] Point 2 | required | 
Returns:
| Type | Description | 
|---|---|
| np.ndarray | [N] array of norm values | 
_update_point(x1: np.ndarray, x2: np.ndarray, x3: np.ndarray, D: np.ndarray, u1: np.ndarray, u2: np.ndarray) -> np.ndarray
Calculates the minimal solution along the border of a triangle.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| x1 | np.ndarray | [N, d] array with stack of the first vertex of the triangles | required | 
| x2 | np.ndarray | [N, d] array with stack of the second vertex of the triangles | required | 
| x3 | np.ndarray | [N, d] array with stack of the third vertex of the triangles | required | 
| D | np.ndarray | [N, d] array with stack of speed tensors | required | 
| u1 | np.ndarray | [N] array with current solution at the first vertex | required | 
| u2 | np.ndarray | [N] array with current solution at the first vertex | required | 
Returns:
| Type | Description | 
|---|---|
| np.ndarray | [N] array minimal solution along the borders of the triangle | 
_update_triangle(x1: np.ndarray, x2: np.ndarray, x3: np.ndarray, D: np.ndarray, u1: np.ndarray, u2: np.ndarray) -> np.ndarray
Update triangle(s) locally.
Calculates all triangle updates in a broadcasted way by solving a constrained optimization problem analytically. See paper on FIM for triangulated meshes for more infos.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| x1 | np.ndarray | [N, d] array with stack of the first vertex of the triangles | required | 
| x2 | np.ndarray | [N, d] array with stack of the second vertex of the triangles | required | 
| x3 | np.ndarray | [N, d] array with stack of the third vertex of the triangles | required | 
| D | np.ndarray | [N, d] array with stack of speed tensors | required | 
| u1 | np.ndarray | [N] array with current solution at the first vertex | required | 
| u2 | np.ndarray | [N] array with current solution at the first vertex | required | 
Returns:
| Type | Description | 
|---|---|
| np.ndarray | [N] minimal solution along the borders of the triangle | 
    Performs one Jacobi update.
Calculates the solution to all update direction and picks the smallest one for each point.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| mesh | Mesh | Mesh | required | 
| D | np.ndarray | [N, d, d] array with metric tensor field | required | 
| solution | np.ndarray | [M] array solution before iteration | required | 
Returns:
| Type | Description | 
|---|---|
| np.ndarray | [M] new solution after one iteration | 
    Performs one Jacobi update.
Calculates the solution to all update direction and picks the smallest one for each point. This does not include the self update, so a node is always updated from the adjacent nodes, so using this method the iteration may NOT converge.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| mesh | Mesh | Mesh | required | 
| D | np.ndarray | [N, d, d] array with metric tensor field | required | 
| solution | np.ndarray | [M] array solution before iteration | required | 
Returns:
| Type | Description | 
|---|---|
| np.ndarray | [M] new solution after one iteration | 
    Performs one Jacobi update.
Calculates the solution to all update direction and picks the smallest one for each point. Instead of the minimum the softmin is used.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| mesh | Mesh | Mesh | required | 
| D | np.ndarray | [N, d, d] array with metric tensor field | required | 
| solution | np.ndarray | [M] array solution before iteration | required | 
Returns:
| Type | Description | 
|---|---|
| np.ndarray | [M] new solution after one iteration |