Mesh Metricsο
The nanomesh.metrics
module helps with calculating different types of cell metrics.
There are a few higher level functions available. While one could use
calculate_all_metrics()
to calculate all available metrics,
each function is also available by itself.
histogram()
and plot2d()
are helpers
to visualize the metrics.
See also
For more info, see the example on Calculate mesh quality metrics.
Functions
These metrics are currently available:
Calculate the area of a triangle. |
|
Calculate the Frobenius condition number of the transformation matrix from an equilateral triangle to a triangle. |
|
Calculate the aspect ratio of a triangle. |
|
Calculate the condition number of a triangle. |
|
Calculate the distortion of a triangle. |
|
Calculate the maximal (non-oriented) angle of a triangle. |
|
|
Calculate the ratio between the longest and shortest edge lengths of a triangle. |
Calculate the minimal (non-oriented) angle of a triangle. |
|
R/2r, where R and r respectively denote the circumradius and the inradius of t. |
|
Calculate the square of the relative size of a triangle. |
|
Calculate the scaled Jacobian of a triangle. |
|
Calculate the shape of a triangle. |
|
Calculate the product of shape and relative size of a triangle. |
Utility functions:
|
Calculate all available metrics. |
|
Create a mesh plot with the cells are colored by the cell quality. |
|
Create a mesh plot with the cells are colored by the cell quality. |
Referenceο
- nanomesh.metrics.calculate_all_metrics(mesh: Mesh, inplace: bool = False) dict [source]ο
Calculate all available metrics.
- nanomesh.metrics.histogram(mesh: Mesh, *, metric: str, ax: Optional[Axes] = None, **kwargs) Axes [source]ο
Create a mesh plot with the cells are colored by the cell quality.
- Parameters
mesh (Mesh) β Input mesh
metric (str) β Metric to calculate.
ax (matplotlib.axes.Axes) β If specified, ax will be used to create the subplot.
vmin (int, float) β Set the lower/upper boundary for the color value.
vmax (int, float) β Set the lower/upper boundary for the color value.
cmap (str) β Set the color map.
**kwargs β Keyword arguments passed on to
matplotlib.pyplot.hist()
.
- Returns
ax
- Return type
- nanomesh.metrics.plot2d(mesh: Mesh, *, metric: str, ax: Optional[Axes] = None, **kwargs) Axes [source]ο
Create a mesh plot with the cells are colored by the cell quality.
- Parameters
mesh (Mesh) β Input mesh
metric (str) β Metric to calculate.
ax (matplotlib.axes.Axes) β If specified, ax will be used to create the subplot.
vmin (int, float) β Set the lower/upper boundary for the color value. Defaults to the 1st and 99th percentile, respectively.
vmax (int, float) β Set the lower/upper boundary for the color value. Defaults to the 1st and 99th percentile, respectively.
cmap (str) β Set the color map.
**kwargs β Keyword arguments passed on to
matplotlib.pyplot.tripcolor()
.
- Returns
ax
- Return type
- nanomesh.metrics.area(mesh: Mesh) ndarray ο
Calculate the area of a triangle.
- Parameters
mesh (Mesh) β Input mesh
- Returns
quality β Array with cell qualities.
- Return type
- nanomesh.metrics.aspect_frobenius(mesh: Mesh) ndarray ο
Calculate the Frobenius condition number of the transformation matrix from an equilateral triangle to a triangle.
- Parameters
mesh (Mesh) β Input mesh
- Returns
quality β Array with cell qualities.
- Return type
- nanomesh.metrics.aspect_ratio(mesh: Mesh) ndarray ο
Calculate the aspect ratio of a triangle.
- Parameters
mesh (Mesh) β Input mesh
- Returns
quality β Array with cell qualities.
- Return type
- nanomesh.metrics.condition(mesh: Mesh) ndarray ο
Calculate the condition number of a triangle.
- Parameters
mesh (Mesh) β Input mesh
- Returns
quality β Array with cell qualities.
- Return type
- nanomesh.metrics.distortion(mesh: Mesh) ndarray ο
Calculate the distortion of a triangle.
- Parameters
mesh (Mesh) β Input mesh
- Returns
quality β Array with cell qualities.
- Return type
- nanomesh.metrics.max_angle(mesh: Mesh) ndarray ο
Calculate the maximal (non-oriented) angle of a triangle.
- Parameters
mesh (Mesh) β Input mesh
- Returns
quality β Array with cell qualities.
- Return type
- nanomesh.metrics.max_min_edge_ratio(mesh: Mesh) ndarray [source]ο
Calculate the ratio between the longest and shortest edge lengths of a triangle.
- Parameters
mesh (Mesh) β Input mesh
- Returns
quality β Array with cell qualities.
- Return type
- nanomesh.metrics.min_angle(mesh: Mesh) ndarray ο
Calculate the minimal (non-oriented) angle of a triangle.
- Parameters
mesh (Mesh) β Input mesh
- Returns
quality β Array with cell qualities.
- Return type
- nanomesh.metrics.radius_ratio(mesh: Mesh) ndarray ο
Calculate the radius ratio of a triangle. The radius ratio of a triangle t is: R/2r, where R and r respectively denote the circumradius and the inradius of t.
- Parameters
mesh (Mesh) β Input mesh
- Returns
quality β Array with cell qualities.
- Return type
- nanomesh.metrics.relative_size_squared(mesh: Mesh) ndarray ο
Calculate the square of the relative size of a triangle.
- Parameters
mesh (Mesh) β Input mesh
- Returns
quality β Array with cell qualities.
- Return type
- nanomesh.metrics.scaled_jacobian(mesh: Mesh) ndarray ο
Calculate the scaled Jacobian of a triangle.
- Parameters
mesh (Mesh) β Input mesh
- Returns
quality β Array with cell qualities.
- Return type
- nanomesh.metrics.shape(mesh: Mesh) ndarray ο
Calculate the shape of a triangle.
- Parameters
mesh (Mesh) β Input mesh
- Returns
quality β Array with cell qualities.
- Return type