Skip to content

walberla: fix LB VTK writers exporting last block's data on multi-block ranks (bug-sweep #14)#5381

Draft
RudolfWeeber wants to merge 1 commit into
espressomd:pythonfrom
RudolfWeeber:fix/bug-14-lbvtk-multiblock-lastblock
Draft

walberla: fix LB VTK writers exporting last block's data on multi-block ranks (bug-sweep #14)#5381
RudolfWeeber wants to merge 1 commit into
espressomd:pythonfrom
RudolfWeeber:fix/bug-14-lbvtk-multiblock-lastblock

Conversation

@RudolfWeeber

Copy link
Copy Markdown
Contributor

register_vtk_field_writers installed one VTKWriter instance plus a
beforeFunction that looped over all local blocks, repeatedly calling
set_content/set_dims on a single shared buffer. waLBerla runs the
beforeFunction exactly once, so the buffer retained only the LAST
block's data; the subsequent per-block evaluate pass then wrote that
same buffer for every block. On any MPI rank holding more than one
waLBerla block (blocks_per_mpi_rank with >1 block), density,
velocity_vector and pressure_tensor VTK output was corrupted for all
blocks but the last. Single-block ranks were unaffected, masking the
bug. BoundaryVTKWriter already reads per-block via configure()/block_.

Fix: make the VTKWriter buffers block-aware. m_content/m_dims become
per-block maps keyed by the IBlock pointer, filled by the beforeFunction
for every local block. configure() (invoked per block with block_ set)
selects the current block's buffer, so evaluate()/get_first_index read
the correct per-block data. The single-block path is numerically
identical.

Adds LBWalberlaVTKDoublePrecisionBlocksCPU to lattice_vtk.py
(blocks_per_mpi_rank=[2,1,1]) which fails on the unfixed code with a
~50% per-node velocity/density mismatch and passes after the fix.

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

🤖 Generated with Claude Code

…ck ranks (bug-sweep #14)

register_vtk_field_writers installed one VTKWriter instance plus a
beforeFunction that looped over all local blocks, repeatedly calling
set_content/set_dims on a single shared buffer. waLBerla runs the
beforeFunction exactly once, so the buffer retained only the LAST
block's data; the subsequent per-block evaluate pass then wrote that
same buffer for every block. On any MPI rank holding more than one
waLBerla block (blocks_per_mpi_rank with >1 block), density,
velocity_vector and pressure_tensor VTK output was corrupted for all
blocks but the last. Single-block ranks were unaffected, masking the
bug. BoundaryVTKWriter already reads per-block via configure()/block_.

Fix: make the VTKWriter buffers block-aware. m_content/m_dims become
per-block maps keyed by the IBlock pointer, filled by the beforeFunction
for every local block. configure() (invoked per block with block_ set)
selects the current block's buffer, so evaluate()/get_first_index read
the correct per-block data. The single-block path is numerically
identical.

Adds LBWalberlaVTKDoublePrecisionBlocksCPU to lattice_vtk.py
(blocks_per_mpi_rank=[2,1,1]) which fails on the unfixed code with a
~50% per-node velocity/density mismatch and passes after the fix.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@espresso-ci

Copy link
Copy Markdown

Your pull request does not meet our code documentation rules. The Doxygen documentation generated 1 unique warnings (total: 1, ignored: 0):

src/lattice_boltzmann/LBVTK.impl.hpp:
  line 62: unable to resolve reference to 'block_' for \ref command

You can generate these warnings with make -t; make doxygen; ../maintainer/CI/dox_warnings.sh using the maxset config. This is the same command that I have executed to generate the log above.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants