Skip to content

Commit 7017c1d

Browse files
committed
Reverted Formatting
1 parent 357bf62 commit 7017c1d

4 files changed

Lines changed: 218 additions & 257 deletions

File tree

openmc/filter.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,20 +1112,12 @@ def from_volumes(cls, mesh: openmc.MeshBase, volumes: openmc.MeshMaterialVolumes
11121112
A new MeshMaterialFilter instance
11131113
11141114
"""
1115-
# Build bins sorted by volume ascending (mat ID ascending as tiebreaker)
1116-
# so the bin ordering is deterministic regardless of the ray-traversal
1117-
# order stored in the raw _materials array.
1118-
bins = []
1119-
for i in range(volumes.num_elements):
1120-
entries = volumes.by_element(i)
1121-
# sort by (volume asc, mat_id asc), excluding void (None)
1122-
entries = sorted(
1123-
((mat_id, vol)
1124-
for mat_id, vol in entries if mat_id is not None),
1125-
key=lambda t: (t[1], t[0])
1126-
)
1127-
for mat_id, _ in entries:
1128-
bins.append((i, mat_id))
1115+
# Get flat arrays of material IDs and element indices
1116+
mat_ids = volumes._materials[volumes._materials > -1]
1117+
elems, _ = np.where(volumes._materials > -1)
1118+
1119+
# Stack them into a 2D array of (element, material) pairs
1120+
bins = np.column_stack((elems, mat_ids))
11291121
return cls(mesh, bins)
11301122

11311123
def __hash__(self):

0 commit comments

Comments
 (0)