Algorithm Search⌘K

Algorithmcore

Sweeping for hexahedral meshes

Also called swept meshing, one-to-one sweep, many-to-one sweep.

Meshes a two-and-a-half dimensional solid by sweeping the quad mesh of a source face to a target face through layers, the most used hex method in practice.

Time
O(K n) worst
Space
O(K n) extra
Where
K = the number of layers of hexes; n = the number of vertices of the source quad mesh
Properties
deterministicexactiterative
Origin
B. Shih, H. Sakurai, Patrick M. Knupp, 1996

Sweeping makes an all-hex mesh of a solid that is a quad face moved along a path, such as an extruded or revolved part. The user gives a source face with a quad mesh, a target face, and linking sides that join them and are already meshed in layers. Each layer of the sweep is a copy of the source mesh: the boundary nodes of the copy are on the linking sides, and the inner nodes are placed by a map from the source face. Corresponding quads of two neighbouring layers are joined into a hex. This page is one method for hexahedral mesh generation, and it meshes only solids that have a sweep direction, while that page states the general problem and its limits. Sweeping is the main hex method in commercial meshers, where the user first cuts the part into sweepable volumes.

In plain words

Think of a cookie cutter pushed through dough. On the face of the cutter we draw a grid of four-sided cells. We push copies of this grid along the part, one layer at a time, to the far end. Two copies in a row, with their matching cells joined, make a layer of bricks.

The edge of each copy must follow the side walls of the part, so it is known. The inner points are not known. A simple rule is to find the stretch, turn and shift that best moves the source edge onto the new edge, and to apply the same move to the inner points.

The bricks are good when each step from one layer to the next is a gentle move. If one layer turns too far against the last one, the bricks between them collapse, even if their corners look correct.

The problem

The source face is a polygon SS in the plane with a conforming mesh of strictly convex counterclockwise quads. Its vertices are pvp_v, and its boundary loop is the cycle of vertices ℓ1,…,ℓm\ell_1, \ldots, \ell_m, not all on one line. The linking sides are meshed already, so the input also gives the position Bk[ℓi]∈R3B_k[\ell_i] \in \mathbb{R}^3 of each loop vertex on each layer k=0,…,Kk = 0, \ldots, K, with K≥1K \ge 1. Layer 00 is the source face and layer KK is the target face.

The output is a node xk,vx_{k,v} for every layer and every source vertex, and the KK times QQ hexes that join quad (a,b,c,d)(a, b, c, d) of layer kk to the same quad of layer k+1k + 1. Here QQ is the number of source quads. A hex is valid if its trilinear map from the unit cube has det⁡J>0\det J > 0 at every point, as on the scaled Jacobian page. A mesh is valid if every hex is valid and two hexes meet only in a common face, edge or vertex.

The algorithm

For layer kk, line L2 finds the affine map φk(p)=Lkp+tk\varphi_k(p) = L_k p + t_k, with LkL_k a 3×23 \times 2 matrix, that minimizes ∑i∥φk(pℓi)−Bk[ℓi]∥2\sum_i \lVert \varphi_k(p_{\ell_i}) - B_k[\ell_i] \rVert^2. This is a least squares problem with one 3×33 \times 3 system of normal equations per coordinate. CERTIFY tests the slab map between two layers. Its coefficients b0,b1,b2b_0, b_1, b_2 are given below.

  1. SWEEP(p, quads, loop, B)
  2. 1for k ← 0 to K do
  3. 2φ_k ← the least squares affine map with φ_k(p_ℓ) ≈ B_k[ℓ] for the loop vertices ℓ
  4. 3for each source vertex v do
  5. 4x_{k,v} ← B_k[v] if v is on the loop, else φ_k(p_v)
  6. 5H ← empty list
  7. 6for k ← 0 to K − 1 do
  8. 7for each source quad (a, b, c, d) do
  9. 8append the hex (x_{k,a}, x_{k,b}, x_{k,c}, x_{k,d}, x_{k+1,a}, x_{k+1,b}, x_{k+1,c}, x_{k+1,d}) to H
  10. 9ok ← every hex of H has 8 positive corner Jacobians
  11. 10return H, x, φ, ok
  12. CERTIFY(p, loop, x, φ)
  13. 11for k ← 0 to K do
  14. 12if x_{k,v} ≠ φ_k(p_v) for some vertex v then return false
  15. 13for k ← 0 to K − 1 do
  16. 14for each loop vertex ℓ do
  17. 15(b_0, b_1, b_2) ← the slab coefficients of φ_k and φ_{k+1} at p_ℓ
  18. 16if not (b_0 > 0 and b_2 > 0 and (b_1 ≥ 0 or b_1² < b_0 b_2)) then return false
  19. 17return true

Lines L1 to L4 build the layers. A loop vertex keeps its given position, so the mesh follows the linking sides exactly. The inner nodes copy the source mesh through the fitted map. Lines L5 to L8 join the layers. The hex has the standard vertex order, so its bottom face is the source quad and its top face is the same quad one layer up. Line L9 is the usual check of the corner Jacobians. It is necessary for validity but not sufficient.

CERTIFY is the stronger test. When every layer is affine, the hexes of slab kk are pieces of the slab map

Fk(p,w)=(1−w) φk(p)+w φk+1(p),p∈S, w∈[0,1].F_k(p, w) = (1 - w)\,\varphi_k(p) + w\,\varphi_{k+1}(p), \qquad p \in S,\ w \in [0, 1].

With Lk=[ lk,1 lk,2 ]L_k = [\,l_{k,1}\ l_{k,2}\,] and d(p)=φk+1(p)−φk(p)d(p) = \varphi_{k+1}(p) - \varphi_k(p), its Jacobian determinant is a quadratic in ww:

det⁡DFk=b0(1−w)2+2b1w(1−w)+b2w2,\det DF_k = b_0 (1 - w)^2 + 2 b_1 w (1 - w) + b_2 w^2,
b0=det⁡[lk,1,lk,2,d],b2=det⁡[lk+1,1,lk+1,2,d],2b1=det⁡[lk,1,lk+1,2,d]+det⁡[lk+1,1,lk,2,d].b_0 = \det[l_{k,1}, l_{k,2}, d], \quad b_2 = \det[l_{k+1,1}, l_{k+1,2}, d], \quad 2 b_1 = \det[l_{k,1}, l_{k+1,2}, d] + \det[l_{k+1,1}, l_{k,2}, d].

Line L16 is an exact test that this quadratic is positive on [0,1][0, 1]. The coefficients are affine in pp, so a test at the loop vertices covers the whole face.

Example

The source face is the square [0,2]2[0, 2]^2 with the 2×22 \times 2 grid of unit quads. There are three layers, all about the center (1,1)(1, 1). Layer 00 is the source at height 00. Layer 11 at height 11 applies the matrix A1=(1−1/21/21)A_1 = \begin{pmatrix} 1 & -1/2 \\ 1/2 & 1 \end{pmatrix}, which turns and stretches the square, with det⁡A1=5/4\det A_1 = 5/4. Layer 22 at height 22 is the target face, the square turned by 9090 degrees. Each loop is an exact affine image of the source loop, so L2 recovers the map exactly, and the inner node (1,1)(1, 1) stays at (1,1)(1, 1) on every layer. The corner (0,0)(0, 0) goes to (1/2,−1/2,1)(1/2, -1/2, 1) and then to (2,0,2)(2, 0, 2).

slab (b0,b1,b2)(b_0, b_1, b_2) at every loop vertex corner Jacobians of each hex volume of each hex
0 (1,1,5/4)(1, 1, 5/4) 1,1,1,1,5/4,5/4,5/4,5/41, 1, 1, 1, 5/4, 5/4, 5/4, 5/4 13/1213/12
1 (5/4,1/2,1)(5/4, 1/2, 1) 5/4,5/4,5/4,5/4,1,1,1,15/4, 5/4, 5/4, 5/4, 1, 1, 1, 1 11/1211/12

All coefficients are positive, so CERTIFY returns true and every hex is valid at every point. The eight volumes add up to 88, the volume of the swept solid. Every node of layer 22 is the source node (x,y)(x, y) moved to (2−y,x,2)(2 - y, x, 2), so the target face gets the source mesh turned by 9090 degrees.

A twist that looks valid. Now use two layers only, and let layer 11 be the source turned by 180180 degrees about (1,1)(1, 1), at height 11. Every hex has all eight corner Jacobians equal to 11, so L9 sets ok to true. But the coefficients are (1,−1,1)(1, -1, 1), so det⁡DF0=(1−2w)2\det DF_0 = (1 - 2w)^2, which is 00 at w=1/2w = 1/2. All four hexes pass through the axis point (1,1,1/2)(1, 1, 1/2), and each has the volume 1/31/3 in place of 11. CERTIFY returns false. With the stretched turn diag⁡(−1,−2)\operatorname{diag}(-1, -2) in place of the half turn, the corners are still positive, but det⁡J<0\det J < 0 inside every hex at w=2/5w = 2/5.

Correctness

L4 keeps every loop vertex, and when a loop is the image of an affine map, the fit is exact and the whole layer is that image, so the target mesh is the expected one. For validity, an affine layer pair makes each hex the slab map FkF_k applied to (source quad) times [0,1][0, 1]. The chain rule then gives det⁡Jhex=det⁡DFk⋅det⁡DP\det J_{\text{hex}} = \det DF_k \cdot \det DP, where PP is the bilinear map of the source quad. For a strictly convex quad, det⁡DP\det DP is affine and positive at the corners, so it is positive. So the hexes are valid when every slab map is orientation preserving. If the slab maps are also one to one, the hexes fill the solid without overlap. For planar layers at increasing heights, CERTIFY implies this. The full proof is below.

What is proved and what is measured are different here. The proof covers only affine layers and convex source quads. For curved linking sides, real sweepers fit or blend non-affine maps, and then validity is measured by the corner check of L9 or by a scaled Jacobian sample, not proved. The tests of the implementation check the example, the half turn, the target mesh, and 500 random sweeps. In each random sweep, CERTIFY agrees with an exact minimization of det⁡((1−w)Ak+wAk+1)\det((1 - w) A_k + w A_{k+1}), and the hex volumes add up to the exact integral of the slab determinant.

Proof: An affine sweep with one to one, orientation preserving slab maps gives valid hexahedrafull

Setting. The source face is a polygon SS in the plane with a conforming mesh of strictly convex quadrilaterals. Each quad (a,b,c,d)(a, b, c, d) is counterclockwise. The boundary loop of SS is the cycle of mesh vertices ℓ1,…,ℓn\ell_1, \ldots, \ell_n, and these points are not all on one line. SWEEP gets the positions Bk[ℓi]∈R3B_k[\ell_i] \in \mathbb{R}^3 of the loop vertices on the layers k=0,…,Kk = 0, \ldots, K, with K≥1K \ge 1. Line L2 fits the affine map φk(p)=Lkp+tk\varphi_k(p) = L_k p + t_k, with LkL_k a 3×23 \times 2 matrix, that minimizes ∑i∥φk(pℓi)−Bk[ℓi]∥2\sum_i \lVert \varphi_k(p_{\ell_i}) - B_k[\ell_i] \rVert^2. Lines L3 and L4 set xk,v=Bk[v]x_{k,v} = B_k[v] for a loop vertex and xk,v=φk(pv)x_{k,v} = \varphi_k(p_v) for the other vertices. Line L8 makes the hex with the corners xk,a,xk,b,xk,c,xk,dx_{k,a}, x_{k,b}, x_{k,c}, x_{k,d} and then xk+1,a,…,xk+1,dx_{k+1,a}, \ldots, x_{k+1,d}. Its map from the unit cube is the trilinear map H(u,v,w)H(u, v, w) with these corner images.

We call layer kk affine if xk,v=φk(pv)x_{k,v} = \varphi_k(p_v) for every vertex vv. For an affine layer pair k,k+1k, k + 1, the slab map is

Fk(p,w)=(1−w) φk(p)+w φk+1(p),p∈S, w∈[0,1].F_k(p, w) = (1 - w)\,\varphi_k(p) + w\,\varphi_{k+1}(p), \qquad p \in S,\ w \in [0, 1].

Claim.

  1. SWEEP stops, and every loop vertex of layer kk is at its given position Bk[v]B_k[v].
  2. The normal equations of L2 are regular. If the given loop of layer kk is ψ(pℓi)\psi(p_{\ell_i}) for an affine map ψ\psi, then φk=ψ\varphi_k = \psi, layer kk is affine, and every node of layer kk is ψ(pv)\psi(p_v). So the target face mesh is the image of the source mesh under ψ\psi.
  3. Let layers kk and k+1k + 1 be affine. Every hex of slab kk is H=Fk∘(P×id)H = F_k \circ (P \times \mathrm{id}), where PP is the bilinear map of its source quad, and det⁡DH(u,v,w)=det⁡DFk(P(u,v),w) det⁡DP(u,v)\det DH(u, v, w) = \det DF_k(P(u, v), w)\,\det DP(u, v).
  4. If every layer is affine and det⁡DFk>0\det DF_k > 0 on S×[0,1]S \times [0, 1] for every kk, then every hex has det⁡J>0\det J > 0 at every point of the closed unit cube. If also each FkF_k is one to one on S×[0,1]S \times [0, 1], and the slabs meet only in their common layers, then the hexes have pairwise disjoint interiors, two hexes that touch share a whole face, an edge or a vertex, and the union of the hexes is the swept solid.
  5. CERTIFY returns true exactly when every layer is affine and det⁡DFk(p,w)>0\det DF_k(p, w) > 0 for every loop vertex pp and every w∈[0,1]w \in [0, 1]. In that case det⁡DFk>0\det DF_k > 0 on S×[0,1]S \times [0, 1].
  6. If the layers are planar, with φk(p)=(Akp+ck,zk)\varphi_k(p) = (A_k p + c_k, z_k) and z0<z1<⋯<zKz_0 < z_1 < \cdots < z_K, and CERTIFY returns true, then every FkF_k is one to one, so part 4 gives a valid hex mesh.

Proof of part 1. The loops of L1, L3, L6 and L7 are finite, so SWEEP stops after O(Kn)O(Kn) steps. L4 copies Bk[v]B_k[v] for a loop vertex.

Proof of part 2. The least squares problem for one coordinate has the normal matrix N=∑iqiqiTN = \sum_i q_i q_i^{\mathsf T} with qi=(xi,yi,1)q_i = (x_i, y_i, 1). For a vector zz, zTNz=∑i(qi⋅z)2z^{\mathsf T} N z = \sum_i (q_i \cdot z)^2. This is zero only if all qiq_i are orthogonal to zz. The points are not on one line, so three of the qiq_i are linearly independent, and z=0z = 0. So NN is positive definite and the minimizer is unique. If the targets are ψ(pℓi)\psi(p_{\ell_i}), the map ψ\psi gives the residual 00, which is the minimum, so φk=ψ\varphi_k = \psi. L4 then gives ψ(pv)\psi(p_v) for the inner vertices, and the loop vertices are ψ(pv)\psi(p_v) by hypothesis.

Proof of part 3. Let the source quad have the corners pa,pb,pc,pdp_a, p_b, p_c, p_d and the bilinear map P(u,v)=(1−u)(1−v)pa+u(1−v)pb+uv pc+(1−u)v pdP(u, v) = (1 - u)(1 - v) p_a + u (1 - v) p_b + u v\, p_c + (1 - u) v\, p_d. On an affine layer, the hex corners are φk(pa),…\varphi_k(p_a), \ldots and φk+1(pa),…\varphi_{k+1}(p_a), \ldots. An affine map commutes with an affine combination, and the bilinear weights add up to 11. So

H(u,v,w)=(1−w) φk(P(u,v))+w φk+1(P(u,v))=Fk(P(u,v),w).H(u, v, w) = (1 - w)\,\varphi_k(P(u, v)) + w\,\varphi_{k+1}(P(u, v)) = F_k(P(u, v), w).

The chain rule gives DH=DFk⋅GDH = DF_k \cdot G with the 3×33 \times 3 block matrix G=(DP001)G = \begin{pmatrix} DP & 0 \\ 0 & 1 \end{pmatrix}, and det⁡G=det⁡DP\det G = \det DP.

Lemma A (a convex quad has det⁡DP>0\det DP > 0). Write P(u,v)=pa+u e+v f+uv gP(u, v) = p_a + u\,e + v\,f + u v\,g with e=pb−pae = p_b - p_a, f=pd−paf = p_d - p_a and g=pa−pb+pc−pdg = p_a - p_b + p_c - p_d. Then DPDP has the columns e+vge + v g and f+ugf + u g, and with s×t=sxty−sytxs \times t = s_x t_y - s_y t_x,

det⁡DP(u,v)=e×f+u (e×g)+v (g×f).\det DP(u, v) = e \times f + u\,(e \times g) + v\,(g \times f).

The term in uvuv is g×g=0g \times g = 0, so det⁡DP\det DP is affine in (u,v)(u, v). At the four corners of the unit square it is the cross product of the two edges at the corresponding quad corner. For a strictly convex counterclockwise quad these four values are positive. An affine function on the square takes its minimum at a corner, so det⁡DP>0\det DP > 0 on the closed square.

Lemma B (the slab determinant). Write Lk=[ lk,1 lk,2 ]L_k = [\,l_{k,1}\ l_{k,2}\,] and d(p)=φk+1(p)−φk(p)d(p) = \varphi_{k+1}(p) - \varphi_k(p). The columns of DFkDF_k are (1−w)lk,1+w lk+1,1(1 - w) l_{k,1} + w\, l_{k+1,1}, (1−w)lk,2+w lk+1,2(1 - w) l_{k,2} + w\, l_{k+1,2} and d(p)d(p). The determinant is linear in each column, so

det⁡DFk(p,w)=b0(1−w)2+2b1w(1−w)+b2w2,\det DF_k(p, w) = b_0 (1 - w)^2 + 2 b_1 w (1 - w) + b_2 w^2,
b0=det⁡[lk,1,lk,2,d],b2=det⁡[lk+1,1,lk+1,2,d],2b1=det⁡[lk,1,lk+1,2,d]+det⁡[lk+1,1,lk,2,d].b_0 = \det[l_{k,1}, l_{k,2}, d], \quad b_2 = \det[l_{k+1,1}, l_{k+1,2}, d], \quad 2 b_1 = \det[l_{k,1}, l_{k+1,2}, d] + \det[l_{k+1,1}, l_{k,2}, d].

Each bib_i is linear in d(p)d(p), and dd is affine in pp. So for a fixed ww, the function p↦det⁡DFk(p,w)p \mapsto \det DF_k(p, w) is affine in pp.

Lemma C (a positive quadratic). The function q(w)=b0(1−w)2+2b1w(1−w)+b2w2q(w) = b_0 (1 - w)^2 + 2 b_1 w (1 - w) + b_2 w^2 is positive on [0,1][0, 1] exactly when b0>0b_0 > 0, b2>0b_2 > 0, and b1≥0b_1 \ge 0 or b12<b0b2b_1^2 < b_0 b_2. Proof: q(0)=b0q(0) = b_0 and q(1)=b2q(1) = b_2, so the first two conditions are necessary. If b1≥0b_1 \ge 0, every term is at least 00, and (1−w)2(1 - w)^2 and w2w^2 are never both 00, so q>0q > 0. Let b1<0b_1 < 0. For 0<w<10 < w < 1, put t=w/(1−w)t = w / (1 - w), which takes every value in (0,∞)(0, \infty). Then q(w)/(1−w)2=b0+2b1t+b2t2q(w) / (1 - w)^2 = b_0 + 2 b_1 t + b_2 t^2. Its minimum over t>0t > 0 is at t∗=−b1/b2>0t^* = -b_1 / b_2 > 0 and has the value b0−b12/b2b_0 - b_1^2 / b_2. This is positive exactly when b12<b0b2b_1^2 < b_0 b_2.

Proof of part 4. By Lemma A, det⁡DP>0\det DP > 0 on the closed square, and PP maps it into SS. So by part 3, det⁡DH>0\det DH > 0 on the closed cube. Now let each FkF_k be one to one. Two hexes of the same slab are the images under FkF_k of the two sets Q×[0,1]Q \times [0, 1] and Q′×[0,1]Q' \times [0, 1] for source quads QQ and Q′Q'. The source mesh is conforming, so these sets have disjoint interiors and meet in a common edge times [0,1][0, 1], in a vertex times [0,1][0, 1], or not at all. A one to one map keeps these relations. Hexes of different slabs meet only in the common layer, where the top face of hex (k,Q)(k, Q) is the bottom face of hex (k+1,Q)(k + 1, Q), because both use the nodes xk+1,vx_{k+1, v}. The union of the sets Q×[0,1]Q \times [0, 1] is S×[0,1]S \times [0, 1], so the union of the hexes is the swept solid.

Proof of part 5. CERTIFY first compares every node with φk(pv)\varphi_k(p_v), which is the definition of an affine layer. Then for each slab and each loop vertex it applies the test of Lemma C to the coefficients of Lemma B. With int or Fraction input both tests are exact. So CERTIFY returns true exactly under the stated conditions. Now let them hold and take p∈Sp \in S. The polygon SS is in the convex hull of its loop vertices, so p=∑iλipℓip = \sum_i \lambda_i p_{\ell_i} with λi≥0\lambda_i \ge 0 and ∑iλi=1\sum_i \lambda_i = 1. By Lemma B, det⁡DFk(p,w)=∑iλidet⁡DFk(pℓi,w)>0\det DF_k(p, w) = \sum_i \lambda_i \det DF_k(p_{\ell_i}, w) > 0.

Proof of part 6. For planar layers, d(p)=((Ak+1−Ak)p+ck+1−ck, zk+1−zk)d(p) = ((A_{k+1} - A_k) p + c_{k+1} - c_k,\ z_{k+1} - z_k), and the first two columns of DFkDF_k have the third entry 00. Expansion along the third row gives det⁡DFk=(zk+1−zk)det⁡A(w)\det DF_k = (z_{k+1} - z_k) \det A(w) with A(w)=(1−w)Ak+wAk+1A(w) = (1 - w) A_k + w A_{k+1}. So det⁡A(w)>0\det A(w) > 0 for every ww in [0,1][0, 1]. Take two points (p,w)(p, w) and (p′,w′)(p', w') with the same image. The third coordinate (1−w)zk+wzk+1(1 - w) z_k + w z_{k+1} is strictly increasing in ww, so w=w′w = w'. The first two coordinates are A(w)p+c(w)A(w) p + c(w), and A(w)A(w) is invertible, so p=p′p = p'. The slab kk has the heights [zk,zk+1][z_k, z_{k+1}], so two slabs meet only in a common layer.

Remark (positive corners are not enough). Take the 2×22 \times 2 grid on [0,2]2[0, 2]^2, the layer 00 equal to the source at z=0z = 0, and the layer 11 equal to the source turned by 180180 degrees about (1,1)(1, 1) at z=1z = 1. Every hex has the corner Jacobians 1,…,11, \ldots, 1. Lemma B gives the coefficients (1,−1,1)(1, -1, 1), so det⁡DF0=(1−2w)2\det DF_0 = (1 - 2w)^2 and it is 00 at w=1/2w = 1/2. All four hexes pass through the point (1,1,1/2)(1, 1, 1/2), and CERTIFY returns false. So the hypothesis of part 4 is needed, and a corner test can not replace it. ■\blacksquare

Complexity

L2 builds and solves a 3×33 \times 3 system in O(m)O(m) time for a loop of mm vertices. L3 and L4 take O(n)O(n) per layer. A planar quad mesh has fewer quads than vertices, so L5 to L8 take O(Kn)O(Kn), and L9 takes constant time per hex. The total time and space are O(Kn)O(Kn). CERTIFY also takes O(Kn)O(Kn). Sweeping has no iteration, so it is one of the cheapest ways to make a large hex mesh.

Properties

  • Structured in the sweep direction. Every inner vertex has degree 6 away from the source and target faces, and the mesh is a stack of copies of the source mesh.
  • Fixed count. The mesh has exactly KQKQ hexes, set by the source mesh and the number of layers.
  • Exact on the linking sides. The loop nodes are the given ones.
  • Exact for affine layers. If every loop is an affine image of the source loop, every layer is that image.
  • Twist per slab. For layers that are turns by an angle θ\theta about one axis, the coefficients are (1,cos⁡θ,1)(1, \cos\theta, 1), so each slab can turn by any angle below 180180 degrees and the hexes stay valid.
  • No general guarantee. For curved or warped sides, the inner nodes can leave the solid or fold, and the corner check can miss an inverted hex.

Variants and improvements

  • Other node placement. In place of one affine map per layer, the inner nodes can come from a blend of the maps from the source and from the target, as in BMSweep, from weighted residuals, or from a transfinite interpolation of the linking sides. These follow curved sides better but have no validity proof.
  • Projection to the target. The target face is often curved. The inner nodes of the last layer are then projected onto it, and the quads of the target mesh are checked.
  • Many-to-one sweep. Several source faces sweep to one target face. Their meshes must be merged in the layer where they meet, and the volume is first split into parts with one source each (CCSweep).
  • Multi-axis sweeps. The volume is split into parts that sweep in different directions, and their interface meshes are matched.
  • Smoothing and untangling. A last pass of mesh untangling or optimization based smoothing repairs the few hexes that fail the check.

When to use it

Use sweeping for extruded, revolved and other two-and-a-half dimensional parts, which are very common in mechanical design. It gives hexes aligned with the sweep direction, which is good for boundary layers and thin walls. Use it inside a decomposition: cut the part into sweepable volumes, by hand or by a method such as medial axis decomposition, and sweep each part. Do not use it for a solid with no sweep direction. For such a solid, use polycube or frame field methods, or accept a mixed mesh.

Pitfalls

  • Corner checks are not proofs. The half turn of the example has eight positive corner Jacobians and a zero Jacobian inside. Test each slab with a certificate such as CERTIFY or with the Bernstein coefficients of the hex.
  • Source and target meshes that do not match. A one-to-one sweep needs the same quad mesh on the source and the target, up to the map. If the target face is already meshed by a neighbour volume, the two meshes must agree, or the sweep fails.
  • Linking sides with a different layer count. Every linking side must have the same number of layers, so the interval counts of the sides must be matched before sweeping.
  • Floating point fits. The least squares fit and the sign tests round. Near a degenerate slab, use exact arithmetic, as the implementation does, or a tolerance.
  • Concave source quads. The proof needs strictly convex quads. A concave quad already has a negative det⁡DP\det DP, and no sweep can repair it.

Implementations

Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.

hexahedral_sweeping.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/hexahedral-sweeping/. The authors are listed in prov/AETFHW.jsonl.

"""One-to-one sweeping of a planar quad mesh into layers of hexahedra.

The source face is a planar quad mesh: points pts[v] = (x, y) and quads
(a, b, c, d) listed counterclockwise. The boundary loop of the source face
is a list of vertex indices. The linking sides are already meshed, so the
positions of the loop vertices on each layer k = 0..K are given as 3D points.
Each layer places its interior vertices by the least squares affine map from
the source plane that best fits the loop of that layer, as in the affine
sweep of Knupp. Every hex joins a quad of layer k to the same quad of layer
k + 1. With int or Fraction input every value and every sign is exact.
"""

from fractions import Fraction
from typing import Dict, List, Sequence, Tuple

from mg4geom import corners_positive, det3, solve

Point2 = Tuple
Point3 = Tuple
Affine = Tuple[List[List], List]  # (L as 3 rows of 2 entries, t as 3 entries)


def fit_affine(pts: Sequence[Point2], loop: Sequence[int], targets: Sequence[Point3]) -> Affine:
    """The least squares affine map p -> L p + t from the plane to space with L p_v + t ~ targets[i].

    Precondition: the loop points pts[loop[i]] are not all on one line, so the
    normal equations are regular. Cost: O(n) for n loop points, all exact.
    """
    sxx = sxy = syy = sx = sy = Fraction(0)
    n = len(loop)
    for v in loop:
        x, y = pts[v]
        sxx += x * x
        sxy += x * y
        syy += y * y
        sx += x
        sy += y
    normal = [[sxx, sxy, sx], [sxy, syy, sy], [sx, sy, n]]
    lin, tr = [], []
    for c in range(3):
        rhs = [Fraction(0)] * 3
        for v, q in zip(loop, targets):
            x, y = pts[v]
            rhs[0] += x * q[c]
            rhs[1] += y * q[c]
            rhs[2] += q[c]
        a, b, t = solve(normal, rhs)
        lin.append([a, b])
        tr.append(t)
    return lin, tr


def apply_affine(m: Affine, p: Point2) -> Point3:
    """L p + t."""
    lin, tr = m
    return tuple(lin[c][0] * p[0] + lin[c][1] * p[1] + tr[c] for c in range(3))


def sweep(
    pts: Sequence[Point2],
    quads: Sequence[Tuple[int, int, int, int]],
    loop: Sequence[int],
    layers: Sequence[Sequence[Point3]],
):
    """Sweep the source mesh through the K + 1 given loop layers.

    layers[k][i] is the position of loop vertex loop[i] on layer k. Returns
    (nodes, hexes, maps, ok): nodes[k][v] is the position of vertex v on layer
    k, hexes is the list of K * len(quads) hexes in the standard vertex order,
    maps[k] is the fitted affine map of layer k, and ok tells whether every hex
    has 8 positive corner Jacobians.
    Precondition: K >= 1 and the loop is not collinear.
    Cost: O(K n) time and space for n source vertices and quads.
    """
    on_loop = {v: i for i, v in enumerate(loop)}
    nodes: List[List[Point3]] = []
    maps: List[Affine] = []
    for k in range(len(layers)):  # @line L1
        m = fit_affine(pts, loop, layers[k])  # @line L2
        maps.append(m)
        row = []
        for v in range(len(pts)):  # @line L3
            row.append(tuple(layers[k][on_loop[v]]) if v in on_loop else apply_affine(m, pts[v]))  # @line L4
        nodes.append(row)
    hexes = []  # @line L5
    for k in range(len(layers) - 1):  # @line L6
        for a, b, c, d in quads:  # @line L7
            lo, hi = nodes[k], nodes[k + 1]
            hexes.append([lo[a], lo[b], lo[c], lo[d], hi[a], hi[b], hi[c], hi[d]])  # @line L8
    ok = all(corners_positive(h) for h in hexes)  # @line L9
    return nodes, hexes, maps, ok  # @line L10


def slab_coefficients(m0: Affine, m1: Affine, p: Point2):
    """The Bernstein coefficients (b0, b1, b2) in w of det DF at the source point p.

    F(p, w) = (1 - w)(L0 p + t0) + w (L1 p + t1) is the slab map between two
    affine layers. Its Jacobian has the columns (1 - w) L0 + w L1 (two columns)
    and d(p) = (L1 - L0) p + t1 - t0, so det DF is a quadratic in w.
    """
    (l0, _), (l1, _) = m0, m1
    d = tuple(a - b for a, b in zip(apply_affine(m1, p), apply_affine(m0, p)))
    a1 = tuple(l0[c][0] for c in range(3))
    a2 = tuple(l0[c][1] for c in range(3))
    c1 = tuple(l1[c][0] for c in range(3))
    c2 = tuple(l1[c][1] for c in range(3))
    b0 = det3(a1, a2, d)
    b2 = det3(c1, c2, d)
    b1 = (det3(a1, c2, d) + det3(c1, a2, d)) / Fraction(2)
    return b0, b1, b2


def quadratic_positive(b0, b1, b2) -> bool:
    """Exact test that b0 (1 - w)^2 + 2 b1 w (1 - w) + b2 w^2 > 0 for all w in [0, 1]."""
    return b0 > 0 and b2 > 0 and (b1 >= 0 or b1 * b1 < b0 * b2)


def certify(pts: Sequence[Point2], loop: Sequence[int], nodes, maps) -> bool:
    """Prove that every hex is valid at every point, not only at its corners.

    Returns True when (1) every layer is exactly the affine image of the source
    plane, so each hex is the image of a source quad times [0, 1] under the slab
    map, and (2) det DF > 0 on the convex hull of the loop times [0, 1] for each
    slab. det DF is affine in p, so it is enough to test the loop vertices.
    The source quads must be strictly convex for the conclusion; see the proof.
    Cost: O(K n).
    """
    for k, m in enumerate(maps):  # @line L11
        if any(nodes[k][v] != apply_affine(m, pts[v]) for v in range(len(pts))):  # @line L12
            return False
    for k in range(len(maps) - 1):  # @line L13
        for v in loop:  # @line L14
            b0, b1, b2 = slab_coefficients(maps[k], maps[k + 1], pts[v])  # @line L15
            if not quadratic_positive(b0, b1, b2):  # @line L16
                return False
    return True  # @line L17


def grid_mesh(xs: Sequence, ys: Sequence):
    """A structured quad mesh of the rectangle with the given breakpoints, and its boundary loop.

    Returns (pts, quads, loop); vertex (i, j) has the index i * len(ys) + j, quads are
    counterclockwise, and the loop runs counterclockwise from (xs[0], ys[0]).
    """
    nx, ny = len(xs), len(ys)
    pts = [(Fraction(x), Fraction(y)) for x in xs for y in ys]
    idx = lambda i, j: i * ny + j
    quads = [(idx(i, j), idx(i + 1, j), idx(i + 1, j + 1), idx(i, j + 1)) for i in range(nx - 1) for j in range(ny - 1)]
    loop = [idx(i, 0) for i in range(nx)] + [idx(nx - 1, j) for j in range(1, ny)]
    loop += [idx(i, ny - 1) for i in range(nx - 2, -1, -1)] + [idx(0, j) for j in range(ny - 2, 0, -1)]
    return pts, quads, loop


def planar_layer(pts: Sequence[Point2], loop: Sequence[int], a: Sequence[Sequence], t: Sequence, z) -> List[Point3]:
    """The loop of a planar layer: (A p + t, z) for each loop vertex p."""
    out = []
    for v in loop:
        x, y = pts[v]
        out.append((a[0][0] * x + a[0][1] * y + t[0], a[1][0] * x + a[1][1] * y + t[1], Fraction(z)))
    return out
mg4geom.py 143 lines
# SPDX-License-Identifier: MIT
# Shared helper of the mg4 cad pages of https://algorithm.tamnd.com/. The authors are listed in prov/.

"""Exact geometry of trilinear hexahedra, shared by the mg4 pages.

A hex is a list of 8 points in the standard order: the bottom face
0, 1, 2, 3 counterclockwise seen from above, then the top face 4, 5, 6, 7
above 0, 1, 2, 3. Vertex k is the image of the reference corner
REF[k] of the unit cube, and the hex is the trilinear map of the cube with
these corner images. With int or Fraction coordinates every value here is
exact, so every sign is decided exactly.
"""

from fractions import Fraction
from typing import List, Sequence, Tuple

Point = Tuple
Hex = Sequence[Point]

REF = [(0, 0, 0), (1, 0, 0), (1, 1, 0), (0, 1, 0), (0, 0, 1), (1, 0, 1), (1, 1, 1), (0, 1, 1)]

# For corner k, three neighbours whose edge vectors form a right-handed frame on the unit cube.
CORNER_NEIGHBOURS = [(1, 3, 4), (2, 0, 5), (3, 1, 6), (0, 2, 7), (7, 5, 0), (4, 6, 1), (5, 7, 2), (6, 4, 3)]

# The six faces, each listed counterclockwise seen from outside the hex.
FACES = [(0, 3, 2, 1), (4, 5, 6, 7), (0, 1, 5, 4), (1, 2, 6, 5), (2, 3, 7, 6), (3, 0, 4, 7)]

# The twelve edges in three classes of four parallel edges (directions u, v, w).
EDGE_CLASSES = [
    [(0, 1), (3, 2), (4, 5), (7, 6)],
    [(0, 3), (1, 2), (4, 7), (5, 6)],
    [(0, 4), (1, 5), (2, 6), (3, 7)],
]


def sub(p: Point, q: Point) -> Point:
    """p - q, componentwise."""
    return tuple(a - b for a, b in zip(p, q))


def det3(a: Point, b: Point, c: Point):
    """The determinant of the 3 x 3 matrix with columns a, b, c."""
    return (
        a[0] * (b[1] * c[2] - b[2] * c[1])
        - b[0] * (a[1] * c[2] - a[2] * c[1])
        + c[0] * (a[1] * b[2] - a[2] * b[1])
    )


def corner_jacobians(h: Hex) -> List:
    """The 8 corner Jacobian determinants det(e1, e2, e3) of a hex. Cost: O(1)."""
    out = []
    for k, (i, j, l) in enumerate(CORNER_NEIGHBOURS):
        out.append(det3(sub(h[i], h[k]), sub(h[j], h[k]), sub(h[l], h[k])))
    return out


def corners_positive(h: Hex) -> bool:
    """True when all 8 corner Jacobians are positive (necessary for validity, not sufficient)."""
    return all(d > 0 for d in corner_jacobians(h))


def trilinear(h: Hex, u, v, w) -> Point:
    """The point of the trilinear hex at the reference point (u, v, w)."""
    out = [0, 0, 0]
    for k, (a, b, c) in enumerate(REF):
        wt = (u if a else 1 - u) * (v if b else 1 - v) * (w if c else 1 - w)
        for t in range(3):
            out[t] += wt * h[k][t]
    return tuple(out)


def jacobian_det(h: Hex, u, v, w):
    """det of the Jacobian matrix of the trilinear hex at (u, v, w), exact for exact input."""
    du, dv, dw = [0, 0, 0], [0, 0, 0], [0, 0, 0]
    for k, (a, b, c) in enumerate(REF):
        fu, fv, fw = (u if a else 1 - u), (v if b else 1 - v), (w if c else 1 - w)
        su, sv, sw = (1 if a else -1), (1 if b else -1), (1 if c else -1)
        for t in range(3):
            du[t] += su * fv * fw * h[k][t]
            dv[t] += fu * sv * fw * h[k][t]
            dw[t] += fu * fv * sw * h[k][t]
    return det3(du, dv, dw)


def _to_bernstein2(f0, fh, f1):
    """Bernstein coefficients of the quadratic with values f0, fh, f1 at 0, 1/2, 1."""
    return (f0, 2 * fh - (f0 + f1) / Fraction(2), f1)


def jacobian_bernstein(h: Hex) -> List:
    """The 27 Bernstein coefficients of det J, which has degree 2 in each of u, v, w.

    The determinant is sampled at {0, 1/2, 1}^3 and converted direction by direction.
    Index order: coefficient (i, j, k) is at position 9 i + 3 j + k. Cost: O(1).
    """
    half = Fraction(1, 2)
    ts = (0, half, 1)
    vals = [[[jacobian_det(h, ts[i], ts[j], ts[k]) for k in range(3)] for j in range(3)] for i in range(3)]
    for i in range(3):
        for j in range(3):
            vals[i][j] = list(_to_bernstein2(*vals[i][j]))
    for i in range(3):
        for k in range(3):
            col = _to_bernstein2(vals[i][0][k], vals[i][1][k], vals[i][2][k])
            for j in range(3):
                vals[i][j][k] = col[j]
    for j in range(3):
        for k in range(3):
            col = _to_bernstein2(vals[0][j][k], vals[1][j][k], vals[2][j][k])
            for i in range(3):
                vals[i][j][k] = col[i]
    return [vals[i][j][k] for i in range(3) for j in range(3) for k in range(3)]


def bernstein_certified(h: Hex) -> bool:
    """True when every Bernstein coefficient of det J is positive, which proves det J > 0 on the whole hex."""
    return all(c > 0 for c in jacobian_bernstein(h))


def hex_volume(h: Hex):
    """The signed volume of the trilinear hex, the integral of det J over the unit cube.

    Each quadratic Bernstein polynomial integrates to 1/3 on [0, 1], so the integral is
    the mean of the 27 coefficients. Exact for exact input.
    """
    return sum(jacobian_bernstein(h)) / Fraction(27)


def solve(a: List[List], b: List) -> List:
    """Solve a x = b by Gaussian elimination with Fraction. Raises ValueError if singular."""
    n = len(a)
    m = [[Fraction(x) for x in row] + [Fraction(y)] for row, y in zip(a, b)]
    for c in range(n):
        p = next((r for r in range(c, n) if m[r][c] != 0), None)
        if p is None:
            raise ValueError("singular system")
        m[c], m[p] = m[p], m[c]
        for r in range(n):
            if r != c and m[r][c] != 0:
                f = m[r][c] / m[c][c]
                m[r] = [x - f * y for x, y in zip(m[r], m[c])]
    return [m[r][n] / m[r][r] for r in range(n)]
test_hexahedral_sweeping.py 182 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/hexahedral-sweeping/. The authors are listed in prov/AETFHW.jsonl.

import random
from fractions import Fraction as F

import pytest

from hexahedral_sweeping import certify, grid_mesh, planar_layer, slab_coefficients, sweep
from mg4geom import (
    FACES,
    REF,
    corner_jacobians,
    det3,
    hex_volume,
    jacobian_bernstein,
    jacobian_det,
    sub,
    trilinear,
)

CENTER = (1, 1)


def about(pts, loop, a, z, c=CENTER):
    t = (c[0] - a[0][0] * c[0] - a[0][1] * c[1], c[1] - a[1][0] * c[0] - a[1][1] * c[1])
    return planar_layer(pts, loop, a, t, z)


def page_example():
    pts, quads, loop = grid_mesh([0, 1, 2], [0, 1, 2])
    a0 = [[1, 0], [0, 1]]
    a1 = [[F(1), F(-1, 2)], [F(1, 2), F(1)]]
    a2 = [[0, -1], [1, 0]]
    layers = [about(pts, loop, a0, 0), about(pts, loop, a1, 1), about(pts, loop, a2, 2)]
    return pts, quads, loop, layers


def test_reference_tables():
    cube = [tuple(F(c) for c in p) for p in REF]
    assert corner_jacobians(cube) == [1] * 8
    assert hex_volume(cube) == 1
    assert all(c == 1 for c in jacobian_bernstein(cube))
    for f in FACES:
        p = [cube[i] for i in f]
        n = det3(sub(p[1], p[0]), sub(p[3], p[0]), sub(p[0], (F(1, 2), F(1, 2), F(1, 2))))
        assert n > 0  # each face is counterclockwise seen from outside


def test_page_example():
    pts, quads, loop, layers = page_example()
    nodes, hexes, maps, ok = sweep(pts, quads, loop, layers)
    assert ok and certify(pts, loop, nodes, maps)
    assert len(hexes) == 8
    assert nodes[1][4] == (1, 1, 1) and nodes[1][0] == (F(1, 2), F(-1, 2), 1)
    for h in hexes[:4]:
        assert corner_jacobians(h) == [1, 1, 1, 1, F(5, 4), F(5, 4), F(5, 4), F(5, 4)]
        assert hex_volume(h) == F(13, 12)
    for h in hexes[4:]:
        assert corner_jacobians(h) == [F(5, 4)] * 4 + [1] * 4
        assert hex_volume(h) == F(11, 12)
    assert sum(hex_volume(h) for h in hexes) == 8
    assert slab_coefficients(maps[0], maps[1], pts[0]) == (1, 1, F(5, 4))
    assert slab_coefficients(maps[1], maps[2], pts[0]) == (F(5, 4), F(1, 2), 1)
    # the target face mesh is the source mesh turned by 90 degrees about (1, 1)
    for v, (x, y) in enumerate(pts):
        assert nodes[2][v] == (2 - y, x, 2)


def test_half_turn_has_positive_corners_but_is_not_valid():
    pts, quads, loop = grid_mesh([0, 1, 2], [0, 1, 2])
    layers = [about(pts, loop, [[1, 0], [0, 1]], 0), about(pts, loop, [[-1, 0], [0, -1]], 1)]
    nodes, hexes, maps, ok = sweep(pts, quads, loop, layers)
    assert ok  # all 8 corner Jacobians are positive
    assert not certify(pts, loop, nodes, maps)
    half = F(1, 2)
    for h in hexes:
        assert corner_jacobians(h) == [1] * 8
        assert jacobian_det(h, half, half, half) == 0
        assert trilinear(h, half, half, half) == (1, 1, half)  # every hex passes through the axis point
        assert hex_volume(h) == F(1, 3)


def test_stretched_half_turn_is_inverted_inside():
    pts, quads, loop = grid_mesh([0, 1, 2], [0, 1, 2])
    layers = [about(pts, loop, [[1, 0], [0, 1]], 0), about(pts, loop, [[-1, 0], [0, -2]], 1)]
    nodes, hexes, maps, ok = sweep(pts, quads, loop, layers)
    assert ok and not certify(pts, loop, nodes, maps)
    w = F(2, 5)  # det((1 - w) I + w diag(-1, -2)) = (1 - 2w)(1 - 3w) < 0
    assert all(jacobian_det(h, F(1, 2), F(1, 2), w) < 0 for h in hexes)


def test_boundary_nodes_are_kept_and_corner_check_is_exact():
    pts, quads, loop = grid_mesh([0, 1, 3], [0, 2, 3])
    l0 = about(pts, loop, [[1, 0], [0, 1]], 0)
    l1 = [(x + (F(1, 3) if i == 2 else 0), y, z) for i, (x, y, z) in enumerate(about(pts, loop, [[1, 0], [0, 1]], 1))]
    nodes, hexes, maps, ok = sweep(pts, quads, loop, [l0, l1])
    for i, v in enumerate(loop):
        assert nodes[1][v] == l1[i]
    assert ok == all(d > 0 for h in hexes for d in corner_jacobians(h))
    assert not certify(pts, loop, nodes, maps)  # layer 1 is not an affine image


def test_rejects_collinear_loop():
    pts = [(F(0), F(0)), (F(1), F(0)), (F(2), F(0))]
    with pytest.raises(ValueError):
        sweep(pts, [], [0, 1, 2], [[(0, 0, 0)] * 3, [(0, 0, 1)] * 3])


def random_instance(rng):
    nx, ny = rng.randint(2, 4), rng.randint(2, 4)
    xs = sorted(rng.sample(range(0, 9), nx))
    ys = sorted(rng.sample(range(0, 9), ny))
    pts, quads, loop = grid_mesh(xs, ys)
    k = rng.randint(1, 3)
    zs = [0]
    for _ in range(k):
        zs.append(zs[-1] + rng.randint(1, 3))
    mats = [[[1, 0], [0, 1]]]
    for _ in range(k):
        while True:
            a = [[F(rng.randint(-4, 4), 2) for _ in range(2)] for _ in range(2)]
            if a[0][0] * a[1][1] - a[0][1] * a[1][0] > 0:
                break
        mats.append(a)
    ts = [(0, 0)] + [(F(rng.randint(-4, 4), 2), F(rng.randint(-4, 4), 2)) for _ in range(k)]
    layers = [planar_layer(pts, loop, a, t, z) for a, t, z in zip(mats, ts, zs)]
    return pts, quads, loop, mats, ts, zs, layers


def det2(a):
    return a[0][0] * a[1][1] - a[0][1] * a[1][0]


def oracle_slab_positive(a0, a1):
    """min over w in [0, 1] of det((1 - w) A0 + w A1) > 0, by exact minimization of the quadratic."""
    m = lambda w: [[(1 - w) * a0[i][j] + w * a1[i][j] for j in range(2)] for i in range(2)]
    q0, qh, q1 = det2(m(F(0))), det2(m(F(1, 2))), det2(m(F(1)))
    # q(w) = q0 + b w + c w^2 from three samples
    c = 2 * (q0 + q1 - 2 * qh)
    b = q1 - q0 - c
    cands = [F(0), F(1)]
    if c != 0:
        w = -b / (2 * c)
        if 0 < w < 1:
            cands.append(w)
    return min(q0 + b * w + c * w * w for w in cands) > 0


def test_random_sweeps_against_oracles():
    rng = random.Random(20261115)
    certified = 0
    for trial in range(500):
        pts, quads, loop, mats, ts, zs, layers = random_instance(rng)
        nodes, hexes, maps, ok = sweep(pts, quads, loop, layers)
        # every layer is the exact affine image, so the fit is exact and the target mesh matches
        for k, (a, t, z) in enumerate(zip(mats, ts, zs)):
            for v, (x, y) in enumerate(pts):
                assert nodes[k][v] == (a[0][0] * x + a[0][1] * y + t[0], a[1][0] * x + a[1][1] * y + t[1], z)
        assert len(hexes) == (len(zs) - 1) * len(quads)
        assert ok == all(d > 0 for h in hexes for d in corner_jacobians(h))
        # the certificate agrees with an exact minimization of det((1 - w) A_k + w A_k+1)
        expect = all(oracle_slab_positive(mats[k], mats[k + 1]) for k in range(len(mats) - 1))
        cert = certify(pts, loop, nodes, maps)
        assert cert == expect
        if trial % 5 == 0:
            # the hex volumes add up to area times the integral of the slab determinant
            area = (pts[-1][0] - pts[0][0]) * (pts[-1][1] - pts[0][1])
            vol = 0
            for k in range(len(mats) - 1):
                a0, a1 = mats[k], mats[k + 1]
                mid = (a0[0][0] * a1[1][1] - a0[1][0] * a1[0][1] + a1[0][0] * a0[1][1] - a1[1][0] * a0[0][1]) / F(2)
                vol += area * (zs[k + 1] - zs[k]) * (det2(a0) + mid + det2(a1)) / 3
            assert sum(hex_volume(h) for h in hexes) == vol
        if cert:
            certified += 1
            assert ok
            for h in hexes[:3]:
                for _ in range(3):
                    u, v, w = (F(rng.randint(0, 8), 8) for _ in range(3))
                    assert jacobian_det(h, u, v, w) > 0
    assert certified > 100

History

Moving a 2D mesh along a third direction is one of the oldest ways to make hexes, and early structured grid codes extruded blocks in this way. Shih and Sakurai in 1996 proposed to split a solid into swept volumes and to sweep each part. Knupp in 1998 gave an affine method to place the inner nodes of each layer from its boundary loop, and Staten, Canann and Owen in 1999 gave BMSweep, which blends maps from both ends. Miyoshi and Blacker in 2000 swept along several axes, and White, Saigal and Owen in 2004 split many-to-one volumes automatically. The Pietroni et al. survey of 2022 reports that sweeping of a user decomposition is still the main hex method in commercial software.

References

  1. B. Shih and H. Sakurai, Automated hexahedral mesh generation by swept volume decomposition and recomposition, Proceedings of the 5th International Meshing Roundtable, 1996, the split of a solid into swept volumes and the one-to-one sweep of each part (general locator)
  2. Patrick M. Knupp, Next-generation sweep tool, a method for generating all-hex meshes on two-and-a-half dimensional geometries, Proceedings of the 7th International Meshing Roundtable, 1998, 505 to 513, the placement of the inner nodes of each layer by a least squares affine map of the boundary loop (general locator)
  3. Matthew L. Staten, Scott A. Canann and Steven J. Owen, BMSweep, locating interior nodes during sweeping, Engineering with Computers 15, 1999, 212 to 218, the placement of the inner nodes by a blend of boundary maps (general locator)
  4. David R. White, Sunil Saigal and Steven J. Owen, CCSweep, automatic decomposition of multi-sweep volumes, Engineering with Computers 20(3), 2004, 222 to 236, the many-to-one sweep and the split of a volume with several source faces (general locator)

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH1 sketch
  • a full proof of time.worst
  • a full proof of space.extra
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a scene preset for the example