Skip to content
Projects

Cell operator

The equations of patchwork.solvers.cell_operator, declared on the code that implements them and checked by the tests.

CellOperator

classsource

Solve −∇⋅(a∇u)+c u=f-\nabla\cdot(a\nabla u) + c\,u = f on the leaf cells of a hierarchy.

problem
−∇⋅(a∇u)+c u=f,a≥0,c∈R or C-\nabla\cdot(a\nabla u) + c\,u = f, \qquad a \ge 0, \quad c \in \mathbb{R} \text{ or } \mathbb{C}
curl curl
∇×(a ∇×(Aϕϕ^))+c Aϕ=f,∇×(Aϕϕ^)=(−∂zAϕ, 1r∂r(rAϕ))\nabla\times\big(a\,\nabla\times(A_\phi\hat\phi)\big) + c\,A_\phi = f, \qquad \nabla\times(A_\phi\hat\phi) = \Big(-\partial_z A_\phi,\ \tfrac{1}{r}\partial_r(rA_\phi)\Big)
energy
E(u)=∑faces faf cf (vf⊤u)2+∑cells iciViui2,vf⊤u=w+u+−w−u−,cf=AfdfE(u) = \sum_{\text{faces } f} a_f\,c_f\,(v_f^\top u)^2 + \sum_{\text{cells } i} c_i V_i u_i^2, \qquad v_f^\top u = w_+ u_+ - w_- u_-, \qquad c_f = \frac{A_f}{d_f}
azimuthal conductance
w=r,cf=Afrf rm df(radial face of Aϕ; rm the mean radius of the two values)w = r, \qquad c_f = \frac{A_f}{r_f\, r_m\, d_f} \quad \text{(radial face of } A_\phi\text{; } r_m \text{ the mean radius of the two values)}
face mean
af=2a−a+a−+a+ (harmonic, the default),af=12(a−+a+) (arithmetic)a_f = \frac{2 a_- a_+}{a_- + a_+} \ \text{(harmonic, the default)}, \qquad a_f = \tfrac12(a_- + a_+) \ \text{(arithmetic)}
symmetric coarse fine
u∗=12δ(δ−1) ubelow+(1−δ2) uC+12δ(δ+1) uabove,δ=k+12r−12,df=12(hf+hc)(uniform; on a graded axis the Lagrange weights through the physical centres)u^* = \tfrac12\delta(\delta - 1)\,u_\mathrm{below} + (1 - \delta^2)\,u_C + \tfrac12\delta(\delta + 1)\,u_\mathrm{above}, \qquad \delta = \frac{k + \frac12}{r} - \frac12, \qquad d_f = \tfrac12 (h_f + h_c) \quad \text{(uniform; on a graded axis the Lagrange weights through the physical centres)}
conservative ghost
ughost=1−r3+r uinner+2(r−1)r+1 ufine+8(r+1)(r+3) u∗,F=afAf (wu)ghost−(wu)finehfu_\mathrm{ghost} = \frac{1-r}{3+r}\,u_\mathrm{inner} + \frac{2(r-1)}{r+1}\,u_\mathrm{fine} + \frac{8}{(r+1)(r+3)}\,u^*, \qquad F = a_f A_f\,\frac{(wu)_\mathrm{ghost} - (wu)_\mathrm{fine}}{h_f}
dirichlet wall
Aii+=aAfh/2,bi+=aAfh/2 uDA_{ii} \mathrel{+}= \frac{a A_f}{h/2}, \qquad b_i \mathrel{+}= \frac{a A_f}{h/2}\, u_D
neumann wall
bi+=a Af gb_i \mathrel{+}= a\,A_f\,g
axis
Aii+=4π Δz afor Aϕ=u r/rc on 0<r<rcA_{ii} \mathrel{+}= 4\pi\,\Delta z\,a \quad \text{for } A_\phi = u\,r/r_c \text{ on } 0 < r < r_c
body
Aii+=afreeAfθ df,bi+=afreeAfθ df UkA_{ii} \mathrel{+}= \frac{a_\mathrm{free} A_f}{\theta\, d_f}, \qquad b_i \mathrel{+}= \frac{a_\mathrm{free} A_f}{\theta\, d_f}\, U_k
Order
2
Assumes
  • the matrix is ∂E/∂u\partial E / \partial u up to a factor 2: symmetric, complex symmetric (not Hermitian) for complex cc; the conservative coarse-fine faces make it unsymmetric
  • symmetric coarse-fine faces: second order in the mean, first order in the maximum norm next to a coarse-fine edge; linear or no interpolation where a neighbour along the face is missing, the mirror image beyond a Neumann(0.0) wall or the axis
  • conservative coarse-fine faces: one flux, into the fine cell and out of the coarse one; linear ghost without the next fine cell
  • bodies: a two-point flux to the surface (not Shortley-Weller), about first order in the maximum norm
  • the order is in the volume-weighted L2L_2 norm, for coarse_fine="symmetric" (the default)
  • SuperLU on every rank; variable aa with the azimuthal component is assembled but only constant aa is tested
References
  • D. F. Martin and K. L. Cartwright, Solving Poisson's equation using adaptive mesh refinement, Tech. Rep. UCB/ERL M96/66, UC Berkeley (1996): quadratic coarse-fine interpolation as in coarse_fine="conservative"
Built from

curl

functionsource

The in-plane curl of the field u normal to the plane, (n, 2).

scalar
∇×(u z^)=(∂yu, −∂xu)\nabla\times(u\,\hat z) = (\partial_y u,\ -\partial_x u)
azimuthal
∇×(u ϕ^)=(−∂zu, 1r∂r(ru))\nabla\times(u\,\hat\phi) = \Big(-\partial_z u,\ \frac{1}{r}\partial_r(r u)\Big)
Assumes
  • 2D only; the derivatives of gradient
Built from

gradient

functionsource

The gradient of a scalar u on the leaf cells, (n, ndim); zero in bodies.

face difference
gf=(wu)+−(wu)−dfat the middle of the two valuesg_f = \frac{(wu)_+ - (wu)_-}{d_f} \quad \text{at the middle of the two values}
centre
∂au≈g−o+−g+o−o+−o−,o−<0<o+\partial_a u \approx \frac{g_- o_+ - g_+ o_-}{o_+ - o_-}, \qquad o_- < 0 < o_+
Order
2
Assumes
  • g±g_\pm the face-length weighted means of the estimates on each side of the cell along the axis, at mean offsets o±o_\pm; one side only gives that side's value
  • the operator's own faces: coarse-fine interpolation (or the ghost), walls and surfaces of bodies; zero in bodies
  • exact for linear fields and for Aϕ=Br/2A_\phi = B r / 2; the order is in the maximum norm