p8est needs two balance calls in function balance!#2289
p8est needs two balance calls in function balance!#2289
balance!#2289Conversation
Review checklistThis checklist is meant to assist creators of PRs (to let them know what reviewers will typically look for) and reviewers (to guide them in a structured review process). Items do not need to be checked explicitly for a PR to be eligible for merging. Purpose and scope
Code quality
Documentation
Testing
Performance
Verification
Created with ❤️ by the Trixi.jl community. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2289 +/- ##
==========================================
- Coverage 97.00% 95.81% -1.18%
==========================================
Files 555 555
Lines 43723 43723
==========================================
- Hits 42410 41893 -517
- Misses 1313 1830 +517
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
balance!balance!
ranocha
left a comment
There was a problem hiding this comment.
Something weird is going on with the MPI tests in this PR but not on main. Could you please check what is going on?
|
MPI applications being stuck waiting for other ranks is an MPI deadlock. I guess it can happen if one MPI rank goes to the second If that is what is causing it, then putting an What can also cause it is if the What is strange is that the currently running CI seems to be stuck at the end of the simulation, in fact in printing summary callback; see the screenshots below. These screenshots are contradictory to my guess about the deadlock, but I thought I would mention it here anyway. |
I think given p4est's maturity, this is not a very likely scenario unless you are trying to process a very weird mesh |
|
It is possible that the reported behavior is not a bug of p4est but rather a consequence of an incompletely specified connectivity. Copying the latest convention from the quoted p4est issue: Connectivity completeness: If a 3D connectivity contains natural connections between trees that are edge neighbors without being face neighbors, these edges shall be encoded explicitly in the connectivity structure. If a connectivity implies natural connections between trees that are corner neighbors without being face (or edge) neighbors, these corners shall be encoded explicitly. Are we certain that the connectivity is constructed according to these rules? Unfortunately, we do not have a function in p4est that would provide a simple answer to this question. |
@Arpit-Babbar @amrueda Can you confirm this? |
Many thanks for pointing this out, @cburstedde! |


As in 2D P4est meshes,
p8est_balancesometimes needs to be called twice to ensure the mesh is properly balanced. This issue is related to the P4est bug reported in p4est issue #112.If the second balancing step is skipped, some simulations may crash during the coarsening operation. I identified a minimal working example by modifying the elixir
examples/p4est_3d_dgsem/elixir_advection_amr.jl, which consistently crashes without the fix introduced in this PR.Issue Breakdown for
elixir_advection_amr.jlcoarsen!(mesh)is called (see code below). The coarsening operation (line 2319) is done without any problems.balance!()call (line 2335), some unfinished changes from the previous balancing (the one done after refinement) step take effect.nothingis returned.nothingis mistakenly used as an integer index.Trixi.jl/src/meshes/p4est_mesh.jl
Lines 2310 to 2354 in 9505d75