-
Notifications
You must be signed in to change notification settings - Fork 660
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
user-specified chunk layouts (#1528)
* user-specified chunk layouts * documentation for user manual * add SWIG typemaps for binary_partition * move py_bp_to_bp from meep.i into typemaps_utils.cpp * rename bp to pybp * add unit test and update docs * simplify load_chunk_layout * add new section User-Specified Cell Partition to docs page Parallel_Meep.md * tweaks to documentation * rename id to proc_id and update docs * more fixes to docs * update figure to center origin at the center of the cell * update figure * more tweaks * comment that num_chunks must be set to the number of chunks defined by the binary tree * remove paragraph from tutorial example describing how to run simulation * remove constraint that num_chunks must be specified * remove num_chunks from tutorial example * Update doc/docs/Parallel_Meep.md Co-authored-by: Steven G. Johnson <[email protected]> Co-authored-by: Steven G. Johnson <[email protected]>
- Loading branch information
Showing
11 changed files
with
354 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import meep as mp | ||
import copy | ||
import unittest | ||
|
||
process_ids = [] | ||
chunk_areas = [] | ||
|
||
def traverse_tree(bp=None,min_corner=None,max_corner=None): | ||
if ((min_corner.x > max_corner.x) or (min_corner.y > max_corner.y)): | ||
raise RuntimeError("min_corner/max_corner have been incorrectly defined.") | ||
|
||
## reached a leaf | ||
if (bp.left is None and bp.right is None): | ||
process_ids.append(bp.proc_id) | ||
chunk_area = (max_corner.x-min_corner.x)*(max_corner.y-min_corner.y) | ||
chunk_areas.append(chunk_area) | ||
|
||
## traverse the left branch | ||
if (bp.left is not None): | ||
new_max_corner = copy.deepcopy(max_corner) | ||
if bp.split_dir == mp.X: | ||
new_max_corner.x = bp.split_pos | ||
else: | ||
new_max_corner.y = bp.split_pos | ||
traverse_tree(bp.left,min_corner,new_max_corner) | ||
|
||
## traverse the right branch | ||
if (bp.right is not None): | ||
new_min_corner = copy.deepcopy(min_corner) | ||
if bp.split_dir == mp.X: | ||
new_min_corner.x = bp.split_pos | ||
else: | ||
new_min_corner.y = bp.split_pos | ||
traverse_tree(bp.right,new_min_corner,max_corner) | ||
|
||
|
||
class TestChunkLayoutBinaryPartition(unittest.TestCase): | ||
|
||
def test_chunk_layout_binary_partition(self): | ||
chunk_layout = mp.BinaryPartition(data=[ (mp.X,-2.0), 0, [ (mp.Y,1.5), [ (mp.X,3.0), 1, [ (mp.Y,-0.5), 4, 3 ] ], 2 ] ]) | ||
|
||
cell_size = mp.Vector3(10.0,5.0,0) | ||
|
||
sim = mp.Simulation(cell_size=cell_size, | ||
resolution=10, | ||
num_chunks=5, | ||
chunk_layout=chunk_layout) | ||
|
||
sim.init_sim() | ||
owners = sim.structure.get_chunk_owners() | ||
areas = [ v.surroundings().full_volume() for v in sim.structure.get_chunk_volumes() ] | ||
|
||
traverse_tree(chunk_layout,-0.5*cell_size,0.5*cell_size) | ||
|
||
self.assertListEqual([int(f) for f in owners],[f % mp.count_processors() for f in process_ids]) | ||
self.assertListEqual(areas,chunk_areas) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.