Mesh

Contents

Mesh#

class Mesh(*values)[source]#

Bases: Enum

Enum identifying the stagger position of one array axis.

MAS and POT3D solve their equations on Yee-type staggered spherical grids. Each axis of a multi-dimensional output array is independently classified as MAIN (cell-center position) or HALF (cell-face/edge position, displaced by half a grid spacing along that axis).

The stagger arrangement is physically motivated:

  • Magnetic field components (\(B_r\), \(B_\theta\), \(B_\varphi\)) are face-centred — each component lives on the face through which it is the outward normal — so that \(\nabla \cdot \mathbf{B} = 0\) is satisfied exactly at the discrete level.

  • Current density components follow from \(\mathbf{J} = \nabla \times \mathbf{B}\) and are therefore edge-centred (half mesh on the two transverse axes).

  • Scalar quantities (temperature, density, pressure) occupy the cell corners, which correspond to the half-mesh position on all three axes (0b111).

Mesh members appear as elements of the normalized mesh tuple returned by mesh and accepted by remesh_array().

Attributes:
MAINint

Cell-center mesh position; encoded as 0.

HALFint

Cell-face/edge mesh position, offset by half a grid spacing; encoded as 1.

Examples

>>> from psi_io._mesh import Mesh
>>> Mesh.MAIN.value
0
>>> Mesh.HALF.value
1
>>> Mesh('half')
<Mesh.HALF: 1>
>>> Mesh('m')
<Mesh.MAIN: 0>
>>> str(Mesh.HALF)
'HALF'