Skip to content
Projects

Halos and restriction

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

_key

functionsource

A patch as its level, box and ranks: the same in the hierarchies a regrid makes.

same level
uhalo=u of a patch of the same level (periodic images included)u_\mathrm{halo} = u \text{ of a patch of the same level (periodic images included)}
position
X=if+12r−12 (cells),X=ifr (nodes)X = \frac{i_f + \frac12}{r} - \frac12 \ \text{(cells)}, \qquad X = \frac{i_f}{r} \ \text{(nodes)}
bilinear
uf=∑c∈{0,1}dwc uc∑c availablewc,wc=∏a(caλa+(1−ca)(1−λa)),λ=X−⌊X⌋u_f = \sum_{c \in \{0,1\}^d} \frac{w_c\, u_c}{\sum_{c\ \text{available}} w_c}, \qquad w_c = \prod_a \big(c_a \lambda_a + (1 - c_a)(1 - \lambda_a)\big), \quad \lambda = X - \lfloor X \rfloor
Order
2
Assumes
  • coarse points on no patch are dropped and the weights renormalised; next to a non-periodic wall the stencil is clipped to the two inside points (linear extrapolation)
  • halo points outside the domain are left to the boundary conditions
  • then mpiarray's update_halos within a patch; one Alltoallv per execution
  • the order is that of the interpolated halo values of a smooth field, maximum norm

conservative_from_below

functionsource

Conservative interpolation of the level below at cells index of patch.

fill
uf=uc+∑aσa ξa,ξ=(i mod r)+12r−12u_f = u_c + \sum_a \sigma_a\, \xi_a, \qquad \xi = \frac{(i \bmod r) + \frac12}{r} - \frac12
slope
σ=minmod(2Δ+, 2Δ−, 12(Δ++Δ−)),σ=0 without both neighbours\sigma = \mathrm{minmod}\Big(2\Delta_+,\ 2\Delta_-,\ \tfrac12(\Delta_+ + \Delta_-)\Big), \qquad \sigma = 0 \text{ without both neighbours}
radial shift
ξr→ξr−Δr∑kξk2r rc(r–z)\xi_r \to \xi_r - \frac{\Delta r \sum_k \xi_k^2}{r\, r_c} \quad (r\text{–}z)
mean
∑f⊂cVfuf∑f⊂cVf=uc\frac{\sum_{f \subset c} V_f u_f}{\sum_{f \subset c} V_f} = u_c
Assumes
  • cell-centered fields; the volume-weighted mean of the fine cells of a coarse cell is its value
  • no new extrema (a positive density stays positive); a linear field is reproduced away from walls
References

Restriction

classsource

Give the coarse points under finer patches the fine values of field name.

cells
uc=∑f⊂cVf uf∑f⊂cVfu_c = \frac{\sum_{f \subset c} V_f\, u_f}{\sum_{f \subset c} V_f}
nodes
uc=ufat the coinciding fine nodeu_c = u_f \quad \text{at the coinciding fine node}
Assumes
  • finest level first, or one level; volume-weighted in (r,z)(r, z), a plain mean in the plane
  • only the points of each rank's block are written