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

Function get_total_volume_per_process

python/binary_partition_utils.py:208–236  ·  view source on GitHub ↗

Computes the total pixel volume per process contained in a BinaryPartition. Args: partition: a BinaryPartition subtree to compute the associated volumes for chunk_volumes: associated grid volumes from a simulation, obtained by calling sim.structure.get_chunk_volumes()

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

Source from the content-addressed store, hash-verified

206
207
208def get_total_volume_per_process(
209 partition: mp.BinaryPartition,
210 chunk_volumes: Tuple[mp.grid_volume],
211 chunk_owners: onp.ndarray,
212) -> Dict[int, float]:
213 """Computes the total pixel volume per process contained in a BinaryPartition.
214
215 Args:
216 partition: a BinaryPartition subtree to compute the associated volumes for
217 chunk_volumes: associated grid volumes from a simulation, obtained by
218 calling sim.structure.get_chunk_volumes()
219 chunk_owners: list of processes associated with each grid volume, obtained
220 by calling sim.structure.get_chunk_owners()
221
222 Returns:
223 A dictionary of the total pixel volume occupied by all chunks owned by each
224 process.
225 """
226 volumes_per_process = {}
227 leaf_nodes_in_tree = enumerate_leaf_nodes(partition)
228 for leaf in leaf_nodes_in_tree:
229 total_volume = sum(
230 pixel_volume(chunk_volumes[i])
231 for i, owner in enumerate(chunk_owners)
232 if owner == leaf.proc_id
233 )
234
235 volumes_per_process[leaf.proc_id] = total_volume
236 return volumes_per_process
237
238
239def get_box_ranges(

Callers

nothing calls this directly

Calls 2

enumerate_leaf_nodesFunction · 0.85
pixel_volumeFunction · 0.85

Tested by

no test coverage detected