Mesh Generation Helpers¶
mesh_generation
¶
Helper functions that produce simple 2D rectangular meshes that can be used for testing.
fimjax.util.mesh_generation.Mesh
¶
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 |
__init__
¶
Constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
points
|
np.ndarray
|
[M, d] array of points |
required |
elements
|
np.ndarray
|
[N] array of |
required |
fimjax.util.mesh_generation.tensor_field
¶
generates identity
Parameters:
Name | Type | Description | Default |
---|---|---|---|
alpha
|
float
|
description |
required |
num_elems
|
int
|
description |
required |
dimension
|
int
|
description |
required |
dtype
|
_type_
|
description. Defaults to jnp.double. |
jnp.double
|
Returns:
Type | Description |
---|---|
np.ndarray
|
np.ndarray: description |
fimjax.util.mesh_generation.generate_random_2d_mesh
¶
Generates a random 2D mesh with random metrics (positive definite with eigenvalues between 1 and 5)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
discretization
|
int
|
Number of points in each dimension |
required |
fimjax.util.mesh_generation.generate_identity_2d_mesh
¶
Generates a 2D mesh with isotropic metrics with velocity 1 (identity tensor)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
discretization
|
int
|
Number of points in each dimension |
required |
fimjax.util.mesh_generation.generate_benchmark_data
¶
Generates benchmark data for benchmarking and also for finite difference validation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir
|
optional
|
directory to store meshes and tensor. Defaults to "data". |
'data'
|
fimjax.util.mesh_generation.read_benchmark_data
¶
read_benchmark_data(dir: str = 'data', maximal_discretization: int = np.inf) -> tuple[dict[int, tuple[Mesh, np.ndarray]], dict[int, tuple[Mesh, np.ndarray]]]
Reads benchmark data from directory
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir
|
optional
|
directory where benchmark data is stored. Defaults to "data". |
'data'
|
Returns:
Type | Description |
---|---|
tuple[dict[int, tuple[Mesh, np.ndarray]], dict[int, tuple[Mesh, np.ndarray]]]
|
dict[int, tuple[Mesh, np.ndarray]]: Dictionary with discretization as key and tuple of mesh and tensor as value |