@@ -38,17 +38,30 @@ def cell_neighbors_along_axis(mesh: TreeMesh, axis: str) -> np.ndarray:
3838 return np .sort (stencil_indices , axis = 1 )
3939
4040
41- def collect_all_neighbors (neighbors , neighbors_backwards , corners , corners_backwards ):
41+ def collect_all_neighbors (
42+ neighbors : list [np .ndarray ],
43+ neighbors_backwards : list [np .ndarray ],
44+ adjacent : list [np .ndarray ],
45+ adjacent_backwards : list [np .ndarray ],
46+ ) -> np .ndarray :
47+ """
48+ Collect all neighbors for cells in the mesh.
49+
50+ :param neighbors: Direct neighbors in each principle axes.
51+ :param neighbors_backwards: Direct neighbors in reverse order.
52+ :param adjacent: Adjacent neighbors (corners).
53+ :param adjacent_backwards: Adjacent neighbors in reverse order.
54+ """
4255 all_neighbors = [] # Store
4356
4457 all_neighbors += [neighbors [0 ]]
4558 all_neighbors += [neighbors [1 ]]
4659
47- all_neighbors += [np .c_ [neighbors [0 ][:, 0 ], corners [0 ][neighbors [0 ][:, 1 ]]]]
48- all_neighbors += [np .c_ [neighbors [0 ][:, 1 ], corners [0 ][neighbors [0 ][:, 0 ]]]]
60+ all_neighbors += [np .c_ [neighbors [0 ][:, 0 ], adjacent [0 ][neighbors [0 ][:, 1 ]]]]
61+ all_neighbors += [np .c_ [neighbors [0 ][:, 1 ], adjacent [0 ][neighbors [0 ][:, 0 ]]]]
4962
50- all_neighbors += [np .c_ [corners [1 ][neighbors [1 ][:, 0 ]], neighbors [1 ][:, 1 ]]]
51- all_neighbors += [np .c_ [corners [1 ][neighbors [1 ][:, 1 ]], neighbors [1 ][:, 0 ]]]
63+ all_neighbors += [np .c_ [adjacent [1 ][neighbors [1 ][:, 0 ]], neighbors [1 ][:, 1 ]]]
64+ all_neighbors += [np .c_ [adjacent [1 ][neighbors [1 ][:, 1 ]], neighbors [1 ][:, 0 ]]]
5265
5366 # Repeat backward for Treemesh
5467 all_neighbors += [neighbors_backwards [0 ]]
@@ -57,13 +70,13 @@ def collect_all_neighbors(neighbors, neighbors_backwards, corners, corners_backw
5770 all_neighbors += [
5871 np .c_ [
5972 neighbors_backwards [0 ][:, 0 ],
60- corners_backwards [0 ][neighbors_backwards [0 ][:, 1 ]],
73+ adjacent_backwards [0 ][neighbors_backwards [0 ][:, 1 ]],
6174 ]
6275 ]
6376 all_neighbors += [
6477 np .c_ [
6578 neighbors_backwards [0 ][:, 1 ],
66- corners_backwards [0 ][neighbors_backwards [0 ][:, 0 ]],
79+ adjacent_backwards [0 ][neighbors_backwards [0 ][:, 0 ]],
6780 ]
6881 ]
6982
@@ -83,14 +96,18 @@ def collect_all_neighbors(neighbors, neighbors_backwards, corners, corners_backw
8396 all_neighbors_z += [neighbors [2 ]]
8497 all_neighbors_z += [neighbors_backwards [2 ]]
8598
86- all_neighbors_z += [np .c_ [all_neighbors [:, 0 ], corners [2 ][all_neighbors [:, 1 ]]]]
87- all_neighbors_z += [np .c_ [all_neighbors [:, 1 ], corners [2 ][all_neighbors [:, 0 ]]]]
99+ all_neighbors_z += [
100+ np .c_ [all_neighbors [:, 0 ], adjacent [2 ][all_neighbors [:, 1 ]]]
101+ ]
102+ all_neighbors_z += [
103+ np .c_ [all_neighbors [:, 1 ], adjacent [2 ][all_neighbors [:, 0 ]]]
104+ ]
88105
89106 all_neighbors_z += [
90- np .c_ [all_neighbors [:, 0 ], corners_backwards [2 ][all_neighbors [:, 1 ]]]
107+ np .c_ [all_neighbors [:, 0 ], adjacent_backwards [2 ][all_neighbors [:, 1 ]]]
91108 ]
92109 all_neighbors_z += [
93- np .c_ [all_neighbors [:, 1 ], corners_backwards [2 ][all_neighbors [:, 0 ]]]
110+ np .c_ [all_neighbors [:, 1 ], adjacent_backwards [2 ][all_neighbors [:, 0 ]]]
94111 ]
95112
96113 # Stack all and keep only unique pairs
@@ -106,7 +123,7 @@ def collect_all_neighbors(neighbors, neighbors_backwards, corners, corners_backw
106123
107124
108125def cell_adjacent (neighbors : list [np .ndarray ]) -> list [np .ndarray ]:
109- """Find all cell corners from cell neighbor array."""
126+ """Find all adjacent cells ( corners) from cell neighbor array."""
110127
111128 dim = len (neighbors )
112129 max_index = np .max (neighbors )
0 commit comments