cburstedde / p4est

The "p4est" forest-of-octrees library
www.p4est.org/
GNU General Public License v2.0
253 stars 114 forks source link

Load p4est from file without user data, but allocate memory for user data #308

Closed benegee closed 4 months ago

benegee commented 4 months ago

We are using p4est in our flow solver Trixi.jl via the Julia API P4est.jl.

To construct new p4ests, we use p4est_new_ext and set data_size to 2 * sizeof(Int). This data is used internally during computation of error indicators for adaptive mesh refinement. I now want to use Trixi's restart feature. In this case we use p4est_load_ext to load an existing p4est from a file. As far as I understand, setting data_size is not enough here and I would also have to set load_data to load some actual data. Indeed, this data is irrelevant for Trixi in between mesh refinement step, so it is not saved to files. What I would like to do is to load a p4est from file, not load any user data, but still allocate memory for user data for the subsequent mesh refinement steps. Is this somehow possible?

@sloede @jmark

cburstedde commented 4 months ago

We are using p4est in our flow solver Trixi.jl via the Julia API P4est.jl.

This is really cool stuff!

To construct new p4ests, we use p4est_new_ext and set data_size to 2 * sizeof(Int). This data is used internally during computation of error indicators for adaptive mesh refinement. I now want to use Trixi's restart feature. In this case we use p4est_load_ext to load an existing p4est from a file. As far as I understand, setting data_size is not enough here and I would also have to set load_data to load some actual data. Indeed, this data is irrelevant for Trixi in between mesh refinement step, so it is not saved to files. What I would like to do is to load a p4est from file, not load any user data, but still allocate memory for user data for the subsequent mesh refinement steps. Is this somehow possible?

Indeed, the load function is a bit inflexible in this regard. You may set load_data to 0 and subsequently call p4est_reset_data with the desired size. See the documentation (generated by make doxygen) for further parameters.

benegee commented 4 months ago

Thanks a lot @cburstedde! That is exactly what we need!

benegee commented 4 months ago

And it works!

cburstedde commented 4 months ago

And it works!

Nice! :)