Quality metrics + smoothing¶
Per-element quality computations and the pre-quadrangulation smoother.
mesh_quality¶
admesh.mesh_quality ¶
mesh_quality(p: ArrayLike, t: ArrayLike, element: str = 'triangle') -> tuple[float, float, NDArray[np.float64]]
Element-quality statistics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p
|
(array_like, shape(n, 2))
|
Nodal coordinates. |
required |
t
|
(array_like, shape(m, 3) or (m, 4))
|
Connectivity list (0-based, per the port's indexing convention). |
required |
element
|
('triangle', 'quad')
|
Element type. |
"triangle"
|
Returns:
| Name | Type | Description |
|---|---|---|
min_q |
float
|
|
mean_q |
float
|
|
q |
(ndarray, shape(m))
|
Per-element quality in [0, 1]. |
Source code in src/admesh/_stages/quality.py
right_iso_quality¶
admesh.right_iso_quality ¶
Mesh-wide right-isoceles quality score in [0, 1].
Companion to :func:mesh_quality (which scores deviation from
equilateral). Reported side-by-side as a delta after running
:func:admesh.quad_prep.smooth_for_quadrangulation (spec-004 SC-007).
Per-element score is the product of three terms in [0, 1]:
- Leg-equality:
1 - |L1 - L2| / max(L1, L2) - Right-angle:
1 - |angle_apex - π/2| / (π/2) - Hypotenuse-fit:
1 - |L_hyp - sqrt(2) * (L1+L2)/2| / L_hyp
where L1, L2 are the two shortest sides (legs), L_hyp is the
longest (hypotenuse), and angle_apex is the angle between the
two legs. The mesh score is the unweighted mean over elements.
The existing :func:mesh_quality is NOT modified — this is purely
additive (spec-004 FR-006).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p
|
(array_like, shape(N, 2))
|
Nodal coordinates. |
required |
t
|
(array_like, shape(M, 3))
|
Triangle connectivity (0-based). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Mesh-wide right-isoceles quality, in |
Source code in src/admesh/_stages/quality.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
smooth_for_quadrangulation¶
admesh.smooth_for_quadrangulation ¶
smooth_for_quadrangulation(p: NDArray[float64], t: NDArray[int64], fd: Callable[[NDArray[float64]], NDArray[float64]], h: Callable[[NDArray[float64]], NDArray[float64]] | None = None, pair_hint: bool = True, n_outer: int = 2) -> tuple[NDArray[np.float64], NDArray[np.int64]]
Nudge a triangle mesh toward right-isoceles for downstream quad fusion.
Implements the SVD-invariant FEM target-Jacobian formulation
(Formulation 1 in specs/004-quad-prep-smoother/research.md).
Connectivity is preserved (FR-002): t_out is the same array
object as t.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p
|
ndarray, shape (N, 2), dtype float64
|
Node coordinates of the input triangulation. |
required |
t
|
ndarray, shape (M, 3), dtype int64
|
Triangle index triples; CCW winding. |
required |
fd
|
callable
|
Signed-distance function |
required |
h
|
callable
|
Size field |
None
|
pair_hint
|
bool
|
When |
True
|
n_outer
|
int
|
Number of outer iterations. Each outer pass does one solve plus
one boundary projection. Must be |
2
|
Returns:
| Name | Type | Description |
|---|---|---|
p_out |
ndarray, shape (N, 2), dtype float64
|
|
t_out |
ndarray, shape (M, 3), dtype int64
|
Same array object as input |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |