MCPcopy Create free account
hub / github.com/NanoComp/meep / get_grid_volumes_in_tree

Function get_grid_volumes_in_tree

python/binary_partition_utils.py:174–205  ·  view source on GitHub ↗

Fetches a list of grid_volumes contained in a BinaryPartition subtree. NOTE: If multiple chunks are owned by the same process, this function may over-count the volume, since all provided grid volumes associated with a given process are counted. Args: partition: a BinaryPartit

(
    partition: mp.BinaryPartition,
    chunk_volumes: Tuple[mp.grid_volume],
    chunk_owners: onp.ndarray,
)

Source from the content-addressed store, hash-verified

172
173
174def get_grid_volumes_in_tree(
175 partition: mp.BinaryPartition,
176 chunk_volumes: Tuple[mp.grid_volume],
177 chunk_owners: onp.ndarray,
178) -> List[mp.grid_volume]:
179 """Fetches a list of grid_volumes contained in a BinaryPartition subtree.
180
181 NOTE: If multiple chunks are owned by the same process, this function may
182 over-count the volume, since all provided grid volumes associated with a
183 given process are counted.
184
185 Args:
186 partition: a BinaryPartition subtree to find grid_volumes for
187 chunk_volumes: associated grid volumes from a simulation, obtained by
188 calling sim.structure.get_chunk_volumes()
189 chunk_owners: list of processes associated with each grid volume, obtained
190 by calling sim.structure.get_chunk_owners()
191
192 Returns:
193 A list of all grid_volume objects associated with any proc_id contained in
194 the partition. The list is not necessarily ordered by proc_id values.
195 """
196 if partition_has_duplicate_proc_ids(partition):
197 warnings.warn("Partition has duplicate proc_ids, overcounting possible!")
198
199 my_proc_ids = [node.proc_id for node in enumerate_leaf_nodes(partition)]
200
201 return [
202 chunk_volumes[i]
203 for (i, owner) in enumerate(chunk_owners)
204 if owner in my_proc_ids
205 ]
206
207
208def get_total_volume_per_process(

Callers 1

get_total_volumeFunction · 0.85

Calls 2

enumerate_leaf_nodesFunction · 0.85

Tested by

no test coverage detected