multiscale / muscle3

The third major version of the MUltiScale Coupling Library and Environment
Apache License 2.0
25 stars 13 forks source link

Data::grid() version that allocates memory #264

Open LourensVeen opened 10 months ago

LourensVeen commented 10 months ago

Currently, when you're creating a Data::grid() you need to pass a pointer to a pre-existing array with data. If the original data are in a format that's not an array layout, then that's no good.

In that case, you need to allocate some memory, copy (or gather, or whatever) the data in there in the right order, and then create your Data object. But now if you want to return that Data object from a function that created it, you'll have to return some other object owning the memory along with it, and that's annoying.

So it would be nice if we could have a Data::grid() that doesn't take a data pointer but only type, indexes and storage order, and that would allocate the memory internally and own it.

If we make a non-const version of the accessor functions in #251, then that can be used to write in the values.

LourensVeen commented 10 months ago

This would also improve regularity, since for Data::byte_array we do have both.