Algorithm Search⌘K

Algorithmresearch

Isogeometric collocation

Also called IGA collocation.

Auricchio and coauthors' method that enforces the strong form of the equations at Greville or other points instead of integrating, cheap because it needs no quadrature.

Time
O(n p^2) worst
Space
O(n p) extra
Where
n = number of spline basis functions; p = spline degree
Properties
deterministicnot exactiterative
Origin
Ferdinando Auricchio, Lourenço Beirão da Veiga, Thomas J. R. Hughes, Alessandro Reali, Giancarlo Sangalli, 2010

Isogeometric collocation solves a differential equation in the spline space of isogeometric analysis by asking the equation, in its strong form, to hold at one point per unknown. The points are usually the Greville abscissae of the B-spline basis. Auricchio, Beirão da Veiga, Hughes, Reali and Sangalli proposed it in 2010 as a cheaper partner of the Galerkin method: there is no integral, so there is no quadrature, and each row of the matrix costs one evaluation of the p+1p+1 non-zero basis functions and their derivatives. The price is accuracy: with Greville points the error in L2L^2 decreases like hph^p for even degree pp and like hp−1h^{p-1} for odd pp, against hp+1h^{p+1} for Galerkin. The basis on this page is the B-spline basis, and the discretization is collocation, in 1D.

In plain words

A spline is a smooth curve built from a row of overlapping bumps, each bump scaled by a number. To solve an equation with a spline, you must choose these numbers. The Galerkin way asks the equation to hold "on average" against every bump, and these averages are integrals that cost many function evaluations.

Collocation asks less. It picks one point for each unknown number, plugs the spline into the equation at that point, and asks the two sides to agree there. Each point gives one linear equation, so the unknowns follow from one linear system. A good choice of points is the "average position" of each bump, which comes from the knots alone. If the true answer is itself one of the splines, collocation finds it exactly.

The problem

The model problem is the 1D Poisson equation with Dirichlet boundary conditions:

−u′′(x)=f(x) on (a,b),u(a)=ga,u(b)=gb.-u''(x) = f(x) \text{ on } (a, b), \qquad u(a) = g_a, \quad u(b) = g_b.

The discrete space is Sp(ξ)=span⁡{N1,p,…,Nn,p}S_p(\xi) = \operatorname{span}\{N_{1,p}, \ldots, N_{n,p}\}, the B-splines of degree p≥2p \ge 2 on an open knot vector ξ=(ξ1,…,ξn+p+1)\xi = (\xi_1, \ldots, \xi_{n+p+1}), with ξ1=⋯=ξp+1=a\xi_1 = \cdots = \xi_{p+1} = a, ξn+1=⋯=ξn+p+1=b\xi_{n+1} = \cdots = \xi_{n+p+1} = b, and interior knots of multiplicity at most p−1p - 1. So each function of SpS_p is C1C^1 and has a second derivative on each knot span. The Greville abscissae are the knot averages

τi=ξi+1+ξi+2+⋯+ξi+pp,i=1,…,n.\tau_i = \frac{\xi_{i+1} + \xi_{i+2} + \cdots + \xi_{i+p}}{p}, \qquad i = 1, \ldots, n.

They satisfy τ1=a\tau_1 = a, τn=b\tau_n = b and τ1<τ2<⋯<τn\tau_1 < \tau_2 < \cdots < \tau_n. They are also the abscissae of the control points of the identity: x=∑iτiNi,p(x)x = \sum_i \tau_i N_{i,p}(x). The method looks for uh=∑jcjNj,pu_h = \sum_j c_j N_{j,p} with

uh(a)=ga,−uh′′(τi)=f(τi) (i=2,…,n−1),uh(b)=gb.u_h(a) = g_a, \qquad -u_h''(\tau_i) = f(\tau_i) \ (i = 2, \ldots, n-1), \qquad u_h(b) = g_b.

That is nn linear equations in nn unknowns. Where τi\tau_i falls on a knot at which uh′′u_h'' jumps, the value is the limit from the right.

The algorithm

  1. IGA-COLLOCATION(ξ, p, f, g_a, g_b)
  2. 1n ← |ξ| − p − 1 ▷ number of basis functions
  3. 2τ_i ← (ξ_{i+1} + ⋯ + ξ_{i+p}) / p for i = 1..n ▷ Greville abscissae
  4. 3row 1: A[1, j] ← N_j(a); b_1 ← g_a
  5. 4for i = 2 to n − 1 do
  6. 5A[i, j] ← −N_j''(τ_i) for the p + 1 values of j with N_j(τ_i) ≠ 0 or N_j''(τ_i) ≠ 0
  7. 6b_i ← f(τ_i)
  8. 7row n: A[n, j] ← N_j(b); b_n ← g_b
  9. 8solve the banded system A c = b and return c

Lines L3 and L7 are trivial for an open knot vector: N1(a)=1N_1(a) = 1, Nn(b)=1N_n(b) = 1, and all other basis functions vanish at the ends, so c1=gac_1 = g_a and cn=gbc_n = g_b. Line L5 evaluates the second derivatives of the non-zero B-splines at one point with the derivative form of the Cox-de Boor recursion, which gives all p+1p + 1 of them in O(p2)O(p^2) operations. Row ii has its non-zeros in the columns of the B-splines whose support holds τi\tau_i, so the matrix is a banded matrix of half bandwidth at most pp. The matrix is not symmetric, unlike the Galerkin matrix.

For a problem in 2D or 3D on a NURBS map FF of the parameter square or cube, the points are the tensor products of the 1D Greville abscissae, the rows are the strong form pulled back by FF (which needs the first and second derivatives of FF), and the boundary rows hold the boundary conditions at the Greville points of the boundary. The 1D case shows all the steps.

Example

A quadratic case by hand. Take p=2p = 2, two elements on (0,1)(0, 1), ξ=(0,0,0,12,1,1,1)\xi = (0, 0, 0, \tfrac12, 1, 1, 1), so n=4n = 4 and τ=(0,14,34,1)\tau = (0, \tfrac14, \tfrac34, 1). On the span [0,12][0, \tfrac12] the second derivatives of N1,N2,N3N_1, N_2, N_3 are 8,−12,48, -12, 4, and on [12,1][\tfrac12, 1] those of N2,N3,N4N_2, N_3, N_4 are 4,−12,84, -12, 8. For f=1f = 1 and ga=gb=0g_a = g_b = 0 the system is

(1000−812−400−412−80001)(c1c2c3c4)=(0110).\begin{pmatrix} 1 & 0 & 0 & 0 \\ -8 & 12 & -4 & 0 \\ 0 & -4 & 12 & -8 \\ 0 & 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} c_1 \\ c_2 \\ c_3 \\ c_4 \end{pmatrix} = \begin{pmatrix} 0 \\ 1 \\ 1 \\ 0 \end{pmatrix}.

With c1=c4=0c_1 = c_4 = 0 the middle rows read 12c2−4c3=112 c_2 - 4 c_3 = 1 and −4c2+12c3=1-4 c_2 + 12 c_3 = 1, so c2=c3=18c_2 = c_3 = \tfrac18. The spline is uh(x)=x(1−x)/2u_h(x) = x(1 - x)/2, the exact solution, for example uh(12)=12⋅18+12⋅18=18u_h(\tfrac12) = \tfrac12 \cdot \tfrac18 + \tfrac12 \cdot \tfrac18 = \tfrac18. This is no accident: the exact solution is a quadratic, so it is in S2S_2, and the theorem below says that collocation then returns it.

A cubic case. With p=3p = 3 and four elements, τ=(0,112,14,12,34,1112,1)\tau = (0, \tfrac1{12}, \tfrac14, \tfrac12, \tfrac34, \tfrac{11}{12}, 1). On a uniform mesh and away from the ends, the Greville points of odd degree lie on the knots, and those of even degree lie at the element midpoints. For f=1f = 1 the coefficients are (0,124,548,1396,548,124,0)(0, \tfrac1{24}, \tfrac5{48}, \tfrac{13}{96}, \tfrac5{48}, \tfrac1{24}, 0), again the exact solution.

Convergence for a smooth solution. For u=sin⁡πxu = \sin \pi x, f=π2sin⁡πxf = \pi^2 \sin \pi x, uniform meshes of nen_e elements, the largest error over 801 equally spaced points is:

degree ne=8n_e = 8 ne=16n_e = 16 ne=32n_e = 32 ne=64n_e = 64 observed order
p=2p = 2 6.51×10−36.51 \times 10^{-3} 1.61×10−31.61 \times 10^{-3} 4.02×10−44.02 \times 10^{-4} 1.00×10−41.00 \times 10^{-4} 2.0
p=3p = 3 1.26×10−21.26 \times 10^{-2} 3.20×10−33.20 \times 10^{-3} 8.03×10−48.03 \times 10^{-4} 2.01×10−42.01 \times 10^{-4} 2.0
p=4p = 4 6.35×10−56.35 \times 10^{-5} 4.69×10−64.69 \times 10^{-6} 3.16×10−73.16 \times 10^{-7} 2.04×10−82.04 \times 10^{-8} 3.95
p=5p = 5 3.12×10−53.12 \times 10^{-5} 2.06×10−62.06 \times 10^{-6} 1.29×10−71.29 \times 10^{-7} 8.07×10−98.07 \times 10^{-9} 4.0

The order is pp for even pp and p−1p - 1 for odd pp, and the cubic is no better than the quadratic on the same mesh. The largest error of uh′′u_h'' on the same runs decreases with order p−1p - 1 for each degree from 2 to 5. These are measurements on one smooth problem. They agree with the orders that the papers report, given under Complexity.

Correctness

The method is a collocation method in a spline space, and two things need proof: the system has exactly one solution, and the method is exact when the solution lies in the space.

Theorem. Let p≥2p \ge 2, let ξ\xi be open with interior knots of multiplicity at most p−1p - 1, and let τ\tau be the Greville abscissae. Then the matrix of lines L3 to L7 is non-singular. So if the exact solution uu is in Sp(ξ)S_p(\xi), the method returns uh=uu_h = u.

The idea of the proof: if uhu_h solves the problem with zero data, then uh′′u_h'' is a spline of degree p−2p - 2 that vanishes at the n−2n - 2 interior Greville points. The space of such second derivatives has dimension n−2n - 2, and the Greville point τi\tau_i lies strictly inside the support of the ii-th of its B-splines. The Schoenberg-Whitney theorem then forces uh′′=0u_h'' = 0, so uhu_h is linear, and the boundary rows make it zero. Exactness follows: uu itself satisfies all nn equations, and the solution is unique. The full proof is below.

The theorem says nothing about the error when u∉Spu \notin S_p. That error is the subject of the convergence results below, which are not proved on this page.

Proof: Collocation at the Greville abscissae has a unique solution and is exact on the spline spacefull

We use the notation of the page. The degree is p≥2p \ge 2. The knot vector ξ=(ξ1,…,ξn+p+1)\xi = (\xi_1, \ldots, \xi_{n+p+1}) is open on [a,b][a, b], so ξ1=⋯=ξp+1=a\xi_1 = \cdots = \xi_{p+1} = a and ξn+1=⋯=ξn+p+1=b\xi_{n+1} = \cdots = \xi_{n+p+1} = b, and each interior knot value has multiplicity at most p−1p - 1. Nj,dN_{j,d} is the B-spline of degree dd with the knots ξj,…,ξj+d+1\xi_j, \ldots, \xi_{j+d+1}, taken right-continuous, with the value at bb taken as the limit from the left. A spline value at a knot where it jumps is the limit from the right, as in line L5.

Fact 1 (knot runs). (a) For 3≤k≤n3 \le k \le n, the pp knots ξk,…,ξk+p−1\xi_k, \ldots, \xi_{k+p-1} are not all equal. (b) For 1≤i≤n−11 \le i \le n - 1, the p+1p + 1 knots ξi+1,…,ξi+p+1\xi_{i+1}, \ldots, \xi_{i+p+1} are not all equal.

Proof. The value aa occurs exactly at ξ1,…,ξp+1\xi_1, \ldots, \xi_{p+1}, the value bb exactly at ξn+1,…,ξn+p+1\xi_{n+1}, \ldots, \xi_{n+p+1}, and an interior value at most p−1p - 1 times. (a) A run that starts at ξk\xi_k with k≥3k \ge 3 holds at most the p−1p - 1 copies ξ3,…,ξp+1\xi_3, \ldots, \xi_{p+1} of aa. A run that ends at ξk+p−1\xi_{k+p-1} with k≤nk \le n ends at ξn+p−1\xi_{n+p-1} or earlier, so it holds at most the p−1p - 1 copies ξn+1,…,ξn+p−1\xi_{n+1}, \ldots, \xi_{n+p-1} of bb. An interior value gives at most p−1p - 1 equal knots. So no pp of these knots are equal. (b) A run that starts at ξ2\xi_2 or later holds at most pp copies of aa, one that ends at ξn+p\xi_{n+p} or earlier holds at most pp copies of bb, and an interior value gives at most p−1p - 1. So no p+1p + 1 of these knots are equal. □\square

Lemma 1 (the Greville points). τ1=a\tau_1 = a, τn=b\tau_n = b, τ1<τ2<⋯<τn\tau_1 < \tau_2 < \cdots < \tau_n, and for 2≤i≤n−12 \le i \le n - 1 the point τi\tau_i lies strictly between ξi+1\xi_{i+1} and ξi+p\xi_{i+p}.

Proof. τ1\tau_1 is the mean of ξ2,…,ξp+1\xi_2, \ldots, \xi_{p+1}, which all equal aa, and τn\tau_n is the mean of ξn+1,…,ξn+p\xi_{n+1}, \ldots, \xi_{n+p}, which all equal bb. Next, τi+1−τi=(ξi+p+1−ξi+1)/p≥0\tau_{i+1} - \tau_i = (\xi_{i+p+1} - \xi_{i+1}) / p \ge 0, and it is zero only if the p+1p + 1 knots ξi+1,…,ξi+p+1\xi_{i+1}, \ldots, \xi_{i+p+1} are equal, which Fact 1(b) excludes for 1≤i≤n−11 \le i \le n - 1. For the last claim, τi\tau_i is the mean of the pp knots ξi+1,…,ξi+p\xi_{i+1}, \ldots, \xi_{i+p}, and with k=i+1∈{3,…,n}k = i + 1 \in \{3, \ldots, n\} Fact 1(a) says they are not all equal. A mean of numbers that are not all equal lies strictly between their least and their largest value, here ξi+1\xi_{i+1} and ξi+p\xi_{i+p}. □\square

Lemma 2 (the space of second derivatives). For each u∈Sp(ξ)u \in S_p(\xi), the second derivative u′′u'' (right limits at the knots) lies in V=span⁡{Mk:3≤k≤n}V = \operatorname{span}\{M_k : 3 \le k \le n\} with Mk=Nk,p−2M_k = N_{k,p-2}. The n−2n - 2 functions MkM_k are linearly independent on [a,b)[a, b).

Proof. The derivative formula for B-splines (de Boor, Chapter X) gives

Nj,d′=dξj+d−ξjNj,d−1−dξj+d+1−ξj+1Nj+1,d−1,N_{j,d}' = \frac{d}{\xi_{j+d} - \xi_j} N_{j,d-1} - \frac{d}{\xi_{j+d+1} - \xi_{j+1}} N_{j+1,d-1},

on each knot span, with a term dropped when its denominator is zero. Applied twice, it writes u′′u'' for u=∑j=1ncjNj,pu = \sum_{j=1}^{n} c_j N_{j,p} as a combination of Nk,p−2N_{k,p-2} for 1≤k≤n+21 \le k \le n + 2. The function Nk,p−2N_{k,p-2} has the pp knots ξk,…,ξk+p−1\xi_k, \ldots, \xi_{k+p-1}. For k=1,2k = 1, 2 these knots all equal aa, and for k=n+1,n+2k = n + 1, n + 2 they all equal bb, so these four functions are zero. That leaves 3≤k≤n3 \le k \le n. For these kk the knots of MkM_k are not all equal by Fact 1(a), so MkM_k is a non-zero B-spline. The knot sequence ξ3,…,ξn+p−1\xi_3, \ldots, \xi_{n+p-1} of the MkM_k has no value of multiplicity more than p−1=(p−2)+1p - 1 = (p - 2) + 1, so by the Curry-Schoenberg theorem the MkM_k are a basis of the splines of degree p−2p - 2 on it, and in particular they are linearly independent. □\square

Theorem. Under the precondition above, the n×nn \times n matrix of lines L3 to L7 is non-singular. If the exact solution uu of −u′′=f-u'' = f, u(a)=gau(a) = g_a, u(b)=gbu(b) = g_b lies in Sp(ξ)S_p(\xi), then IGA-COLLOCATION returns its coefficients.

Proof. A square matrix is non-singular if its kernel is zero. So let cc satisfy the homogeneous system, and let v=∑jcjNj,pv = \sum_j c_j N_{j,p}. Then v(a)=0v(a) = 0 (line L3), v(b)=0v(b) = 0 (line L7), and v′′(τi)=0v''(\tau_i) = 0 for 2≤i≤n−12 \le i \le n - 1 (line L5).

By Lemma 2, v′′=∑k=3ndkMkv'' = \sum_{k=3}^{n} d_k M_k for some numbers dkd_k. Re-index the interior rows by k=i+1k = i + 1: row ii asks the element v′′v'' of VV to vanish at xk=τk−1x_k = \tau_{k-1}, for k=3,…,nk = 3, \ldots, n. By Lemma 1 these n−2n - 2 points are strictly increasing, and xk=τk−1x_k = \tau_{k-1} lies strictly between ξk\xi_k and ξk+p−1\xi_{k+p-1}, the first and the last knot of MkM_k. A B-spline is positive on the open interval between its first and its last knot, so Mk(xk)>0M_k(x_k) > 0 for each kk. This is the condition of the Schoenberg-Whitney theorem (de Boor, Chapter XIII): interpolation in VV at the points x3<⋯<xnx_3 < \cdots < x_n has a unique solution. The zero spline interpolates zero data, so v′′=0v'' = 0, that is, all dk=0d_k = 0.

So v′′=0v'' = 0 on each knot span, and v′v' is constant on each span. The interior knots have multiplicity at most p−1p - 1, so vv is C1C^1 on [a,b][a, b] and v′v' is continuous. A continuous function that is constant on each span of a partition is constant. So vv is a polynomial of degree at most 1, and v(a)=v(b)=0v(a) = v(b) = 0 gives v=0v = 0. The B-splines Nj,pN_{j,p} are linearly independent, so c=0c = 0. The kernel is zero, and the matrix is non-singular.

For the second claim, let u=∑jujNj,p∈Sp(ξ)u = \sum_j u_j N_{j,p} \in S_p(\xi) be the exact solution. Then u(a)=gau(a) = g_a and u(b)=gbu(b) = g_b, and −u′′(τi)=f(τi)-u''(\tau_i) = f(\tau_i) for every interior ii, so the vector (uj)(u_j) solves the system of lines L3 to L7. By the first part this system has exactly one solution, and line L8 returns it. So the method returns uu. ■\blacksquare

The precondition is needed. Let p=2p = 2 and ξ=(0,0,0,12,12,1,1,1)\xi = (0, 0, 0, \tfrac12, \tfrac12, 1, 1, 1), with the interior knot of multiplicity p=2p = 2. Then n=5n = 5, τ=(0,14,12,34,1)\tau = (0, \tfrac14, \tfrac12, \tfrac34, 1), and S2S_2 holds v(x)=min⁡(x,1−x)v(x) = \min(x, 1 - x), which is C0C^0 at 12\tfrac12. It has v′′=0v'' = 0 on both spans and v(0)=v(1)=0v(0) = v(1) = 0. So v≠0v \ne 0 is in the kernel, and the matrix is singular. In the proof, the step from v′′=0v'' = 0 to "vv is linear" fails because v′v' jumps.

What is not proved here. The theorem gives existence, uniqueness and exactness on SpS_p. It gives no error bound for a solution outside SpS_p. The orders hph^p (even pp) and hp−1h^{p-1} (odd pp) in L2L^2 and H1H^1, and hp−1h^{p-1} in H2H^2, are cited from Auricchio and coauthors (2010) and Montardini, Sangalli and Tamellini (2017), and the table on the page measures them on one problem.

Complexity

In the real RAM model with nn unknowns and degree pp:

  • Forming the system. Each of the nn rows needs the span of one point, found by binary search in O(log⁡n)O(\log n), and the second derivatives of p+1p + 1 B-splines in O(p2)O(p^2). So the matrix costs O(n(p2+log⁡n))O(n (p^2 + \log n)), and with the spans known in order, O(np2)O(n p^2). Galerkin needs about p+1p + 1 quadrature points per element and (p+1)2(p + 1)^2 products at each, so O(np3)O(n p^3) in 1D. In dd dimensions a collocation row has (p+1)d(p + 1)^d entries, while Galerkin needs (p+1)d(p + 1)^d quadrature points per element, each adding to (p+1)2d(p + 1)^{2d} products. Schillinger and coauthors (2013) count these operations in detail and find that the gap grows with pp and dd.
  • Solving. The matrix has half bandwidth pp. Gaussian elimination with partial pivoting on a band of this width takes O(np2)O(n p^2) time and O(np)O(n p) space. The implementation below uses a dense solver, O(n3)O(n^3), which is enough for the tests.

Accuracy. For a smooth solution, uniform meshes of size hh and the smoothest splines (Cp−1C^{p-1}), collocation at the Greville abscissae has these orders:

  • In L2L^2 and in H1H^1: O(hp)O(h^p) for even pp and O(hp−1)O(h^{p-1}) for odd pp. The best approximation in SpS_p is O(hp+1)O(h^{p+1}) in L2L^2 and O(hp)O(h^p) in H1H^1, so the method loses one order in L2L^2 for even pp and two for odd pp, and is optimal in H1H^1 only for even pp.
  • In H2H^2: O(hp−1)O(h^{p-1}) for every pp, the best possible order in this norm.

Auricchio and coauthors (2010) report these orders from numerical tests, and Montardini, Sangalli and Tamellini (2017) restate them in this form. The table of the Example measures the same orders in the maximum norm. Galerkin with the same space gives O(hp+1)O(h^{p+1}) in L2L^2. So for equal accuracy collocation needs a finer mesh or a higher degree, and the cost comparison above has to be made at equal error, as Schillinger and coauthors do.

Properties

  • No quadrature. Each row needs one evaluation of the basis and its derivatives, at one point.
  • One point per unknown. The matrix is square, banded and not symmetric. Its condition number grows like h−2h^{-2}, as for the second derivative of any discretization.
  • Exact on the space. A solution in SpS_p is reproduced exactly, in particular every polynomial of degree at most pp.
  • Strong form. The method needs the second derivative of uhu_h at the points, so the space must be at least C1C^1; the C0C^0 basis of standard finite elements does not work.
  • Same geometry as IGA. The geometry stays exact under the refinements of k-refinement, as in Galerkin IGA.

Variants and improvements

  • Other points. Demko abscissae, and points related to Galerkin superconvergence: Montardini, Sangalli and Tamellini (2017) choose a subset of the superconvergent points, more than one per element and fewer than two, solved in a least-squares or a clustered way, and reach the optimal order p+1p + 1 in L2L^2 for odd pp.
  • NURBS and multi-patch geometry. The rows hold the pulled-back operator. At patch interfaces the strong form is replaced by a condition on the fluxes.
  • Hierarchical and local refinement. Schillinger and coauthors (2013) use collocation on hierarchical NURBS, see hierarchical B-splines.
  • Explicit dynamics. With a lumped mass, collocation gives a time step with one evaluation per node, which is the main use of the method in practice.
  • Systems. Elasticity, beams and plates use the same idea with one row per component and point.

When to use it

Use collocation when the cost of forming the system dominates: high degree, 3D, explicit dynamics or nonlinear problems that need many re-assemblies. Use Galerkin when the error per unknown matters most, when the equation has a weak form that the strong form cannot match (rough coefficients, point loads, interfaces), or when symmetry of the matrix is needed. For integral equations on the boundary, collocation is also the common choice, see the isogeometric boundary element method.

Pitfalls

  • An interior knot of multiplicity pp. Then SpS_p holds a function with a kink and u′′=0u'' = 0 on both sides, such as min⁡(x,1−x)\min(x, 1 - x) for p=2p = 2 with a double knot at 12\tfrac12, and the matrix of lines L3 to L7 is singular. Keep the interior multiplicity at most p−1p - 1, as the precondition says, or add a row for the jump of u′u'.
  • Expecting Galerkin accuracy. Doubling the degree from 2 to 3 does not help here: the table shows the cubic worse than the quadratic on the same mesh. Use even degrees, or other points, when the L2L^2 error matters.
  • The value at a knot. For p=2p = 2 the second derivative jumps at each knot. Line L5 must use one fixed side, as the code does with the right limit, or the rows depend on rounding of τi\tau_i.
  • Neumann conditions. A flux condition at an end is a row with Nj′N_j', and it must replace one interior row, not be added to the system, or the matrix is no longer square.
  • Geometry derivatives. In 2D and 3D the rows need second derivatives of the NURBS map. A geometry map with a weak or a zero Jacobian makes these rows large or undefined, see volumetric spline parameterization.

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.

ig2kit.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Shared helper of the ig2 cad pages of https://algorithm.tamnd.com/. The authors are listed in prov/.
"""Small numerical helpers: B-spline basis with derivatives, Greville points,
Gauss-Legendre points and a dense linear solver.

Every function works with float, and the spline and solver functions also work
with fractions.Fraction, so that a test can check an exact identity.
"""

from __future__ import annotations

import math
from typing import List, Sequence, Tuple


def open_uniform_knots(p: int, ne: int, a=0, b=1) -> List:
    """Open knot vector of degree p with ne equal elements on [a, b].

    The ends have multiplicity p + 1 and the interior knots are simple.
    With Fraction inputs the knots are Fractions.
    """
    inner = [a + (b - a) * k / ne for k in range(1, ne)]
    return [a] * (p + 1) + inner + [b] * (p + 1)


def find_span(knots: Sequence, p: int, x) -> int:
    """Index s with knots[s] <= x < knots[s + 1], and the last non-empty span for x = knots[-1]."""
    n = len(knots) - p - 1  # number of basis functions
    if x >= knots[n]:
        s = n - 1
        while knots[s] == knots[s + 1]:
            s -= 1
        return s
    lo, hi = p, n
    while hi - lo > 1:
        mid = (lo + hi) // 2
        if x < knots[mid]:
            hi = mid
        else:
            lo = mid
    return lo


def basis_ders(knots: Sequence, p: int, s: int, x, nd: int) -> List[List]:
    """Values and derivatives of the p + 1 B-splines that are non-zero on span s.

    Returns d with d[k][j] = the k-th derivative of N_{s - p + j} at x, for
    k = 0..nd. This is algorithm A2.3 of Piegl and Tiller.
    """
    one = x - x + 1
    zero = x - x
    ndu = [[zero] * (p + 1) for _ in range(p + 1)]
    ndu[0][0] = one
    left = [zero] * (p + 1)
    right = [zero] * (p + 1)
    for j in range(1, p + 1):
        left[j] = x - knots[s + 1 - j]
        right[j] = knots[s + j] - x
        saved = zero
        for r in range(j):
            ndu[j][r] = right[r + 1] + left[j - r]
            temp = ndu[r][j - 1] / ndu[j][r]
            ndu[r][j] = saved + right[r + 1] * temp
            saved = left[j - r] * temp
        ndu[j][j] = saved
    ders = [[zero] * (p + 1) for _ in range(nd + 1)]
    for j in range(p + 1):
        ders[0][j] = ndu[j][p]
    for r in range(p + 1):
        s1, s2 = 0, 1
        a = [[zero] * (p + 1) for _ in range(2)]
        a[0][0] = one
        for k in range(1, nd + 1):
            dval = zero
            rk, pk = r - k, p - k
            if r >= k:
                a[s2][0] = a[s1][0] / ndu[pk + 1][rk]
                dval = a[s2][0] * ndu[rk][pk]
            j1 = 1 if rk >= -1 else -rk
            j2 = k - 1 if r - 1 <= pk else p - r
            for j in range(j1, j2 + 1):
                a[s2][j] = (a[s1][j] - a[s1][j - 1]) / ndu[pk + 1][rk + j]
                dval += a[s2][j] * ndu[rk + j][pk]
            if r <= pk:
                a[s2][k] = -a[s1][k - 1] / ndu[pk + 1][r]
                dval += a[s2][k] * ndu[r][pk]
            ders[k][r] = dval
            s1, s2 = s2, s1
    fac = p
    for k in range(1, nd + 1):
        for j in range(p + 1):
            ders[k][j] = ders[k][j] * fac
        fac *= p - k
    return ders


def all_basis(knots: Sequence, p: int, x, nd: int = 0) -> List[List]:
    """Full rows: out[k][i] = k-th derivative of N_i at x, for all n basis functions."""
    n = len(knots) - p - 1
    s = find_span(knots, p, x)
    d = basis_ders(knots, p, s, x, nd)
    zero = x - x
    out = [[zero] * n for _ in range(nd + 1)]
    for k in range(nd + 1):
        for j in range(p + 1):
            out[k][s - p + j] = d[k][j]
    return out


def greville(knots: Sequence, p: int) -> List:
    """Greville abscissae tau_i = (knots[i+1] + ... + knots[i+p]) / p."""
    n = len(knots) - p - 1
    return [sum(knots[i + 1 : i + p + 1]) / p for i in range(n)]


def solve_dense(a: List[List], b: List) -> List:
    """Solve a x = b by Gaussian elimination with partial pivoting.

    Works with float and with Fraction (then the result is exact).
    Raises ValueError if the matrix is singular (an exact zero pivot).
    Cost O(n^3) operations.
    """
    n = len(a)
    m = [list(row) + [bi] for row, bi in zip(a, b)]
    for c in range(n):
        piv = max(range(c, n), key=lambda r: abs(m[r][c]))
        if m[piv][c] == 0:
            raise ValueError("singular matrix")
        m[c], m[piv] = m[piv], m[c]
        for r in range(c + 1, n):
            f = m[r][c] / m[c][c]
            if f != 0:
                row_r, row_c = m[r], m[c]
                for k in range(c, n + 1):
                    row_r[k] -= f * row_c[k]
    x = [0] * n
    for r in range(n - 1, -1, -1):
        acc = m[r][n]
        for k in range(r + 1, n):
            acc -= m[r][k] * x[k]
        x[r] = acc / m[r][r]
    return x


def gauss_legendre(n: int) -> Tuple[List[float], List[float]]:
    """Nodes and weights of the n-point Gauss-Legendre rule on [-1, 1]."""
    xs, ws = [], []
    for i in range(1, n + 1):
        x = math.cos(math.pi * (i - 0.25) / (n + 0.5))
        for _ in range(100):
            p0, p1 = 1.0, x
            for k in range(2, n + 1):
                p0, p1 = p1, ((2 * k - 1) * x * p1 - (k - 1) * p0) / k
            dp = n * (x * p1 - p0) / (x * x - 1)
            dx = p1 / dp
            x -= dx
            if abs(dx) < 1e-16:
                break
        p0, p1 = 1.0, x
        for k in range(2, n + 1):
            p0, p1 = p1, ((2 * k - 1) * x * p1 - (k - 1) * p0) / k
        dp = n * (x * p1 - p0) / (x * x - 1)
        xs.append(x)
        ws.append(2.0 / ((1 - x * x) * dp * dp))
    return xs, ws
isogeometric_collocation.py 65 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/isogeometric-collocation/. The authors are listed in prov/AE2H60.jsonl.
"""Isogeometric collocation for the 1D Poisson problem.

Solve -u'' = f on (a, b) with u(a) = ga and u(b) = gb in the B-spline space of
degree p on an open knot vector, by asking the strong form to hold at the
interior Greville abscissae.
"""

from __future__ import annotations

from typing import Callable, List, Sequence, Tuple

from ig2kit import all_basis, greville, open_uniform_knots, solve_dense


def collocate_poisson(
    knots: Sequence, p: int, f: Callable, ga, gb
) -> Tuple[List, List]:
    """Return (coefficients, collocation points) of the collocation solution.

    Precondition: p >= 2, an open knot vector (end multiplicity p + 1) and
    interior knots of multiplicity at most p - 1. Then the system is
    non-singular (Schoenberg-Whitney, see the proof on the page).
    Cost: O(n p) to build the banded rows and O(n^3) for the dense solve,
    with n = len(knots) - p - 1 unknowns.
    Works with float or with Fraction knots and data (then it is exact).
    """
    n = len(knots) - p - 1  # @line L1
    tau = greville(knots, p)  # @line L2
    a_, b_ = knots[0], knots[-1]
    rows, rhs = [], []
    rows.append(all_basis(knots, p, a_, 0)[0])  # @line L3
    rhs.append(ga)
    for i in range(1, n - 1):  # @line L4
        d2 = all_basis(knots, p, tau[i], 2)[2]
        rows.append([-v for v in d2])  # @line L5
        rhs.append(f(tau[i]))  # @line L6
    rows.append(all_basis(knots, p, b_, 0)[0])  # @line L7
    rhs.append(gb)
    c = solve_dense(rows, rhs)  # @line L8
    return c, tau


def evaluate(knots: Sequence, p: int, c: Sequence, x, nd: int = 0):
    """Value (nd = 0) or nd-th derivative of the spline with coefficients c at x."""
    row = all_basis(knots, p, x, nd)[nd]
    return sum(ci * ri for ci, ri in zip(c, row))


def max_error(knots: Sequence, p: int, c: Sequence, exact: Callable, samples: int = 400) -> float:
    """Largest |u_h - u| over equally spaced samples (a measure, not a proof)."""
    a_, b_ = float(knots[0]), float(knots[-1])
    worst = 0.0
    for k in range(samples + 1):
        x = a_ + (b_ - a_) * k / samples
        worst = max(worst, abs(float(evaluate(knots, p, c, x)) - exact(x)))
    return worst


def uniform_solve(p: int, ne: int, f: Callable, ga=0.0, gb=0.0) -> Tuple[List, List]:
    """Collocation on (0, 1) with ne equal elements; returns (knots, coefficients)."""
    knots = open_uniform_knots(p, ne)
    c, _ = collocate_poisson(knots, p, f, ga, gb)
    return knots, c
test_isogeometric_collocation.py 100 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/isogeometric-collocation/. The authors are listed in prov/AE2H60.jsonl.

import math
import random
from fractions import Fraction as F

import pytest

from ig2kit import all_basis, greville, open_uniform_knots
from isogeometric_collocation import collocate_poisson, evaluate, max_error, uniform_solve


def random_knots(rng: random.Random, p: int, max_mult: int) -> list:
    """Open knot vector on [0, 1] with random rational interior knots of multiplicity <= max_mult."""
    m = rng.randint(1, 4)
    inner = sorted({F(rng.randint(1, 15), 16) for _ in range(m)})
    knots = [F(0)] * (p + 1)
    for t in inner:
        knots += [t] * rng.randint(1, max_mult)
    return knots + [F(1)] * (p + 1)


def test_worked_example() -> None:
    knots = open_uniform_knots(2, 2, F(0), F(1))
    assert greville(knots, 2) == [0, F(1, 4), F(3, 4), 1]
    assert all_basis(knots, 2, F(1, 4), 2)[2] == [8, -12, 4, 0]
    c, _ = collocate_poisson(knots, 2, lambda x: F(1), F(0), F(0))
    assert c == [0, F(1, 8), F(1, 8), 0]
    for k in range(9):
        x = F(k, 8)
        assert evaluate(knots, 2, c, x) == x * (1 - x) / 2


def test_cubic_example() -> None:
    knots = open_uniform_knots(3, 4, F(0), F(1))
    c, tau = collocate_poisson(knots, 3, lambda x: F(1), F(0), F(0))
    assert tau == [0, F(1, 12), F(1, 4), F(1, 2), F(3, 4), F(11, 12), 1]
    assert c == [0, F(1, 24), F(5, 48), F(13, 96), F(5, 48), F(1, 24), 0]


