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

Implement BMI get_value_ptr method in C++ template #59

Open
mdpiper opened this issue Aug 31, 2021 · 1 comment
Open

Implement BMI get_value_ptr method in C++ template #59

mdpiper opened this issue Aug 31, 2021 · 1 comment
Labels
enhancement New feature or request hacktoberfest

Comments

@mdpiper
Copy link
Member

mdpiper commented Aug 31, 2021

This is a request to implement the BMI get_value_ptr method in the C++ cookiecutter template.

@mdpiper mdpiper added the enhancement New feature or request label Aug 31, 2021
@mdpiper
Copy link
Member Author

mdpiper commented Aug 31, 2021

Here's a possible way to do it:

cpdef get_value_ptr(self, name):
    cdef int gid = self.get_var_grid(name)
    cdef int size = self.get_grid_size(gid)
    cdef void* ptr
    ptr = self._bmi.GetValuePtr(<char*>name)
    return np.asarray(<np.float_t[:size]>ptr)

This is C-like, though; I'm not sure if there's a cleaner C++ way to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest
Projects
None yet
Development

No branches or pull requests

1 participant