Peano
Loading...
Searching...
No Matches
Lexicographic.py
Go to the documentation of this file.
1
# This file is part of the ExaHyPE2 project. For conditions of distribution and
2
# use, please see the copyright notice at www.peano-framework.org
3
"""!
4
5
Legacy lexicographic Cartesian ordering helpers.
6
7
This module provides the standard row-major lexicographic mapping that was
8
used by an earlier version of the leaf distribution before the traversal was
9
switched to Peano SFC order in `SplitTrees.py`.
10
11
This strategy runs through the mesh bottom up. It first assigns all leaves
12
on the finest level to partitions, then the leaves on the next coarser
13
level, and so forth. This strategy is biased towards the finest mesh and
14
particularly valuable for strategies which do more work on the finest level
15
than on other cells. This holds for example for some p-multigrid solvers or
16
ExaHyPE with limiter where the limiter typically kicks in on the finest
17
mesh resolution only.
18
19
We do assign indices per level along the Peano space filling curve. However,
20
whenever we encounter an AMR transition, we stop assigning cells to a rank.
21
That is, if there are 27 connected fine grid cells and each subtree should
22
have 15 cells, then we assign the first 15 cells to tree 0. Tree 1 then
23
get the remaining 27-15 cells. After that, we continue with tree 2. Through
24
this, we avoid that AMR partitions become disconnected:
25
26
@image html distribute_leaves_bottom_up.png
27
28
The ordering itself is straightforward:
29
- 2-D: `(x, y) -> x + y * size`
30
- 3-D: `(x, y, z) -> x + y * size + z * size^2`
31
32
This module keeps the legacy helpers isolated from the SFC utilities so the
33
Peano-specific code can stay focused on SFC order.
34
"""
35
36
37
def
Cartesian_to_lexicographic_2d(
38
coordinates: tuple[int, int],
39
size: int,
40
):
41
"""Map a 2-D Cartesian index to standard lexicographic order."""
42
result = 0
43
base = 1
44
for
i
in
range(0, 2):
45
result += coordinates[i] * base
46
base *= size
47
return
result
48
49
50
def
Cartesian_to_lexicographic_3d(
51
coordinates: tuple[int, int, int],
52
size: int,
53
):
54
"""Map a 3-D Cartesian index to standard lexicographic order."""
55
result = 0
56
base = 1
57
for
i
in
range(0, 3):
58
result += coordinates[i] * base
59
base *= size
60
return
result
src
toolbox
loadbalancing
api
strategies
Lexicographic.py
Generated on Wed Nov 4 2026 08:20:47 for Peano by
1.9.8