Skip to content
Projects

Hierarchy

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

AMRHierarchy

classsource

A 1D or 2D nested patch hierarchy with mpiarray-backed fields.

levels
hL=h0rL,r≥2 on every axis and levelh_L = \frac{h_0}{r^L}, \qquad r \ge 2 \text{ on every axis and level}
nesting
loL≡hiL≡0(modr),[loLr,hiLr)⊂⋃patches of L−1box\mathrm{lo}_L \equiv \mathrm{hi}_L \equiv 0 \pmod r, \qquad \Big[\tfrac{\mathrm{lo}_L}{r}, \tfrac{\mathrm{hi}_L}{r}\Big) \subset \bigcup_{\text{patches of } L-1} \text{box}
ring volume
V=2πrc Δr Δz,rc=12(r0+r1)V = 2\pi r_c\,\Delta r\,\Delta z, \qquad r_c = \tfrac12 (r_0 + r_1)
radial face
Ar=2πrf ΔzA_r = 2\pi r_f\,\Delta z
axial face
Az=π(r12−r02)=2πrc ΔrA_z = \pi (r_1^2 - r_0^2) = 2\pi r_c\,\Delta r
plane
V=Δx Δy,A=Δy or Δx (2D);V=Δx,A=1 (1D)V = \Delta x\,\Delta y, \quad A = \Delta y \text{ or } \Delta x \ \text{(2D)}; \qquad V = \Delta x, \quad A = 1 \ \text{(1D)}
Assumes
  • one refinement ratio rr for all axes and levels; patch boxes half open, in cells of their level
  • proper nesting by a margin is not required by add_patch; regrid enforces it
  • in (r,z)(r, z): 2D, r0≥0r_0 \ge 0, the radius not periodic; the ring volumes and areas are exact, so the faces of a cell close it and fine faces add up to the coarse one

deposit

functionsource

Deposit the charge of markers on the node-centered field name, patch by patch.

cloud in cell
q00=q(1−ξ)(1−η),q10=q ξ(1−η),q01=q(1−ξ) η,q11=q ξη,ξ=x−xihx, η=y−yjhyq_{00} = q(1-\xi)(1-\eta), \quad q_{10} = q\,\xi(1-\eta), \quad q_{01} = q(1-\xi)\,\eta, \quad q_{11} = q\,\xi\eta, \qquad \xi = \frac{x - x_i}{h_x}, \ \eta = \frac{y - y_j}{h_y}
line
q0=q(1−ξ),q1=q ξq_0 = q(1-\xi), \qquad q_1 = q\,\xi
splines
qk=q∏dBp(rd−kd),rd=xd−xd,0hd(degree p; p=1 above)q_{\mathbf k} = q \prod_d B_p(r_d - k_d), \qquad r_d = \frac{x_d - x_{d,0}}{h_d} \quad (\text{degree } p; \ p = 1 \text{ above})
gather
E(x)=∑corners cwc(x) Ec(the transpose: interpolate)E(\mathbf{x}) = \sum_{\text{corners } c} w_c(\mathbf{x})\,E_c \quad (\text{the transpose: } \texttt{interpolate})
Assumes
  • each marker in the finest patch that holds it; the values are charges, not a density
  • a marker gathers the field of its own patch, which may jump at a coarse-fine edge
  • the halos and the copies of shared nodes are summed afterwards (accumulate_halos)
  • from degree 2 on a stencil folds onto the edge nodes of the marker's patch where it would reach past them (at coarse-fine edges, walls and periodic seams alike): the charge is kept, the shape there is not the spline's
Built from

regrid

functionsource

A new hierarchy with patches over the tagged cells, and the fields moved to it.

grow
T~L=growb(TL∪coarsenr(growm(T~L+1)))∩ΩL,L=Lmax,…,0\tilde T_L = \mathrm{grow}_{b}\Big(T_L \cup \mathrm{coarsen}_r\big(\mathrm{grow}_{m}(\tilde T_{L+1})\big)\Big) \cap \Omega_L, \qquad L = L_\mathrm{max}, \dots, 0
allowed
AL=shrinkm(⋃new boxes of L)∖{cells with forbidden fine cells}\mathcal{A}_L = \mathrm{shrink}_{m}\big(\textstyle\bigcup \text{new boxes of } L\big) \setminus \{\text{cells with forbidden fine cells}\}
boxes
BL+1=r⋅cluster(T~L∩AL)B_{L+1} = r \cdot \mathrm{cluster}\big(\tilde T_L \cap \mathcal{A}_L\big)
transfer
unew={uoldon an old patch of the levelI(uL−1new)elseu^\mathrm{new} = \begin{cases} u^\mathrm{old} & \text{on an old patch of the level} \\ \mathcal{I}(u^\mathrm{new}_{L-1}) & \text{else} \end{cases}
Assumes
  • bb = buffer, mm = nesting (cells of the level below; the domain's edge does not count as an edge)
  • I\mathcal{I} the bilinear (renormalised) interpolation, or for a conservative field the conservative fill after a restriction
  • the base level is kept; levels above the last tagged one are dropped
  • halos stay zero unless fill_halos
References
Built from