openPMD / openPMD-api

:floppy_disk: C++ & Python API for Scientific I/O
https://openpmd-api.readthedocs.io
GNU Lesser General Public License v3.0
142 stars 51 forks source link

Implement a bounding box calculus #989

Open eschnett opened 3 years ago

eschnett commented 3 years ago

When handling mesh refinement data, it is often convenient to have utility routines to handle bounding boxes and sets (lists) of bounding boxes.

Each bounding box is defined by a pair (lower, upper) of integer vectors. In this terminology, each chunk that is written is defined by a bounding box, and the overall shape of a mesh is also described by a bounding box. (openPMD sets the lower bound of the mesh always to 0).

I have in mind a generic utility for such operations. This provide three C++ types (point, box, and regions), each handling respective data in D dimensions. These type support operations such as

Some of these operations are challenging to implement efficiently when there are thousands of boxes in a bounding box set.

When writing AMR data, these operations are typically not needed, because the AMR infrastructure provides the data in the form that openPMD expects. However, when reading or analysing data, these operations are convenient. They allow e.g.:

I happen to have such a set of routines, written in C++, and also designed for convenient Python wrappers. (C++ cares about the dimension D for efficiency, Python does not.)

Please let me know if this is of interest. I could then create a strawman pull request.

ax3l commented 3 years ago

Hi Erik,

As bespoken: I think that sounds fantastic and we can totally implement this as utility/helper functionality and ship it. Let's include some (AMR) batteries! :)