Skip to content

Implement BMI get_value_ptr method in C++ template #59

Open

Description

@mdpiper

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

Activity

  1. mdpiper commented on Aug 31, 2021

    @mdpiper
    MemberAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions