def adj_list_from_blocks(block_proc, proc_block_np): """ return adjacency list information for use by METIS partitioning Arguments: ---------- - block_proc: dict mapping bid:proc - proc_block_map: list of dict bid:np, in sequence of the process to which block belongs Returns: -------- - adj_list: list of 3-tuples, one for each block in proc-block_np The 3-tuple consists of (bid, adjacent bids, num_particles in bid) """ adj_list = [] nbrs = [] i = 0 for blocks in proc_block_np: for bid, np in blocks.iteritems(): nbrs[:] = [] adjl = [] py_construct_immediate_neighbor_list(bid, nbrs, False) for nbr in nbrs: if nbr in block_proc: adjl.append(nbr) adj_list.append((bid, adjl, np)) i += 1 return adj_list
def adj_list_from_blocks(block_proc, proc_block_np): """ return adjacency list information for use by METIS partitioning Arguments: ---------- - block_proc: dict mapping bid:proc - proc_block_map: list of dict bid:np, in sequence of the process to which block belongs Returns: -------- - adj_list: list of 3-tuples, one for each block in proc-block_np The 3-tuple consists of (bid, adjacent bids, num_particles in bid) """ adj_list = [] nbrs = [] i = 0 for blocks in proc_block_np: for bid, np in blocks.iteritems(): nbrs[:] = [] adjl = [] py_construct_immediate_neighbor_list(bid, nbrs, False) for nbr in nbrs: if nbr in block_proc: adjl.append(nbr) adj_list.append((bid, adjl, np)) i += 1 return adj_list
def get_cell_list_to_send(self): """Return a list of cells to send to each processor. Neighboring cells are determined allowing for cells to be shared across processors. The return value is a dictionary keyed on processor id with value equal to the list of cells to send that processor. """ local_map = self.local_cell_map global_map = self.global_cell_map pc = self.parallel_controller cell_list_to_send = {} for cid in local_map: neighbor_ids = [] py_construct_immediate_neighbor_list(cid, neighbor_ids, include_self=False) # handle non-overlapping regions for neighbor_id in neighbor_ids: if neighbor_id in global_map: owning_pids = list(global_map[neighbor_id]) for pid in owning_pids: if not pid in cell_list_to_send: cell_list_to_send[pid] = set([cid]) else: cell_list_to_send[pid].update([cid]) # handle overlapping regions conflicting_pids = list(global_map[cid]) if len(conflicting_pids) > 0: for neighbor_id in neighbor_ids: if neighbor_id in local_map: for pid in conflicting_pids: if not pid in cell_list_to_send: cell_list_to_send[pid] = set([cid]) else: cell_list_to_send[pid].update([cid]) return cell_list_to_send