pass binary-tree partition to structure constructor #1577
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1573.
Based on a suggestion in #1528 by @stevengj, this PR revamps the
structure
class constructor to accept abinary_partition
argument which enables specifying the chunk volumes once when the user passes in aBinaryPartition
object from the Python API. Correspondingly, the Python functionload_chunk_layout
has been removed since it is no longer necessary. The main changes involved the functionsplit_by_cost
instructure.cpp
which now returns abinary_partition
object rather than writing the chunk volumes into an array.This PR enables creating the PML regions as separate chunks using the existing code
structure::choose_chunkdivision
. As a result, the example test described in #1573 now produces the correct chunk layout:All the C++ tests are passing yet several of the Python tests are failing. This is due to a SWIG-related issue that needs to be resolved before this PR can be merged. An additional argument has been added to the C++/Python function
create_structure_and_set_materials
in the SWIG typemaps filemeep.i
in order to pass in theBinaryPartition
pointer object (which is then passed to thestructure
class constructor). The problem is that trying to pass in aNone
(for aNULL
pointer) for this argument produces an error:The issue is that SWIG is expecting a
meep::binary_partition *my_bp
type argument and does not acceptNULL
.