Skip to content

Mesh Preprocessing

preprocessing

Test mesh creation and preparation for Eikonax solver runs.

Info

The creation of test meshes can be done with any other tool. The format of the required adjacency data for Eikonax is strict, however.

Classes:

Name Description
MeshData

Data characterizing a computational mesh from a vertex-centered perspective.

InitialSites

Initial site info.

Functions:

Name Description
create_test_mesh

Create a simple test mesh with Scipy's Delauny functionality.

get_adjacent_vertex_data

Preprocess mesh data for a vertex-centered evaluation.

eikonax.preprocessing.MeshData dataclass

Data characterizing a computational mesh from a vertex-centered perspective.

Attributes:

Name Type Description
vertices jax.Array | npt.NDArray

The coordinates of the vertices in the mesh. The dimension of this array is (num_vertices, dim), where num_vertices is the number of vertices in the mesh and dim is the dimension of the space in which the mesh is embedded.

simplices jax.Array | npt.NDArray

The vertex indices for each simplex in the mesh. The dimension of this array is (num_simplices, 3), where num_simplices is the number of simplices in the mesh.

adjacency_data jax.Array | npt.NDArray

Adjacency data for each vertex. This is the list of adjacent triangles, together with the two vertices that span the respective triangle with the current vertex. The dimension of this array is (num_vertices, max_num_adjacent_simplices, 4), where max_num_adjacent_simplices is the maximum number of simplices that are adjacent to a vertex in the mesh. All entries have this maximum size, as JAX only operates on homogeneous data structures. If a vertex has fewer than max_num_adjacent_simplices adjacent simplices, the remaining entries are filled with -1.

__post_init__

__post_init__() -> None

Initialize data structures and convert to JAX arrays.

eikonax.preprocessing.InitialSites dataclass

Initial site info.

For a unique solution of the state-constrained Eikonal equation, the solution values need to be given a number of initial points (at least one). Multiple initial sites need to be compatible, in the sense that the arrival time from another source is not smaller than the initial value itself.

Attributes:

Name Type Description
inds jax.Array | npt.NDArray

The indices of the nodes where the initial sites are placed.

values jax.Array | npt.NDArray

The values of the initial sites.

__post_init__

__post_init__() -> None

Convert to jax arrays.

eikonax.preprocessing.create_test_mesh

create_test_mesh(mesh_bounds_x: Annotated[Iterable[Real], Is[lambda x: len(x) == 2]], mesh_bounds_y: Annotated[Iterable[Real], Is[lambda x: len(x) == 2]], num_points_x: Annotated[int, Is[lambda x: x >= 2]], num_points_y: Annotated[int, Is[lambda x: x >= 2]]) -> tuple[jtFloat[npt.NDArray, 'num_vertices dim'], jtInt[npt.NDArray, 'num_simplices 3']]

Create a simple test mesh with Scipy's Delaunay functionality.

This methods creates a simple square mesh with Scipy's Delaunay triangulation.

Parameters:

Name Type Description Default
mesh_bounds_x Iterable[float, float]

Mesh bounds for x-direction

required
mesh_bounds_y Iterable[float, float]

Mesh bounds for y-direction

required
num_points_x int

Number of vertices for x-direction

required
num_points_y int

Number of vertices for y-direction

required

Raises:

Type Description
ValueError

Checks that mesh bounds have correct dimension

ValueError

Checks that mesh bounds are provided correctly

ValueError

Checks that at least two mesh points are chosen

Returns:

Type Description
tuple[jtFloat[npt.NDArray, 'num_vertices dim'], jtInt[npt.NDArray, 'num_simplices 3']]

tuple[npt.NDArray, npt.NDArray]: Array of vertex coordinates and array of simplex indices

eikonax.preprocessing.get_adjacent_vertex_data

get_adjacent_vertex_data(simplices: jtInt[jax.Array | npt.NDArray, 'num_simplices 3'], num_vertices: Annotated[int, Is[lambda x: x > 0]]) -> jtInt[jax.Array, 'num_vertices max_num_adjacent_simplices 4']

Preprocess mesh data for a vertex-centered evaluation.

Standard mesh tools provide vertex coordinates and the vertex indices for each simplex. For the vertex-centered solution of the Eikonal equation, however, we need the adjacent simplices/vertices for each vertex. This method performs the necessary transformation.

Parameters:

Name Type Description Default
simplices npt.NDArray

Vertex indices for all simplices

required
num_vertices int

Number of vertices in the mesh

required

Returns:

Type Description
jtInt[jax.Array, 'num_vertices max_num_adjacent_simplices 4']

npt.NDArray: Array containing for each vertex the vertex and simplex indices of all adjacent simplices. Dimension is (num_vertices, max_num_adjacent_simplices, 4), where the 4 entries contain the index of an adjacent simplex and the associated vertices. To ensure homogeneous arrays, all vertices have the same (maximum) number of adjacent simplices. Non-existing simplices are buffered with the value -1.