Replies: 1 comment
-
Yeah, this doesn't work because by cast to an std::unordered_map from a Alternatively, you can go with the PYBIND11_MAKE_OPAQUE approach which would ensure it's not converted, but it would appear as it's own type and not a python dict to Python. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is the same question I posted on Fenics Forum.
The whole idea here is to pass a dict from python to c++ (especially if the mesh/functionspace remains same) and use c++ to calculate dof_component_map and get it back in python so that can be used later in a fluid structure-interaction code.
Note 1: I need this because:
It is very expensive to call a recursive function each time
I am interpolating multiple times in each time-step in the solver on a 1 million DOF function-space. However my fluid mesh remain constant with time.
Note 2: That is the reason I intend to pass it by reference. The whole idea of this interpolation script is copied from the fenicstools/interpolate module.
The code works well, except the fact that the dof_component_map is calculated correctly in c++ and does not get carried back to python. (One can check that by uncommenting the “printing map” lines in interpolate.cpp).
test.py
delta_interpolation.cpp
If we look here and also at (test_stl_binders.cpp), it looks like we should be able to pass dict by reference, maybe I am wrong, but I tried my best, for the life of me, I can’t seem to figure it out. They also mention that using “PYBIND11_MAKE_OPAQUE” macro helps us to do that. What makes it even more complicated is the fact that std:unordered_map uses “dynamic vectors - size_t” (because of the size of Function space).
Any help or even a workaround will be very helpful. Again I am using FEniCS 2019.1.0. Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions