Skip to content

Implement local VTU export for load balancing#240

Open
Geethapranay1 wants to merge 3 commits into
precice:developfrom
Geethapranay1:fix-189-load-balancing-vtu-export
Open

Implement local VTU export for load balancing#240
Geethapranay1 wants to merge 3 commits into
precice:developfrom
Geethapranay1:fix-189-load-balancing-vtu-export

Conversation

@Geethapranay1

Copy link
Copy Markdown
Contributor

Fix #189

This PR implements a native, local VTU export functionality specifically tailored for dynamic load balancing, resolving the previously reported export data loss and duplicate points issues.

When load balancing and export:vtu are enabled concurrently:

  • we automatically intercept the export:vtu tag in the preCICE configuration and parse its parameters (directory, frequency).
  • MicroManagerCoupling suppresses preCICE's native global export by injecting a modified, stripped XML locally.
  • micro-manager now handles it natively: every MPI rank iterates solely over its currently owned/active subset of coords_local and writes proper .vtu (VTK_VERTEX) files containing exactly its local scalar and vector datasets.
  • rank 0 orchestrates gathering the MPI metadata and produces the coordinating parallel .pvtu file.

Checklist:

  • I made sure that the CI passed before I ask for a review.
  • I added a summary of the changes (compared to the last release) in the CHANGELOG.md.
  • If necessary, I made changes to the documentation and/or added new content.
  • I will remember to squash-and-merge, providing a useful summary of the changes of this PR.

Testing

Successfully tested VTU generation offline. Example output format validation when run across distributed domains:

Click to view generated VTU Structure Proof

Local VTU format (e.g. Micro-Manager_Macro-Mesh_1_rank0.vtu):

<?xml version='1.0' encoding='utf-8'?>
<VTKFile type="UnstructuredGrid" version="0.1" byte_order="LittleEndian">
  <UnstructuredGrid>
    <Piece NumberOfPoints="3" NumberOfCells="3">
      <Points>
        <DataArray type="Float64" NumberOfComponents="3" format="ascii">0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0</DataArray>
      </Points>
      <Cells>
        <DataArray type="Int32" Name="connectivity" format="ascii">0 1 2</DataArray>
        <DataArray type="Int32" Name="offsets" format="ascii">1 2 3</DataArray>
        <DataArray type="UInt8" Name="types" format="ascii">1 1 1</DataArray>
      </Cells>
      <PointData>
        <DataArray type="Float64" Name="Temperature" NumberOfComponents="1" format="ascii">100.5 110.2 95.8</DataArray>
        <DataArray type="Float64" Name="Velocity" NumberOfComponents="3" format="ascii">1.0 0.5 0.0 1.2 0.6 0.1 0.9 0.4 0.0</DataArray>
      </PointData>
    </Piece>
  </UnstructuredGrid>
</VTKFile>

@MakisH MakisH added the GSoC Contributed in the context of the Google Summer of Code label Apr 6, 2026
@Geethapranay1

Copy link
Copy Markdown
Contributor Author

hi @IshaanDesai
I have pushed a new commit to address the remaining edge cases, stabilize the load-balanced VTU exporter.

here are the main improvements:

  • replaced fragile ElementTree parsing with targeted text parsing to safely handle preCICE <export:vtu /> tags without XML namespace issues.
  • the custom VTU writer now properly supports empty ranks, writing the necessary files so the .pvtu output remains valid and unbroken.
  • enforced a globally consistent point-data schema across all ranks (using allgather) to ensure seamless loading in ParaView.
  • fixed the vertex ID mapping to use the actual preCICE vertex IDs (_mesh_vertex_ids) rather than raw coordinate indices.
  • added missing unit tests covering empty-rank VTU generation, 2D-to-3D vector padding, and .pvtu file creation.

Note: full feature parity for every-iteration="true" is not yet implemented in the custom exporter (it currently exports completed time windows only), but it now safely logs a warning if configured.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GSoC Contributed in the context of the Google Summer of Code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

preCICE export does not work as expected when load balancing is done

2 participants