|
37 | 37 | ) |
38 | 38 |
|
39 | 39 |
|
40 | | - |
41 | 40 | class FilterMeta(ABCMeta): |
42 | 41 | """Metaclass for filters that ensures class names are appropriate.""" |
43 | 42 |
|
@@ -1113,12 +1112,14 @@ def from_volumes(cls, mesh: openmc.MeshBase, volumes: openmc.MeshMaterialVolumes |
1113 | 1112 | A new MeshMaterialFilter instance |
1114 | 1113 |
|
1115 | 1114 | """ |
1116 | | - # Get flat arrays of material IDs and element indices |
1117 | | - mat_ids = volumes._materials[volumes._materials > -1] |
1118 | | - elems, _ = np.where(volumes._materials > -1) |
1119 | | - |
1120 | | - # Stack them into a 2D array of (element, material) pairs |
1121 | | - bins = np.column_stack((elems, mat_ids)) |
| 1115 | + # Build bins using by_element so ordering is deterministic (volume |
| 1116 | + # ascending, material ID as tiebreaker) regardless of the ray-traversal |
| 1117 | + # order returned by the C library. |
| 1118 | + bins = [] |
| 1119 | + for i in range(volumes.num_elements): |
| 1120 | + for mat_id, _ in volumes.by_element(i): |
| 1121 | + if mat_id is not None: |
| 1122 | + bins.append((i, mat_id)) |
1122 | 1123 | return cls(mesh, bins) |
1123 | 1124 |
|
1124 | 1125 | def __hash__(self): |
@@ -1861,7 +1862,7 @@ def __init__(self, particles, energies=None, filter_id=None): |
1861 | 1862 | def __repr__(self): |
1862 | 1863 | string = type(self).__name__ + '\n' |
1863 | 1864 | string += '{: <16}=\t{}\n'.format('\tParticles', |
1864 | | - [str(p) for p in self.particles]) |
| 1865 | + [str(p) for p in self.particles]) |
1865 | 1866 | if self.energies is not None: |
1866 | 1867 | string += '{: <16}=\t{}\n'.format('\tEnergies', self.energies) |
1867 | 1868 | string += '{: <16}=\t{}\n'.format('\tID', self.id) |
@@ -2171,7 +2172,7 @@ def paths(self): |
2171 | 2172 | if self._paths is None: |
2172 | 2173 | if not hasattr(self, '_geometry'): |
2173 | 2174 | raise ValueError( |
2174 | | - "Model must be exported before the 'paths' attribute is" \ |
| 2175 | + "Model must be exported before the 'paths' attribute is" |
2175 | 2176 | "available for a DistribcellFilter.") |
2176 | 2177 |
|
2177 | 2178 | # Determine paths for cell instances |
|
0 commit comments