Peano
Loading...
Searching...
No Matches
SFC Namespace Reference

Peano space-filling curve as Peano's spacetree traversal runs through it. More...

Functions

bool _is_traversal_positive_along_axis (tuple even_flags, int axis)
 Python counterpart of peano4::grid::PeanoCurve::isTraversePositiveAlongAxis() for a non-inverted traversal.
 
tuple _children_in_traversal_order (tuple directions)
 The 3^d children of a cell in the order of peano4::utils::zfor3.
 
tuple _child_even_flags (tuple even_flags, tuple child)
 Even flags of a child: the middle child along an axis inverts this axis' flag.
 
int _cartesian_to_peano (tuple coordinates, int size)
 
tuple _peano_to_cartesian (int peano_index, int size, int dimensions)
 
int Cartesian_to_Peano_2d (tuple[int, int] coordinates, int size)
 Map Cartesian index to Peano SFC index.
 
int Cartesian_to_Peano_3d (tuple[int, int, int] coordinates, int size)
 Map 3-D Cartesian index to Peano SFC index.
 
tuple[int, int] Peano_to_Cartesian_2d (int peano_index, int size)
 Inverse of Cartesian_to_Peano_2d.
 
tuple[int, int, int] Peano_to_Cartesian_3d (int peano_index, int size)
 Inverse of Cartesian_to_Peano_3d.
 

Detailed Description

Peano space-filling curve as Peano's spacetree traversal runs through it.

The routines replicate the traversal order of peano4::grid::Spacetree, i.e. they do not implement an arbitrary Peano curve but exactly the one that Peano's C++ core uses. The offline load balancing hence plans along the same order in which Peano later hands out cells throughout a split.

The order is defined recursively. The root cell starts with all even flags unset. A cell runs through its \( 3^d \) children in a serpentine (boustrophedon) order: axis 0 is the fastest axis, axis d-1 the slowest one. Along each axis, the cell runs in positive direction if the number of even flags set for the other axes is even (peano4::grid::PeanoCurve::isTraversePositiveAlongAxis()), and the serpentine then alternates the direction of all faster axes (peano4::utils::zfor3). A child inherits the even flags of its parent, but the middle child along an axis inverts the flag of this axis (peano4::grid::Spacetree::refineState()).

Peano inverts the whole traversal in every other mesh sweep. The routines here describe the non-inverted traversal. The inverted one runs through the same curve backwards. The offline load balancing ignores this inversion and always plans along the non-inverted curve: A split which Peano carries out in an inverted sweep picks its cells from the other end of the curve, but it still hands over the requested number of cells.

Function Documentation

◆ _cartesian_to_peano()

int SFC._cartesian_to_peano ( tuple  coordinates,
int  size 
)
protected

Definition at line 72 of file SFC.py.

References _child_even_flags(), and _is_traversal_positive_along_axis().

Referenced by Cartesian_to_Peano_2d(), and Cartesian_to_Peano_3d().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _child_even_flags()

tuple SFC._child_even_flags ( tuple  even_flags,
tuple  child 
)
protected

Even flags of a child: the middle child along an axis inverts this axis' flag.

Definition at line 67 of file SFC.py.

Referenced by _cartesian_to_peano(), and _peano_to_cartesian().

Here is the caller graph for this function:

◆ _children_in_traversal_order()

tuple SFC._children_in_traversal_order ( tuple  directions)
protected

The 3^d children of a cell in the order of peano4::utils::zfor3.

Parameters
directionstuple of bool One flag per axis: True means that the traversal runs in positive direction along this axis.

Definition at line 46 of file SFC.py.

◆ _is_traversal_positive_along_axis()

bool SFC._is_traversal_positive_along_axis ( tuple  even_flags,
int  axis 
)
protected

Python counterpart of peano4::grid::PeanoCurve::isTraversePositiveAlongAxis() for a non-inverted traversal.

Definition at line 35 of file SFC.py.

Referenced by _cartesian_to_peano(), and _peano_to_cartesian().

Here is the caller graph for this function:

◆ _peano_to_cartesian()

tuple SFC._peano_to_cartesian ( int  peano_index,
int  size,
int  dimensions 
)
protected

Definition at line 93 of file SFC.py.

References _child_even_flags(), and _is_traversal_positive_along_axis().

Referenced by Peano_to_Cartesian_2d(), and Peano_to_Cartesian_3d().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cartesian_to_Peano_2d()

int SFC.Cartesian_to_Peano_2d ( tuple[int, int]  coordinates,
int  size 
)

Map Cartesian index to Peano SFC index.

This operation accepts a Cartesian index and returns the position of this cell along Peano's traversal (see the file documentation). In the example below

we can hand in (4,2) and get a 10 back.

Args: coordinates: (x, y) index with entries in [0, size-1] size: Side length of the square grid; must be a power of 3.

Returns: Integer Peano SFC index in [0, size*size - 1].

Definition at line 120 of file SFC.py.

References _cartesian_to_peano().

Here is the call graph for this function:

◆ Cartesian_to_Peano_3d()

int SFC.Cartesian_to_Peano_3d ( tuple[int, int, int]  coordinates,
int  size 
)

Map 3-D Cartesian index to Peano SFC index.

Three-dimensional counterpart of Cartesian_to_Peano_2d.

Args: coordinates: (x, y, z) index with entries in [0, size-1] size: Side length of the cubic grid; must be a power of 3.

Returns: Integer Peano SFC index in [0, size**3 - 1].

Definition at line 143 of file SFC.py.

References _cartesian_to_peano().

Here is the call graph for this function:

◆ Peano_to_Cartesian_2d()

tuple[int, int] SFC.Peano_to_Cartesian_2d ( int  peano_index,
int  size 
)

Inverse of Cartesian_to_Peano_2d.

Args: peano_index: SFC index in [0, size*size - 1]. size: Side length of the square grid; must be a power of 3.

Returns: (x, y) Cartesian coordinates.

Definition at line 160 of file SFC.py.

References _peano_to_cartesian().

Referenced by 35_offline-load-balancing-plan-vs-run.draw(), and 35_offline-load-balancing-split-modes.read_subdomains().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Peano_to_Cartesian_3d()

tuple[int, int, int] SFC.Peano_to_Cartesian_3d ( int  peano_index,
int  size 
)

Inverse of Cartesian_to_Peano_3d.

Args: peano_index: SFC index in [0, size**3 - 1]. size: Side length of the cubic grid; must be a power of 3.

Returns: (x, y, z) Cartesian coordinates.

Definition at line 176 of file SFC.py.

References _peano_to_cartesian().

Here is the call graph for this function: