remesh

Contents

remesh#

Mesh.remesh(target, strict=True)[source]#

Return per-axis flags indicating which axes require averaging.

An axis needs remeshing when the source is on the half mesh (1) and the target is on the main mesh (0). By default, requesting a main-to-half transition (upsampling) raises a ValueError.

Parameters:
targetMeshLike | None

Desired output stagger; coerced to Mesh via _coerce_mesh_target() if necessary. None is treated as self (no-op: returns all False).

strictbool, optional

If True (default), raise ValueError when any axis in target is on the half mesh but the corresponding axis in self is already on the main mesh (main → half is not supported). Set to False to silently ignore such axes.

Returns:
outtuple[bool, …]

Tuple of per-axis boolean flags in logical axis order (MSB first). True at position i means axis i must be averaged (half → main); False means no averaging is needed on that axis.

Raises:
ValueError

If strict is True and target requests a half-mesh axis where self is already on the main mesh.

Examples

>>> from psi_io.mesh import Mesh
>>> src = Mesh.parse(0b111, ndim=3)   # all-half
>>> src.remesh('main')
(True, True, True)
>>> src.remesh(None)                   # no-op: target == self
(False, False, False)
>>> src.remesh(0b101)                  # only theta needs averaging
(False, True, False)