def test_exact_on_random_splines() -> None:
    """If the solution is in the spline space, collocation returns it exactly."""
    rng = random.Random(4211)
    for _ in range(150):
        p = rng.randint(2, 5)
        knots = random_knots(rng, p, p - 1)
        n = len(knots) - p - 1
        u = [F(0)] + [F(rng.randint(-20, 20), rng.randint(1, 9)) for _ in range(n - 2)] + [F(0)]
        u[-1] = F(rng.randint(-5, 5))
        f = lambda x, u=u, knots=knots, p=p: -evaluate(knots, p, u, x, 2)
        c, _ = collocate_poisson(knots, p, f, u[0], u[-1])
        assert c == u


def test_exact_on_polynomials() -> None:
    """u = sum a_k x^k of degree <= p: the method reproduces it exactly."""
    rng = random.Random(77)
    for _ in range(100):
        p = rng.randint(2, 5)
        knots = random_knots(rng, p, p - 1)
        a = [F(rng.randint(-9, 9), rng.randint(1, 5)) for _ in range(p + 1)]
        u = lambda x: sum(ak * x**k for k, ak in enumerate(a))
        f = lambda x: -sum(k * (k - 1) * ak * x ** (k - 2) for k, ak in enumerate(a) if k >= 2)
        c, _ = collocate_poisson(knots, p, f, u(F(0)), u(F(1)))
        for j in range(11):
            x = F(j, 10)
            assert evaluate(knots, p, c, x) == u(x)


def test_singular_with_multiplicity_p() -> None:
    """Pitfall: an interior knot of multiplicity p allows a kink with u'' = 0."""
    knots = [F(0)] * 3 + [F(1, 2)] * 2 + [F(1)] * 3
    with pytest.raises(ValueError):
        collocate_poisson(knots, 2, lambda x: F(1), F(0), F(0))


def test_error_and_rates_against_exact() -> None:
    f = lambda x: math.pi**2 * math.sin(math.pi * x)
    exact = lambda x: math.sin(math.pi * x)
    for p in (2, 3, 4, 5):
        errs = []
        for ne in (8, 16, 32):
            knots, c = uniform_solve(p, ne, f)
            errs.append(max_error(knots, p, c, exact, 400))
        rates = [math.log2(errs[i] / errs[i + 1]) for i in range(2)]
        expected = p if p % 2 == 0 else p - 1
        assert abs(rates[-1] - expected) < 0.2, (p, rates)
    knots, c = uniform_solve(4, 16, f)
    assert max_error(knots, 4, c, exact, 400) < 1e-5


def test_second_derivative_rate() -> None:
    f = lambda x: math.pi**2 * math.sin(math.pi * x)
    for p in (2, 3, 4):
        errs = []
        for ne in (16, 32):
            knots, c = uniform_solve(p, ne, f)
            errs.append(max(abs(float(evaluate(knots, p, c, k / 200, 2)) + f(k / 200)) for k in range(201)))
        assert abs(math.log2(errs[0] / errs[1]) - (p - 1)) < 0.2

History

Collocation with piecewise polynomials for ordinary boundary value problems is old. De Boor and Swartz (1973) proved the convergence orders of collocation at Gauss points with Cm−1C^{m-1} splines for equations of order mm. Isogeometric analysis came in 2005, with Galerkin as its standard discretization. Auricchio, Beirão da Veiga, Hughes, Reali and Sangalli (2010) proposed to collocate at the Greville abscissae of the smooth spline basis, with an analysis of the 1D case and numerical tests of the orders. Schillinger, Evans, Reali, Scott and Hughes (2013) counted the operations against Galerkin and extended the method to hierarchical NURBS. Later work looked for points with better orders, such as the superconvergent points of Montardini, Sangalli and Tamellini (2017).

References

  1. F. Auricchio, L. Beirão da Veiga, T. J. R. Hughes, A. Reali and G. Sangalli, Isogeometric collocation methods, Mathematical Models and Methods in Applied Sciences 20(11), 2010, 2075 to 2107, the whole paper (collocation at the Greville abscissae, the 1D analysis, and the numerical convergence orders p for even and p - 1 for odd degree)
  2. D. Schillinger, J. A. Evans, A. Reali, M. A. Scott and T. J. R. Hughes, Isogeometric collocation, cost comparison with Galerkin methods and extension to adaptive hierarchical NURBS discretizations, Computer Methods in Applied Mechanics and Engineering 267, 2013, 170 to 232, the operation counts of the formation and the solution of collocation and Galerkin systems
  3. M. Montardini, G. Sangalli and L. Tamellini, Optimal-order isogeometric collocation at Galerkin superconvergent points, Computer Methods in Applied Mechanics and Engineering 316, 2017, 741 to 757, the introduction (the orders of Greville collocation in the L2, H1 and H2 norms) and the clustered superconvergent points
  4. Carl de Boor, A Practical Guide to Splines, revised edition, Springer, 2001, Chapter X (derivatives of B-splines) and Chapter XIII (the Schoenberg-Whitney theorem on spline interpolation)
  5. Carl de Boor and Blair Swartz, Collocation at Gaussian points, SIAM Journal on Numerical Analysis 10(4), 1973, 582 to 606, the whole paper, spline collocation for ordinary boundary value problems, the older form of the idea

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