ForestClaw / forestclaw

Quadtree/octree adaptive PDE solver based based on p4est.
http://www.forestclaw.org
BSD 2-Clause "Simplified" License
57 stars 21 forks source link

Feature restart API #269

Closed tim-griesbach closed 10 months ago

tim-griesbach commented 11 months ago

This PR proposes an API for parallel I/O in ForestClaw. The API is dedicated to read and write the ForestClaw domain and to provide generic functions, which can be used to read and write in particular the global structure and the patch data by passing the respective data arrays to them. The overall goal of providing these functionalities is to enable simulation checkpointing/restart functionalities in ForestClaw.

With the proposed API the workflow for writing a checkpoint file is

  1. create a new file by calling fclaw2d_file_open_write; this file contains already the associated domain including the underlying p4est,
  2. write the global structure to the file using fclaw2d_file_write_block by providing a linear byte array of global data,
  3. pass an array of arrays pointing to the patch data to fclaw2d_file_write_field to write the patch data to the file and
  4. close the file using fclaw2d_file_close.

The reading workflow is analogous to the writing workflow above. One can just replace the writing functions by the corresponding reading function. All patch-related data is written and read in parallel according to the partition of the patches. Moreover, every file must contain exactly one domain, i.e. the domain passed to fclaw2d_file_open_write.

The function declarations can be found in fclaw2d_file.h. We appreciate any feedback on the API.

This API is based on the first version of the serial-equivalent file format in p4est in p4est_io.h.

This PR includes commits from @scottaiton for packing glob data that will be required for the implementation of the ForestClaw I/O functionalities.

tim-griesbach commented 10 months ago

We updated the API for the ForestClaw file API that is now ready for review and in particular the include problems described before are no longer relevant to this PR.

We removed the functions to write and read the global structure since this can be done by providing linear byte arrays to the function fclaw2d_file_block and the exact content of these linear byte arrays depends on what data from the global structure is actually needed to restart a ForestClaw simulation.

Together with the implementation of the API we will also provide examples using the ForestClaw file functionalities.