Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sim.chunk_layout is not accessible in Python if not specified at class instantiation time #1648

Closed
bencbartlett opened this issue Jun 29, 2021 · 1 comment · Fixed by #1673

Comments

@bencbartlett
Copy link
Contributor

If a meep.Simulation object is created without specifying chunk_layout, then the default logic for choosing chunk divisions is invoked when sim.init_sim() is called. However, the chunk_layout attribute on the Python Simulation object is not updated to reflect this change and will still read as None.

When converting from a Python meep.BinaryPartition object, py_bp_to_bp() is called to convert the Python object into a C++ object. It would be useful to have the inverse operation present with a bp_to_py_bp() function, perhaps as a class construction method to live on meep.BinaryPartition. Then in Simulation._init_structure() at line 1709, this function could be called to update the Simulation.chunk_layout attribute:

if self.chunk_layout is None:
  self.chunk_layout = mp.BinaryPartition.from_cpp_object(...)
@stevengj
Copy link
Collaborator

stevengj commented Jul 1, 2021

Probably the code would go in python/typemap_utils.cpp. Once you have the function PyObject *binarypartition_cpp_to_py(...) or whatever it is called, SWIG should handle it automatically.

You may also need some refactoring in the structure constructor to save the binary partition it creates.

ahoenselaar added a commit to ahoenselaar/meep that referenced this issue Jul 2, 2021
* Store the binary partition - whether passed in externally or generated
via `choose_chunkdivision` in `structure` and expose it via a getter.
* Remove the unused default constructor of `structure`.
* Remove a redundant copy constructor of `structure`.
* Clean up the copy constructor `structure`.
* Make `binary_partition` copyable.

Prepares for making the BinaryPartition visible in Python (NanoComp#1648).
stevengj pushed a commit that referenced this issue Jul 2, 2021
* Store the binary partition - whether passed in externally or generated
via `choose_chunkdivision` in `structure` and expose it via a getter.
* Remove the unused default constructor of `structure`.
* Remove a redundant copy constructor of `structure`.
* Clean up the copy constructor `structure`.
* Make `binary_partition` copyable.

Prepares for making the BinaryPartition visible in Python (#1648).
bencbartlett pushed a commit to bencbartlett/meep that referenced this issue Sep 9, 2021
* Store the binary partition - whether passed in externally or generated
via `choose_chunkdivision` in `structure` and expose it via a getter.
* Remove the unused default constructor of `structure`.
* Remove a redundant copy constructor of `structure`.
* Clean up the copy constructor `structure`.
* Make `binary_partition` copyable.

Prepares for making the BinaryPartition visible in Python (NanoComp#1648).
mawc2019 pushed a commit to mawc2019/meep that referenced this issue Nov 3, 2021
* Store the binary partition - whether passed in externally or generated
via `choose_chunkdivision` in `structure` and expose it via a getter.
* Remove the unused default constructor of `structure`.
* Remove a redundant copy constructor of `structure`.
* Clean up the copy constructor `structure`.
* Make `binary_partition` copyable.

Prepares for making the BinaryPartition visible in Python (NanoComp#1648).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants