Algorithmresearch
Isogeometric boundary element method
Also called IGABEM.
Uses the spline basis of the CAD boundary for boundary integral equations, so only the surface needs a parameterization, as Politis and then Simpson and coauthors showed.
- Solves
- Poisson equation
- Time
- O(n^2 g + n^3) worst
- Space
- O(n^2) extra
- Where
- g = Gauss points per element; n = number of boundary unknowns
- Model
- Real RAM
- Properties
- deterministicnot exactiterative
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Costas Politis, Alexandros I. Ginnis, Panagiotis D. Kaklis, Robert N. Simpson, Stéphane P. A. Bordas, Jon Trevelyan, Timon Rabczuk, 2009
The isogeometric boundary element method (IGABEM) solves a linear partial differential equation by an integral equation on the boundary of the domain, and it uses the NURBS basis of the CAD boundary both for the geometry and for the unknown fields. A CAD solid is stored by its boundary, so the method needs no volume mesh and no volumetric spline parameterization, which is the hard step of volume isogeometric analysis. Politis and coauthors (2009) used it for 2D potential flow, and Simpson, Bordas, Trevelyan and Rabczuk (2012) for 2D elasticity. No page of this site covers the boundary element method itself, so this page defines what it needs, for the 2D Laplace equation, with collocation at the Greville abscissae as in isogeometric collocation.
In plain words
For some equations, such as steady heat flow without sources, the values inside a region follow from the values and the fluxes on its border. A classic formula, built from the field of a point source, ties the two together. So you can solve for the unknown border data only, and the problem lives on a curve instead of on a whole area.
To solve the border problem, you need a way to describe functions on the border. The CAD model already describes the border with smooth spline pieces. The method uses those same pieces for the unknown data, so the shape is exact and no mesh has to be made. You ask the border formula to hold at one point per unknown, get a full linear system, and solve it. The values inside then follow from the same formula.
The problem
Let be a bounded domain with a smooth boundary and outward normal . Given on , find with
that is, the Poisson equation with zero source. The unknown of the boundary method is the flux on .
The boundary integral equation. The fundamental solution of the 2D Laplace equation and its normal derivative at are
Green's second identity, applied on minus a small disc around , gives for a harmonic and an interior point the representation formula . As moves to a smooth point of , the second integral jumps by half the value, and
The right side is the single layer operator , with a weak singularity . On a smooth boundary is bounded, because is of order .
The isogeometric discretization. is a closed NURBS curve , , of degree , counterclockwise, with an open knot vector and . The functions and are merged into one, which gives functions that are continuous around the closed curve and sum to 1. Both fields use this basis, and . The collocation points are , , for the Greville abscissae without the last one, which gives the same point as the first.
The algorithm
IGABEM-DIRICHLET(C, g) ▷ C: closed NURBS curve, g: boundary values- 1
n ← number of control points − 1 ▷ first and last basis functions merged - 2
τ_i ← Greville abscissae of the knots, the last dropped; x_i ← C(τ_i) - 3
for i = 1 to n, for each element e = [t_a, t_b] of C do - 4
if τ_i ∈ e: split e at τ_i; graded Gauss rule t = τ_i ± d w^m for u*, plain Gauss on each part for q* - 5
else: the same g-point Gauss rule on e for both kernels - 6
for each rule point t with weight ω: add u*(x_i, C(t)) R_j(t) |C'(t)| ω to G[i, j] and the same with q* to H[i, j] - 7
H[i, j] ← H[i, j] + ½ R_j(τ_i) ▷ the free term - 8
solve Σ_j R_j(τ_i) u_j = g(x_i) for the coefficients u of the data - 9
solve G q = H u and return q
Line L4 handles the log singularity of . On each side of , of length , the substitution with turns into and multiplies it by , which is bounded and smooth enough for Gauss rules in . The code uses and 16 points. The element test checks both and , because the collocation point at also ends the last element at . Line L8 takes the Dirichlet data into the basis by interpolation at the same points, so that is the left side of the integral equation. For a Neumann problem, is given and lines L8 and L9 change roles. For mixed data the columns of known and unknown values are swapped.
Geometry refinement. The basis is refined by knot insertion with Boehm's algorithm applied to the homogeneous control points , which leaves the curve exactly unchanged.
Example
The circle. Take the circle of radius as the exact quadratic NURBS with 9 control points, the knots and the weights . On the circle, , so is constant, and .
- Constant data. For , each row of is , so . The code returns .
- Data in the space. For , the flux is . Both are NURBS of the basis, because and are. The code returns the exact control values of to about , the error of the quadrature.
- A smooth solution not in the space. For , the flux is . Uniform knot insertion gives:
| elements | unknowns | max error of | error of at |
|---|---|---|---|
| 4 | 8 | ||
| 8 | 12 | ||
| 16 | 20 | ||
| 32 | 36 | ||
| 64 | 68 |
From 16 to 64 elements the flux error falls by about 8 per halving of the element size, an observed order 3, and the interior error by about 16, an observed order 4. These are measurements on this problem. The interior value comes from the representation formula with and , which smooths the boundary error.
An ellipse. The same circle scaled by is an ellipse, still an exact NURBS with the same weights. There is not constant, and for the flux error falls from to when the elements go from 16 to 32.
Correctness
Three things are proved on the proof page. First, the integral equation holds for the exact solution, and on the circle the operators are diagonal in Fourier modes: and for . So the single layer operator of a circle is invertible if and only if . Second, the discrete system is consistent: if the exact and are both in the spline space, they satisfy the collocation equations exactly, so if the matrices of lines L8 and L9 are non-singular, the method returns them. This is what the test with checks. Third, gives for every closed smooth curve, from .
The non-singularity of the discrete matrix and the convergence order are not proved here. The table measures them.
Proof: The boundary integral equation on a circle, its degenerate scale, and the consistency of IGABEM collocationfull
We use the notation of the page: , , and . The boundary integral equation is on a smooth closed curve . We take it as known from Green's second identity, as derived on the page.
Lemma 1 (the double layer of a constant). For a smooth closed curve and , .
Proof. The function is harmonic with . The boundary integral equation gives .
Lemma 2 (the circle). Let be the circle of radius about the origin, with and . Then
- for , so , where is the mean of over ;
- , and for each integer .
Proof. (1) The outward normal at is , and , so and . So , and . With , .
(2) , and for the Fourier series holds, as the real part of on , , with convergence in . So
Multiply by and integrate over ; the convergence allows term by term integration against the bounded function . For only the constant term remains, and it gives . For only the term remains, with , which gives .
Theorem 1 (solvability on the circle and the degenerate scale). On the circle of radius , is injective on if and only if . For and the Dirichlet data , the equation has the unique solution with the Fourier coefficients and for , which is the exact flux .
Proof. By Lemma 2, multiplies the Fourier coefficient of index by for and by for . A multiplier operator is injective if and only if no multiplier is zero, and exactly for . For the right side, Lemma 2 gives , whose coefficients are for and for . Dividing by the multipliers gives the stated . The harmonic function with boundary values is , and at has the coefficients , so the solution is the exact flux.
For this gives , the value used in the test. For , , so the constant density is in the kernel and the Dirichlet problem cannot be solved through alone. This is the degenerate scale of the Pitfalls.
Theorem 2 (consistency of the collocation). Let be a smooth closed NURBS curve and let the collocation points be smooth points of . Suppose the exact solution has and in the merged basis. If the matrix of line L8 and the matrix of line L9 are non-singular, and the integrals of lines L3 to L7 are exact, then IGABEM-DIRICHLET returns .
Proof. Line L8 solves . The vector satisfies it, because , and is non-singular, so . With exact integrals, row of is and row of is , by linearity of the integrals in the coefficients. The boundary integral equation holds at every smooth point of , so . is non-singular, so line L9 returns .
On the circle, and for the control points , because a NURBS curve is the weighted sum of its control points. The function is harmonic, and its flux is by . Both lie in the space, so Theorem 2 applies: the method returns the control values of . The test checks this with , , , where the only error left is that of the quadrature.
Corollary (constant data). For on any smooth closed curve, by the partition of unity, and with exact integrals by Lemma 1. So if is non-singular, .
What is not proved here. The non-singularity of the discrete for and the rate of convergence when is not in the spline space are not proved. The page measures an order of about 3 for the largest flux error and about 4 at an interior point, for quadratic NURBS on the circle.
Complexity
In the real RAM model, with unknowns, about elements and Gauss points per element:
- Assembly. Each pair (collocation point, element) costs kernel evaluations, each adding to entries. The regular rules do not depend on the point, so the curve is evaluated once per element. The total is , with two extra graded rules per row. The code evaluates full basis rows, an extra factor in that step, which is fine for the tests.
- Solve. is dense and not symmetric, so Gaussian elimination costs time and the matrices space.
A 3D problem has unknowns on a surface, against about for a volume mesh of the same resolution, but the dense matrix makes plain BEM cost memory. Large problems use fast methods, such as the fast multipole method or hierarchical matrices, which reduce this to nearly .
Properties
- Exact geometry and boundary only. The analysis uses the CAD boundary without change. A trimmed CAD solid also only needs its boundary, see trimmed isogeometric analysis.
- Dense, non-symmetric matrix. Every point sees every element.
- Exterior problems (unbounded domains) need no truncation, because the fundamental solution has the right behavior at infinity.
- Singular integrals. The diagonal blocks need special rules, and their accuracy limits the whole method.
- Linear, constant coefficient equations only. The method needs a fundamental solution.
Variants and improvements
- Galerkin BEM. Test the integral equation against the basis instead of collocating. The matrix of is then symmetric, and positive definite when the logarithmic capacity of is below 1 (for a circle, ), at the cost of double integrals.
- Other equations. Elastostatics (Simpson and coauthors 2012), Helmholtz for acoustics, and Stokes flow, each with its fundamental solution.
- T-spline and trimmed boundaries. 3D IGABEM works directly on T-spline surfaces and on trimmed NURBS surfaces.
- Fast methods. Fast multipole methods and hierarchical matrices compress the dense blocks.
When to use it
Use it for linear problems with a known fundamental solution when the model comes from CAD and a volume mesh is costly: exterior acoustics and potential flow, electrostatics, and elasticity of solids when only the boundary is of interest. Use volume isogeometric or finite element analysis for nonlinear materials, variable coefficients and volume sources, which need a volume integral.
Pitfalls
- The degenerate scale. In 2D, is not invertible when the logarithmic capacity of is 1, and for a circle that means : then . The test with shows that the constant vector is in the kernel of the discrete to . Scale the geometry, or add the condition with an extra unknown.
- Singular quadrature. Plain Gauss on the element that holds the collocation point converges slowly on . Use a graded rule, subtraction of the singularity, or a special log rule.
- Points at corners. At a corner the free term is not but the inner angle over , and the normal jumps. Do not collocate at corners with the smooth formula, or move the point inside an element.
- The seam of a closed curve. The parameter and are the same point. Merge the two basis functions and treat the singular element on both sides.
- Nearly singular integrals. Interior points close to the boundary need refined rules, as in line L4.
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 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_boundary_element_method.py 193 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/isogeometric-boundary-element-method/. The authors are listed in prov/JQY36Z.jsonl.
"""Isogeometric boundary element method for the 2D Laplace equation.
The boundary is a closed NURBS curve, counterclockwise, with an open knot
vector on [0, 1] whose first and last control points coincide. The same
NURBS basis, with the first and last functions merged into one, carries the
boundary values u and the normal derivatives q = du/dn. Collocation at the
images of the Greville abscissae gives the square system H u = G q of the
boundary integral equation
(1/2) u(x) + int q*(x, y) u(y) ds_y = int u*(x, y) q(y) ds_y,
with u* = -(1/2 pi) ln r and q* = -(1/2 pi) (r . n_y) / r^2, r = y - x.
"""
from __future__ import annotations
import math
from typing import Callable, List, Sequence, Tuple
from ig2kit import all_basis, gauss_legendre, greville, solve_dense
Point = Tuple[float, float]
def circle_nurbs(radius: float, sx: float = 1.0, sy: float = 1.0):
"""Exact quadratic NURBS of the circle of this radius (an ellipse if sx != sy).
Returns (degree, knots, control points, weights), counterclockwise from (radius sx, 0).
"""
r = radius
pts = [(r, 0), (r, r), (0, r), (-r, r), (-r, 0), (-r, -r), (0, -r), (r, -r), (r, 0)]
pts = [(sx * x, sy * y) for x, y in pts]
h = math.sqrt(0.5)
w = [1, h, 1, h, 1, h, 1, h, 1]
knots = [0, 0, 0, 0.25, 0.25, 0.5, 0.5, 0.75, 0.75, 1, 1, 1]
return 2, [float(k) for k in knots], [(float(x), float(y)) for x, y in pts], [float(v) for v in w]
def insert_knot(p: int, knots: List[float], pts: List[Point], w: List[float], t: float):
"""Boehm insertion of one knot t, done on the homogeneous points (w x, w y, w)."""
k = max(i for i in range(len(knots) - 1) if knots[i] <= t < knots[i + 1])
hom = [(wi * x, wi * y, wi) for (x, y), wi in zip(pts, w)]
new = []
for i in range(len(hom) + 1):
if i <= k - p:
new.append(hom[i])
elif i >= k + 1:
new.append(hom[i - 1])
else:
a = (t - knots[i]) / (knots[i + p] - knots[i])
new.append(tuple(a * hom[i][c] + (1 - a) * hom[i - 1][c] for c in range(3)))
knots = knots[: k + 1] + [t] + knots[k + 1 :]
return knots, [(X / W, Y / W) for X, Y, W in new], [W for _, _, W in new]
def refine(p, knots, pts, w, per_span: int):
"""Insert per_span - 1 equally spaced knots in each non-empty knot span."""
spans = [(knots[i], knots[i + 1]) for i in range(len(knots) - 1) if knots[i] < knots[i + 1]]
for a, b in spans:
for k in range(1, per_span):
knots, pts, w = insert_knot(p, knots, pts, w, a + (b - a) * k / per_span)
return knots, pts, w
class Curve:
"""A closed NURBS curve with the periodic (merged) basis."""
def __init__(self, p, knots, pts, w):
self.p, self.knots, self.pts, self.w = p, knots, pts, w
self.n = len(pts) - 1 # number of unknowns after merging the first and the last function
def eval(self, t: float):
"""(point, unit tangent speed |C'|, outward normal, merged basis row) at parameter t."""
d = all_basis(self.knots, self.p, t, 1)
wn = [wi * v for wi, v in zip(self.w, d[0])]
wd = [wi * v for wi, v in zip(self.w, d[1])]
W, Wd = sum(wn), sum(wd)
R = [v / W for v in wn]
Rd = [(a * W - b * Wd) / (W * W) for a, b in zip(wd, wn)]
x = sum(r * P[0] for r, P in zip(R, self.pts))
y = sum(r * P[1] for r, P in zip(R, self.pts))
dx = sum(r * P[0] for r, P in zip(Rd, self.pts))
dy = sum(r * P[1] for r, P in zip(Rd, self.pts))
jac = math.hypot(dx, dy)
row = R[:-1]
row[0] += R[-1]
return (x, y), jac, (dy / jac, -dx / jac), row
def elements(self) -> List[Tuple[float, float]]:
k = self.knots
return [(k[i], k[i + 1]) for i in range(len(k) - 1) if k[i] < k[i + 1]]
def kernels(x: Point, y: Point, ny: Point) -> Tuple[float, float]:
"""(u*, q*) of the 2D Laplace equation for the source x and the field point y."""
rx, ry = y[0] - x[0], y[1] - x[1]
r2 = rx * rx + ry * ry
return -math.log(r2) / (4 * math.pi), -(rx * ny[0] + ry * ny[1]) / (2 * math.pi * r2)
def _rule(a: float, b: float, gx, gw):
return [(0.5 * (a + b) + 0.5 * (b - a) * s, 0.5 * (b - a) * v) for s, v in zip(gx, gw)]
def _graded(ts: float, d: float, m: int, gx, gw):
"""Rule on [ts, ts + d] (d of either sign) with t = ts + d w^m, w in (0, 1): it removes the log singularity at ts."""
out = []
for s, v in zip(gx, gw):
u = 0.5 * (s + 1)
out.append((ts + d * u**m, abs(d) * m * u ** (m - 1) * 0.5 * v))
return out
def assemble(curve: Curve, ng: int = 12, ngs: int = 16, m: int = 4):
"""Collocation points and the matrices H and G of the boundary integral equation."""
n = curve.n
gx, gw = gauss_legendre(ng)
sx, sw = gauss_legendre(ngs)
tau = greville(curve.knots, curve.p)[:-1] # @line L2
src = [curve.eval(t) for t in tau]
els = curve.elements()
# The regular rule of each element does not depend on the source: evaluate it once.
regular = [[(curve.eval(t), wt) for t, wt in _rule(a, b, gx, gw)] for a, b in els]
H = [[0.0] * n for _ in range(n)]
G = [[0.0] * n for _ in range(n)]
for i, (ts, (xi, _, _, rowi)) in enumerate(zip(tau, src)): # @line L3
for e, (a, b) in enumerate(els):
hits = [s for s in (ts, ts + 1.0) if a <= s <= b]
if hits: # @line L4
s0 = hits[0]
qu = [] # rule for u*: graded toward s0
qq = [] # rule for q*: plain Gauss on both sides of s0
for d in (a - s0, b - s0):
if d != 0:
qu += _graded(s0, d, m, sx, sw)
qq += _rule(s0, s0 + d, gx, gw) if d > 0 else _rule(s0 + d, s0, gx, gw)
pts_u = [(curve.eval(t), wt) for t, wt in qu]
pts_q = [(curve.eval(t), wt) for t, wt in qq]
else:
pts_u = pts_q = regular[e] # @line L5
for (y, jac, ny, row), wt in pts_u:
us, _ = kernels(xi, y, ny)
c = us * jac * wt
for j, rj in enumerate(row):
if rj:
G[i][j] += c * rj # @line L6
for (y, jac, ny, row), wt in pts_q:
_, qs = kernels(xi, y, ny)
c = qs * jac * wt
for j, rj in enumerate(row):
if rj:
H[i][j] += c * rj
for j in range(n):
H[i][j] += 0.5 * rowi[j] # @line L7
return tau, src, H, G
def solve_dirichlet(curve: Curve, g: Callable[[float, float], float], **quad):
"""Given u = g on the boundary, return (coefficients of u, coefficients of q, tau, src, H, G)."""
n = curve.n # @line L1
tau, src, H, G = assemble(curve, **quad)
C = [s[3] for s in src]
u = solve_dense(C, [g(*s[0]) for s in src]) # @line L8
rhs = [sum(H[i][j] * u[j] for j in range(n)) for i in range(n)]
q = solve_dense(G, rhs) # @line L9
return u, q, tau, src, H, G
def flux_at(curve: Curve, q: Sequence[float], t: float) -> float:
"""q_h(t) = sum_j R_j(t) q_j."""
return sum(r * c for r, c in zip(curve.eval(t)[3], q))
def interior_value(curve: Curve, u: Sequence[float], q: Sequence[float], x: Point, ng: int = 24) -> float:
"""Representation formula u(x) = int u* q - int q* u for an interior point x."""
gx, gw = gauss_legendre(ng)
total = 0.0
for a, b in curve.elements():
for t, wt in _rule(a, b, gx, gw):
y, jac, ny, row = curve.eval(t)
us, qs = kernels(x, y, ny)
uh = sum(r * c for r, c in zip(row, u))
qh = sum(r * c for r, c in zip(row, q))
total += (us * qh - qs * uh) * jac * wt
return total
def refined_circle(radius: float, per_span: int, sx: float = 1.0, sy: float = 1.0) -> Curve:
p, k, P, w = circle_nurbs(radius, sx, sy)
k, P, w = refine(p, k, P, w, per_span)
return Curve(p, k, P, w)
test_isogeometric_boundary_element_method.py 95 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/isogeometric-boundary-element-method/. The authors are listed in prov/JQY36Z.jsonl.
import math
import random
from isogeometric_boundary_element_method import (
flux_at,
interior_value,
refined_circle,
solve_dirichlet,
)
def flux_error(curve, q, grad, samples=400):
"""Largest |q_h - dg/dn| over equally spaced parameters."""
worst = 0.0
for k in range(samples):
t = k / samples
(x, y), _, n, _ = curve.eval(t)
gx, gy = grad(x, y)
worst = max(worst, abs(flux_at(curve, q, t) - (gx * n[0] + gy * n[1])))
return worst
def test_refined_geometry_is_exact() -> None:
rng = random.Random(5)
for per_span in (1, 3, 8):
c = refined_circle(2.0, per_span)
for _ in range(200):
(x, y), _, n, row = c.eval(rng.random())
assert abs(math.hypot(x, y) - 2.0) < 1e-12
assert abs(n[0] * x + n[1] * y - 2.0) < 1e-12 # outward unit normal
assert abs(sum(row) - 1.0) < 1e-12 # partition of unity of the merged basis
def test_single_layer_of_a_constant() -> None:
"""On a circle of radius R, int u*(x, y) ds_y = -R ln R for x on the circle."""
for radius in (2.0, 0.5):
c = refined_circle(radius, 4)
_, _, _, _, _, G = solve_dirichlet(c, lambda x, y: 0.0)
for row in G:
assert abs(sum(row) + radius * math.log(radius)) < 1e-7
def test_degenerate_scale_radius_one() -> None:
"""Pitfall: for R = 1 the constant is in the kernel of the single layer, so G is (nearly) singular."""
c = refined_circle(1.0, 4)
_, _, _, _, _, G = solve_dirichlet(c, lambda x, y: 0.0)
assert max(abs(sum(row)) for row in G) < 1e-7
assert max(abs(v) for row in G for v in row) > 1e-2
def test_constant_data_gives_zero_flux() -> None:
c = refined_circle(2.0, 4)
_, q, _, _, _, _ = solve_dirichlet(c, lambda x, y: 1.0)
assert max(abs(v) for v in q) < 1e-7
def test_exact_when_data_and_flux_are_in_the_space() -> None:
"""u = x + 2 y on the circle of radius 2 has q = (x + 2 y) / 2, and both are NURBS of the basis."""
for per_span in (1, 2, 4):
c = refined_circle(2.0, per_span)
u, q, _, _, _, _ = solve_dirichlet(c, lambda x, y: x + 2 * y)
for uj, qj, (px, py) in zip(u, q, c.pts):
assert abs(uj - (px + 2 * py)) < 1e-12
assert abs(qj - (px + 2 * py) / 2) < 1e-7 # only the quadrature error is left
def test_circle_against_exact_solution() -> None:
"""u = x^2 - y^2 on the circle of radius 2: q = 2 R cos(2 theta)."""
g = lambda x, y: x * x - y * y
grad = lambda x, y: (2 * x, -2 * y)
errs = []
for per_span in (4, 8, 16):
c = refined_circle(2.0, per_span)
u, q, _, _, _, _ = solve_dirichlet(c, g)
errs.append(flux_error(c, q, grad))
if per_span == 8:
assert abs(interior_value(c, u, q, (0.5, 0.3)) - 0.16) < 1e-5
assert errs[1] < 3e-3
rates = [math.log2(errs[k] / errs[k + 1]) for k in range(2)]
assert all(r > 2.7 for r in rates), rates
def test_ellipse_against_exact_solution() -> None:
g = lambda x, y: x * x - y * y + 0.5 * x * y + x
grad = lambda x, y: (2 * x + 0.5 * y + 1, -2 * y + 0.5 * x)
errs = []
for per_span in (4, 8):
c = refined_circle(2.0, per_span, 1.0, 0.75)
u, q, _, _, _, _ = solve_dirichlet(c, g)
errs.append(flux_error(c, q, grad))
assert errs[1] < 5e-3 and errs[0] / errs[1] > 6
assert abs(interior_value(c, u, q, (0.5, 0.3)) - g(0.5, 0.3)) < 1e-4
History
Boundary integral equations for potential problems go back to the nineteenth century, and the boundary element method as a numerical method developed from the 1960s. Politis, Ginnis, Kaklis, Belibassakis and Feurer (2009) used the NURBS basis of the boundary curve for a 2D exterior potential flow BEM. Simpson, Bordas, Trevelyan and Rabczuk (2012) gave a 2D IGABEM for elastostatics with collocation at the Greville abscissae, and later work extended the idea to 3D with T-splines and to trimmed surfaces. Marussig and Hughes (2018) list boundary methods among the ways to analyze trimmed CAD models without a volume parameterization.
References
- R. N. Simpson, S. P. A. Bordas, J. Trevelyan and T. Rabczuk, A two-dimensional isogeometric boundary element method for elastostatic analysis, Computer Methods in Applied Mechanics and Engineering 209-212, 2012, 87 to 100, the whole paper (the NURBS basis of the boundary for both the geometry and the fields, collocation at the Greville abscissae, the singular integrals and the comparison with Lagrange BEM)
- C. Politis, A. I. Ginnis, P. D. Kaklis, K. Belibassakis and C. Feurer, An isogeometric BEM for exterior potential-flow problems in the plane, 2009 SIAM/ACM Joint Conference on Geometric and Physical Modeling, 2009, 349 to 354, the whole paper, the first use of the NURBS basis of the boundary in a BEM
- T. J. R. Hughes, J. A. Cottrell and Y. Bazilevs, Isogeometric analysis, CAD, finite elements, NURBS, exact geometry and mesh refinement, Computer Methods in Applied Mechanics and Engineering 194(39-41), 2005, 4135 to 4195, the isogeometric idea of one basis for geometry and analysis, and the NURBS circle
- B. Marussig and T. J. R. Hughes, A review of trimming in isogeometric analysis, challenges, data exchange and simulation aspects, Archives of Computational Methods in Engineering 25(4), 2018, 1059 to 1127, the part on boundary methods, which need only the boundary representation of a trimmed CAD model
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 JQY36Z Edit this page History Report an error Markdown