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

[Python] adding Vector #118

Merged
merged 10 commits into from
Jan 18, 2021
Merged

[Python] adding Vector #118

merged 10 commits into from
Jan 18, 2021

Conversation

philbucher
Copy link
Member

This PR adds the CoSimIO.Vector
this object is a tiny wrapper around std::vector<double> to be used in Python. The goals are:

  • Make the data exchange more efficient, having a dedicated object will not require to copy back and forth the data each time (currently pybind does this automatically each time we pass data btw Python & C++)
  • The interfaces are now unified, esp for the ImportData we will not need to return a tuple (of CoSimIO.Info & the data (a py::list)) any more but now only the Info

=> the Interface will be updated in a follow up PR

@philbucher
Copy link
Member Author

philbucher commented Jan 18, 2021

I managed to get it to work with PYBIND11_MAKE_OPAQUE which is quite cool
=> https://pybind11.readthedocs.io/en/stable/advanced/cast/stl.html#making-opaque-types

basically this disables the automatic copy of the specified types and allows to use the by reference, exactly what we need!

unfortunately this breaks the old Import/ExportMesh tests where I still use them by copy. Hence I need to update those first

TODO for this PR to go in:

  • update old tests => [Python] using ModelPart in interface #120
  • add more tests with passing the object to the function, modifying it and then checking if the modification is propagated (will probably require some function in C++ for testing) => done in the integration tutorials
  • decide on naming: Vector (as it is now) or DoubleVector so that we could easily add an IntVector in the future

@pooyan-dadvand
Copy link
Member

I would go for DoubleVector

@philbucher philbucher mentioned this pull request Jan 18, 2021
35 tasks
@philbucher philbucher merged commit 125d747 into master Jan 18, 2021
@philbucher philbucher deleted the py/vector branch January 18, 2021 14:55
@philbucher philbucher mentioned this pull request Jan 18, 2021
39 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request interface Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants