Algorithmcore
Transfinite interpolation grid generation
Also called algebraic grid generation, Gordon-Hall method.
Gordon and Hall's algebraic grid that blends the boundary curves of a block by a Boolean sum of linear interpolants, the basis of mapped meshing.
- Time
- O(M N) worst
- Space
- O(M N) extra
- Where
- M = the number of cells along the first parameter; N = the number of cells along the second parameter
- Model
- Real RAM
- Properties
- deterministicexactiterative
- Evidence
- Proof sketchCode in 1 languages
- Origin
- William J. Gordon, Charles A. Hall, 1973
Transfinite interpolation (TFI) makes a structured grid inside a block with four curved sides. It adds the linear interpolation between the left and right sides to the linear interpolation between the bottom and top sides, and subtracts the bilinear interpolation of the four corners. The grid matches every given boundary point exactly, costs a constant number of operations per point, and has no iteration. It does not guarantee a valid grid: on a strongly curved or concave side the grid lines can cross, so every TFI grid must be checked, and many are then smoothed by elliptic grid generation.
In plain words
Take a region with four sides, like a bent rectangle. Each side has a row of points on it, and opposite sides have the same number of points. We want a net of grid lines inside that joins each point to the matching point on the opposite side.
Draw straight lines from each left point to its right partner, and from each bottom point to its top partner. Each of these two families of lines matches two of the sides but misses the other two. Add the two families and subtract a simple correction made from the four corners, and the result matches all four sides.
The method is fast and direct. It looks only at the sides, so a deep dent in one side can push the inner lines over each other. A good program always checks the grid cells after it builds them.
The problem
This is structured grid generation for one block. The input is four sides given as point lists: the bottom and top , the left and right , with . The sides must meet at four common corners:
The input also gives parameter values and , which are and by default. The output is the grid , , , with , , and . Cell is the quadrilateral . A grid is valid if every cell is a strictly convex counterclockwise quadrilateral.
The algorithm
ORIENT2D is the orientation test. CHECK uses it to test the corner Jacobians of each cell, as on the scaled Jacobian page.
TFI(B, T, L, R, u, v)- 1
if B_0 ≠ L_0 or B_M ≠ R_0 or T_0 ≠ L_N or T_M ≠ R_N then error - 2
P00 ← B_0; P10 ← B_M; P01 ← T_0; P11 ← T_M - 3
for i ← 0 to M do - 4
for j ← 0 to N do - 5
U ← (1 − u_i) L_j + u_i R_j ▷ matches left and right - 6
V ← (1 − v_j) B_i + v_j T_i ▷ matches bottom and top - 7
C ← (1 − v_j)((1 − u_i) P00 + u_i P10) + v_j((1 − u_i) P01 + u_i P11) - 8
x_ij ← U + V − C - 9
return x CHECK(x)- 10
for each cell with corners q_0 = x_ij, q_1 = x_{i+1,j}, q_2 = x_{i+1,j+1}, q_3 = x_{i,j+1} do - 11
if ORIENT2D(q_{k−1}, q_k, q_{k+1}) ≤ 0 for some k = 0..3 then return false - 12
return true
The grid is the Coons patch of the sides, sampled at the parameters. In the language of projectors, let interpolate linearly between the left and right sides and between the bottom and top sides. Then , , , and TFI is the Boolean sum
Points can have any dimension, so the same code makes a grid on a surface patch in 3D from its four boundary curves. In 3D, a block with six faces uses three projectors and
which reads the six faces, subtracts the linear interpolants of the twelve edges and adds back the trilinear interpolant of the eight corners. It reproduces all six faces by the same argument.
Example
Take a quarter of the annulus between the circles of radii 1 and 2, with . The bottom side is the segment , the top side is , the left side is the inner arc , and the right side is the outer arc . The arc points are exact rational points on the circles.
| step | value at , |
|---|---|
| L5, | |
| L6, | |
| L7, | the average of the four corners, |
| L8, | , which lies on the circle of radius |
The points on the sides come out equal to the input, as the proof says. The four cells have the corner values , , and , all positive, so CHECK returns true.
A grid that folds. Take the unit square, but replace the bottom side by the hook polyline , which goes right, turns back to the left, and then goes down to . The domain is still a simple polygon. Sample the hook at and the straight sides at . Near the hook, the grid line follows the turn back: its points at are , and . Cells and have all four corner values negative, for example , , , , so they are turned over. Cells and have mixed signs, so they are not convex. CHECK returns false. A finer grid does not help, because the continuous TFI map itself folds there.
Correctness
The proof is by substitution. On the bottom side , so is the bottom point and the corner conditions make and the same linear interpolation between and , which cancels. The other three sides are the same. In projector form, , and the projectors commute, so the error vanishes where either factor vanishes, which is the whole boundary. The same identity shows that data from a bilinear map are reproduced exactly, so a parallelogram or any convex quadrilateral with evenly spaced straight sides gives its bilinear grid. With int or Fraction input every value is exact. The full proof is below.
The algorithm only interpolates. Its output is valid exactly when CHECK returns true, and the example above shows that this can fail for a simple domain.
Proof: Transfinite interpolation reproduces the four boundary sides exactly and reproduces bilinear datafull
Claim. Let , , and be points of with and with common corners
and let and . Let be the output of TFI. Then:
- , , and for all and ;
- if there is a map with such that the side points are , , and , then for all ;
- with int or Fraction input, the computed values are exactly these values, and CHECK returns true exactly when every cell has four positive corner Jacobians.
TFI stops after iterations of its inner loop, and CHECK after orientation tests.
Notation. Lines L5 to L8 compute
Step 1 (the bottom side). Take , so . Then , by the corner conditions, and . So and .
Step 2 (the top side). Take , so . Then , , and . So .
Step 3 (the left and right sides). Take , so . Then , , and . So . For , gives and , so . This proves part 1. The corner conditions are used in each step: without them, or is not zero on the side, and the side is not reproduced.
Step 4 (the projector form). Part 1 is a case of a general fact about projectors, which also gives part 2. For a function on the unit square, let
Both are linear, and both are idempotent: is linear in with the values and at and , so . They commute, because and are both the bilinear function with the values , , , at the corners. The Boolean sum is
For any with the given values on the boundary of the square, at is , because uses only and , uses only and , and uses only the corners. Now is zero on and for every , and is zero on and . Since the projectors commute, is zero on all four sides, which is part 1 again.
Step 5 (bilinear data). Let . For fixed it is linear in , so . Then , and . The side points of part 2 are the values of on the boundary, so by Step 4, . This proves part 2. The same argument shows that any that is linear in alone, or in alone, is reproduced.
Step 6 (exactness and CHECK). Lines L5 to L8 use only additions, subtractions and multiplications of the input values with , and , . With int or Fraction values, each of these operations is exact, so the computed are the values of Steps 1 to 5 and the equalities of part 1 hold as exact equalities. CHECK computes the four values ORIENT2D for each cell with corners , , , . The value at equals , because ORIENT2D does not change under a cyclic shift of its arguments, and this is the Jacobian determinant of the bilinear map of the cell from the unit square at that corner. For example, at the two vectors are the edge and the reversed edge , and . The values are exact, so CHECK returns true exactly when all values are positive. This proves part 3.
Step 7 (termination). The loops of L3 and L4 run over the finite ranges and , and each iteration does a fixed number of operations on coordinates. The loop of L10 runs over cells with four tests each. So both procedures stop.
What the claim does not say. The claim does not say that the grid is valid. TFI is a linear formula in the boundary data, and nothing in it keeps the interior map one to one. The test file has a hook-shaped side of a simple domain whose TFI grid has four cells that fail CHECK, two of them with all four corner values negative. Validity has to be checked after the grid is made, and an elliptic grid is the usual repair.
Complexity
The inner loop runs times, and each iteration does a constant number of operations per coordinate, so the time is and the space for the grid is . CHECK does orientation tests. In 3D, a block of cells takes time. No linear system is solved, which is why TFI is the usual first grid and the starting point of iterative methods.
Properties
- Exact on the boundary. Every given side point is reproduced, in exact arithmetic exactly.
- Bilinear precision. Data from any map that is linear in each parameter are reproduced.
- Local in the data. A change of one side point that is not a corner changes only the grid line that starts at it. A change of a corner changes the whole grid.
- No validity guarantee. Concave or strongly curved sides can fold the grid.
- Inherits the spacing of the sides. Points clustered on a side stay clustered along the grid lines that leave it, and the clustering fades linearly to the opposite side.
- Explicit and parallel. Each grid point is computed on its own.
Variants and improvements
- Other blending functions. The linear functions and can be replaced by other functions with the same values at 0 and 1, for example the stretching functions that cluster grid lines near a wall. Cubic Hermite blending also uses the derivatives across the sides, which lets the grid lines leave a side at right angles.
- Arc length parameters. If is the normalized arc length of the bottom side and it differs from that of the top side, the parameters can be blended between the two, so that each side keeps its own spacing.
- Three dimensions. The Boolean sum of three projectors fills a block from its six faces, and is the core of mapped hexahedral meshing and of hexahedral mesh generation by blocks.
- Elliptic smoothing. TFI gives the initial grid of elliptic grid generation, which then iterates to a smooth grid. The continuous harmonic map behind that method does not fold on any domain bounded by a Jordan curve, but its discrete grid has no such proof.
When to use it
Use TFI for a block whose sides are close to straight or gently curved, when speed matters, and as the initial grid for an elliptic or optimization method. It is the standard way to fill the blocks of a multiblock grid and to place interior points of high order elements with curved sides. Use an elliptic grid or another smoothing step when the block has concave sides or when smooth spacing is needed, and use an unstructured method such as advancing front mesh generation when the domain does not split into four-sided blocks.
Pitfalls
- Corners that do not match. If two sides meet at different points, the grid does not close. L1 rejects this input; with floats, compare with a tolerance or share the corner objects.
- Unchecked folding. A folded cell has a negative Jacobian and breaks a finite element or finite volume solver. Always run CHECK, with exact orientation signs if the points are close.
- Opposite sides with different spacing. If the bottom points cluster to the left and the top points to the right, the grid lines are strongly skewed, and cells can fail CHECK even in a convex quadrilateral. The tests of elliptic grid generation find this for 5 of 25 convex quadrilaterals with random spacing on the sides.
- Degenerate blocks. A triangle given as a block with one side of zero length has cells of zero area along that side, and CHECK returns false there.
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.
# SPDX-License-Identifier: MIT
# Shared helper of the mg1 cad pages of https://algorithm.tamnd.com/. The authors are listed in prov/.
"""Small exact tools for planar grids and triangulations, used by the mg1 pages.
Points are tuples of int, fractions.Fraction or float. Every predicate here is
exact when the coordinates are int or Fraction. A float coordinate converts to
a Fraction without rounding, so exact() followed by a predicate gives the exact
sign for the float points as they are stored.
"""
from fractions import Fraction
from typing import Iterable, Sequence, Tuple
Point = Tuple
def exact(p: Point) -> Tuple[Fraction, ...]:
"""The point p with each coordinate converted to Fraction, without rounding."""
return tuple(Fraction(c) for c in p)
def orient2d(a: Point, b: Point, c: Point):
"""Twice the signed area of the triangle a, b, c; positive if counterclockwise."""
return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0])
def twice_area(poly: Sequence[Point]):
"""Twice the signed area of a polygon by the shoelace formula."""
n = len(poly)
return sum(poly[i][0] * poly[(i + 1) % n][1] - poly[(i + 1) % n][0] * poly[i][1] for i in range(n))
def quad_corner_values(q: Sequence[Point]) -> list:
"""The four values ORIENT2D(q[k-1], q[k], q[k+1]) of a quadrilateral q[0..3].
They are the Jacobian determinants of the bilinear map of the cell at its
corners. All four are positive exactly when the quadrilateral is strictly
convex and counterclockwise.
"""
return [orient2d(q[k - 1], q[k], q[(k + 1) % 4]) for k in range(4)]
def grid_cells(grid: Sequence[Sequence[Point]]) -> Iterable:
"""Yield ((i, j), corners) for each cell of a grid x[i][j], corners counterclockwise for u right, v up."""
for i in range(len(grid) - 1):
for j in range(len(grid[0]) - 1):
yield (i, j), (grid[i][j], grid[i + 1][j], grid[i + 1][j + 1], grid[i][j + 1])
def in_closed_triangle(p: Point, a: Point, b: Point, c: Point) -> bool:
"""True if p lies in the closed counterclockwise triangle a, b, c."""
return orient2d(a, b, p) >= 0 and orient2d(b, c, p) >= 0 and orient2d(c, a, p) >= 0
def segments_cross(a: Point, b: Point, c: Point, d: Point) -> bool:
"""True if the closed segments ab and cd share a point other than a common endpoint.
Segments that share exactly one endpoint and are not collinear return False.
Cost O(1); exact for int and Fraction.
"""
shared = {a, b} & {c, d}
o1, o2 = orient2d(a, b, c), orient2d(a, b, d)
o3, o4 = orient2d(c, d, a), orient2d(c, d, b)
if o1 == 0 and o2 == 0:
# collinear: overlap in more than a shared endpoint?
k = 0 if a[0] != b[0] else 1
lo1, hi1 = sorted((a[k], b[k]))
lo2, hi2 = sorted((c[k], d[k]))
lo, hi = max(lo1, lo2), min(hi1, hi2)
if lo < hi:
return True
return lo == hi and not shared
if shared:
# two segments that are not collinear meet in at most one point
return False
return o1 * o2 <= 0 and o3 * o4 <= 0
transfinite_interpolation_grid.py 96 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/transfinite-interpolation-grid/. The authors are listed in prov/FNVCY2.jsonl.
"""Transfinite interpolation (Gordon and Hall) of a structured grid.
The four sides of a block are point lists: bottom[i] and top[i] for
i = 0..M, left[j] and right[j] for j = 0..N, with common corners. The grid
point x[i][j] is the Boolean sum of the linear interpolation between left
and right and the linear interpolation between bottom and top. Points may
have any dimension. With int or Fraction input every value is exact, and so
are the signs of the cell test.
"""
from fractions import Fraction
from typing import Dict, List, Optional, Sequence, Tuple
from mg1geom import grid_cells, quad_corner_values
Point = Tuple
Grid = List[List[Point]]
def _lerp(p: Point, q: Point, t) -> Point:
"""(1 - t) p + t q."""
return tuple((1 - t) * a + t * b for a, b in zip(p, q))
def tfi_grid(
bottom: Sequence[Point],
top: Sequence[Point],
left: Sequence[Point],
right: Sequence[Point],
u: Optional[Sequence] = None,
v: Optional[Sequence] = None,
) -> Grid:
"""The grid points x[i][j], 0 <= i <= M, 0 <= j <= N.
Precondition: len(bottom) == len(top) == M + 1 >= 2, len(left) ==
len(right) == N + 1 >= 2, and the corners agree: bottom[0] == left[0],
bottom[M] == right[0], top[0] == left[N], top[M] == right[N]. The
parameters u[0..M] and v[0..N] run from 0 to 1; the default is i / M
and j / N as Fractions.
Cost: O(M N) arithmetic operations and O(M N) space.
"""
m, n = len(bottom) - 1, len(left) - 1
if m < 1 or n < 1 or len(top) != m + 1 or len(right) != n + 1:
raise ValueError("bottom and top need equal lengths, left and right too, each at least 2")
if bottom[0] != left[0] or bottom[m] != right[0] or top[0] != left[n] or top[m] != right[n]: # @line L1
raise ValueError("the four sides do not meet at common corners")
u = [Fraction(i, m) for i in range(m + 1)] if u is None else list(u)
v = [Fraction(j, n) for j in range(n + 1)] if v is None else list(v)
if len(u) != m + 1 or len(v) != n + 1 or u[0] != 0 or u[m] != 1 or v[0] != 0 or v[n] != 1:
raise ValueError("parameters must run from 0 to 1, one per point")
p00, p10, p01, p11 = bottom[0], bottom[m], top[0], top[m] # @line L2
grid: Grid = []
for i in range(m + 1): # @line L3
col: List[Point] = []
for j in range(n + 1): # @line L4
a = _lerp(left[j], right[j], u[i]) # @line L5
b = _lerp(bottom[i], top[i], v[j]) # @line L6
c = _lerp(_lerp(p00, p10, u[i]), _lerp(p01, p11, u[i]), v[j]) # @line L7
col.append(tuple(x + y - z for x, y, z in zip(a, b, c))) # @line L8
grid.append(col)
return grid # @line L9
def cell_corner_values(grid: Grid) -> Dict[Tuple[int, int], list]:
"""For each cell (i, j) of a planar grid, its four corner Jacobians.
The corners of cell (i, j) are x[i][j], x[i+1][j], x[i+1][j+1], x[i][j+1].
The value at corner k is ORIENT2D(q[k-1], q[k], q[k+1]).
Cost: O(M N).
"""
out = {}
for key, q in grid_cells(grid): # @line L10
out[key] = quad_corner_values(q) # @line L11
return out
def is_unfolded(grid: Grid) -> bool:
"""True if every cell of a planar grid has four positive corner values. Cost: O(M N)."""
return all(s > 0 for vals in cell_corner_values(grid).values() for s in vals) # @line L12
def sample_polyline(points: Sequence[Point], ts: Sequence) -> List[Point]:
"""Points at parameters ts in [0, 1] on a polyline whose vertex k has parameter k / (len - 1).
Exact for Fraction input. Used to build the sides of a block from a few vertices.
"""
k = len(points) - 1
out = []
for t in ts:
s = Fraction(t) * k
seg = min(int(s), k - 1)
out.append(_lerp(points[seg], points[seg + 1], s - seg))
return out
test_transfinite_interpolation_grid.py 147 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/transfinite-interpolation-grid/. The authors are listed in prov/FNVCY2.jsonl.
import random
from fractions import Fraction as F
import pytest
from mg1geom import orient2d, twice_area
from transfinite_interpolation_grid import cell_corner_values, is_unfolded, sample_polyline, tfi_grid
def annulus_sides():
"""The block of the page example: a quarter annulus with radii 1 and 2."""
bottom = [(F(1), F(0)), (F(3, 2), F(0)), (F(2), F(0))]
top = [(F(0), F(1)), (F(0), F(3, 2)), (F(0), F(2))]
left = [(F(1), F(0)), (F(3, 5), F(4, 5)), (F(0), F(1))]
right = [(F(2), F(0)), (F(6, 5), F(8, 5)), (F(0), F(2))]
return bottom, top, left, right
def random_sides(rng, m, n, dim=2):
"""Random rational sides with matching corners."""
def pt():
return tuple(F(rng.randint(-50, 50), rng.randint(1, 9)) for _ in range(dim))
p00, p10, p01, p11 = pt(), pt(), pt(), pt()
bottom = [p00] + [pt() for _ in range(m - 1)] + [p10]
top = [p01] + [pt() for _ in range(m - 1)] + [p11]
left = [p00] + [pt() for _ in range(n - 1)] + [p01]
right = [p10] + [pt() for _ in range(n - 1)] + [p11]
return bottom, top, left, right
def random_params(rng, k):
"""0 = t_0 < t_1 < ... < t_k = 1, random rationals."""
inner = sorted(set(F(rng.randint(1, 999), 1000) for _ in range(3 * k)))
while len(inner) < k - 1:
inner = sorted(set(inner) | {F(rng.randint(1, 999), 1000)})
return [F(0)] + sorted(rng.sample(inner, k - 1)) + [F(1)]
def test_example_of_the_page() -> None:
g = tfi_grid(*annulus_sides())
assert g[1][0] == (F(3, 2), F(0))
assert g[1][1] == (F(9, 10), F(6, 5))
assert g[1][1][0] ** 2 + g[1][1][1] ** 2 == F(9, 4)
vals = cell_corner_values(g)
assert vals[(0, 0)] == [F(2, 5), F(3, 5), F(3, 5), F(2, 5)]
assert vals[(1, 1)] == [F(9, 20), F(3, 5), F(3, 5), F(9, 20)]
assert is_unfolded(g)
def test_boundary_reproduction_is_exact() -> None:
rng = random.Random(20261114)
for trial in range(200):
m, n = rng.randint(1, 7), rng.randint(1, 7)
dim = 2 if trial % 2 else 3
bottom, top, left, right = random_sides(rng, m, n, dim)
u = random_params(rng, m) if trial % 3 == 0 else None
v = random_params(rng, n) if trial % 3 == 0 else None
g = tfi_grid(bottom, top, left, right, u, v)
assert [g[i][0] for i in range(m + 1)] == list(bottom)
assert [g[i][n] for i in range(m + 1)] == list(top)
assert g[0] == list(left)
assert g[m] == list(right)
def coons(c0, c1, d0, d1, s, t):
"""The bilinearly blended Coons patch of four curves, written out term by term (an independent oracle)."""
p00, p10, p01, p11 = c0(0), c0(1), c1(0), c1(1)
return tuple(
(1 - t) * c0(s)[k] + t * c1(s)[k] + (1 - s) * d0(t)[k] + s * d1(t)[k]
- ((1 - s) * (1 - t) * p00[k] + s * (1 - t) * p10[k] + (1 - s) * t * p01[k] + s * t * p11[k])
for k in range(2)
)
def test_equals_the_coons_patch_at_the_grid_parameters() -> None:
rng = random.Random(7)
for _ in range(30):
cb = [F(rng.randint(-9, 9), 7) for _ in range(6)]
c0 = lambda s: (s, cb[0] * s * (1 - s))
c1 = lambda s: (s + cb[1] * s * (1 - s), 1 + cb[2] * s * s * (1 - s))
d0 = lambda t: (cb[3] * t * (1 - t), t)
d1 = lambda t: (1 + cb[4] * t * (1 - t) * (1 - 2 * t), t + cb[5] * t * (1 - t))
m, n = rng.randint(1, 6), rng.randint(1, 6)
u, v = random_params(rng, m), random_params(rng, n)
g = tfi_grid([c0(s) for s in u], [c1(s) for s in u], [d0(t) for t in v], [d1(t) for t in v], u, v)
for i in range(m + 1):
for j in range(n + 1):
assert g[i][j] == coons(c0, c1, d0, d1, u[i], v[j])
def test_bilinear_data_are_reproduced() -> None:
rng = random.Random(11)
for _ in range(50):
a, b, c, d = [(F(rng.randint(-20, 20), 3), F(rng.randint(-20, 20), 5)) for _ in range(4)]
def f(s, t):
return tuple(a[k] + b[k] * s + c[k] * t + d[k] * s * t for k in range(2))
m, n = rng.randint(1, 5), rng.randint(1, 5)
u, v = random_params(rng, m), random_params(rng, n)
g = tfi_grid([f(s, 0) for s in u], [f(s, 1) for s in u], [f(0, t) for t in v], [f(1, t) for t in v], u, v)
assert all(g[i][j] == f(u[i], v[j]) for i in range(m + 1) for j in range(n + 1))
def test_convex_quadrilateral_gives_cells_that_tile_it() -> None:
q = [(F(0), F(0)), (F(7), F(1)), (F(6), F(5)), (F(1), F(4))]
m, n = 5, 4
us, vs = [F(i, m) for i in range(m + 1)], [F(j, n) for j in range(n + 1)]
g = tfi_grid(sample_polyline([q[0], q[1]], us), sample_polyline([q[3], q[2]], us),
sample_polyline([q[0], q[3]], vs), sample_polyline([q[1], q[2]], vs))
assert is_unfolded(g)
total = sum(twice_area([g[i][j], g[i + 1][j], g[i + 1][j + 1], g[i][j + 1]]) for i in range(m) for j in range(n))
assert total == twice_area(q)
def test_hook_boundary_folds() -> None:
m, n = 6, 4
us, vs = [F(i, m) for i in range(m + 1)], [F(j, n) for j in range(n + 1)]
hook = [(F(0), F(0)), (F(3, 5), F(1, 5)), (F(2, 5), F(2, 5)), (F(1), F(0))]
bottom = sample_polyline(hook, us)
# the hook is a simple polyline: its first and last pieces do not meet
assert orient2d(hook[2], hook[3], hook[1]) < 0 and orient2d(hook[2], hook[3], hook[0]) < 0
g = tfi_grid(bottom, [(s, F(1)) for s in us], [(F(0), t) for t in vs], [(F(1), t) for t in vs])
vals = cell_corner_values(g)
assert not is_unfolded(g)
assert all(x < 0 for x in vals[(2, 0)]) and all(x < 0 for x in vals[(3, 0)])
bad = {key for key, vs4 in vals.items() if min(vs4) <= 0}
assert bad == {(2, 0), (3, 0), (2, 1), (3, 1)}
def test_float_input_is_accepted() -> None:
g = tfi_grid([(0.0, 0.0), (1.0, 0.0)], [(0.0, 1.0), (1.0, 1.0)], [(0.0, 0.0), (0.0, 1.0)], [(1.0, 0.0), (1.0, 1.0)])
assert g == [[(0.0, 0.0), (0.0, 1.0)], [(1.0, 0.0), (1.0, 1.0)]]
def test_bad_input() -> None:
b, t, l, r = annulus_sides()
with pytest.raises(ValueError):
tfi_grid(b, t, l, [(F(5), F(5))] + r[1:])
with pytest.raises(ValueError):
tfi_grid(b, t[:2], l, r)
with pytest.raises(ValueError):
tfi_grid(b, t, l, r, u=[F(0), F(1, 2), F(2)])
History
Steven Coons introduced the bilinearly blended patch for surfaces in the 1960s. William Gordon described interpolation projectors and their Boolean sums in general in 1971. The word transfinite means that the interpolant matches a function on whole curves or surfaces, not only at finitely many points. In 1973 Gordon and Hall used it to build curvilinear coordinate systems and meshes for numerical methods. It became the standard algebraic method of the numerical grid generation books of the 1980s, and it remains the default way to fill structured blocks.
References
- William J. Gordon and Charles A. Hall, Construction of curvilinear co-ordinate systems and applications to mesh generation, International Journal for Numerical Methods in Engineering 7(4), 1973, 461 to 477, the transfinite interpolation of the boundary of a block by Boolean sums and its use for grids in two and three dimensions (general locator)
- William J. Gordon, Blending-function methods of bivariate and multivariate interpolation and approximation, SIAM Journal on Numerical Analysis 8(1), 1971, 158 to 177, the interpolation projectors, their Boolean sum, and the interpolation of a function on the whole boundary of a rectangle
- Joe F. Thompson, Z. U. A. Warsi and C. Wayne Mastin, Numerical Grid Generation, Foundations and Applications, North-Holland, 1985, the chapter on algebraic generation systems (general locator)
Where this leads
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.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag FNVCY2 Edit this page History Report an error Markdown