Open
Conversation
This commit addresses several potential issues and improves the robustness
of the CDT simulation code.
Key changes include:
1. RNG Seeding: Standardized random number generator seeding for
`Universe::rng`, ensuring it's seeded from main like `Simulation::rng`.
Addresses a TODO comment.
2. `verticesFour` Management:
- `insertVertex`: Correctly updates the `verticesFour` bag for the newly
inserted vertex and its relevant neighbors by evaluating `isFourVertex`.
- `removeVertex`: Ensures `verticesFour` is updated for neighbors
affected by a vertex removal.
- `flipLink`: Systematically updates `verticesFour` for all four
vertices involved in an edge flip using `isFourVertex`. The
`setVertices` calls within `flipLink` were also updated to reflect a
standard robust edge flip procedure.
3. `Universe::check()` Enhancement: The `verticesFour` verification in
`Universe::check()` now iterates over all active vertices in the
simulation (using `Vertex::items()`) and asserts that their status
(per `isFourVertex`) matches their presence in the `verticesFour` bag.
4. `Universe::vertices` List: `Universe::updateVertexData` now populates
`Universe::vertices` with all unique active vertices. This ensures
that `Universe::exportGeometry` exports the complete geometry.
5. Robust Geometry I/O:
- `Universe::importGeometry` now returns a boolean status indicating
success or failure instead of asserting on errors.
- It handles file open errors, read errors, and count mismatches
gracefully, printing informative messages.
- `main.cpp` now checks this return status and proceeds accordingly,
allowing for fallback to new universe creation if import fails.
The `trianglesFlip` logic within the move functions was largely preserved
to limit the scope of this set of changes, though the corrected
`setVertices` in `flipLink` should contribute to its correctness.
Further investigation into `trianglesFlip` invariants might be beneficial
in the future.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit addresses several potential issues and improves the robustness of the CDT simulation code.
Key changes include:
RNG Seeding: Standardized random number generator seeding for
Universe::rng, ensuring it's seeded from main likeSimulation::rng. Addresses a TODO comment.verticesFourManagement:insertVertex: Correctly updates theverticesFourbag for the newly inserted vertex and its relevant neighbors by evaluatingisFourVertex.removeVertex: EnsuresverticesFouris updated for neighbors affected by a vertex removal.flipLink: Systematically updatesverticesFourfor all four vertices involved in an edge flip usingisFourVertex. ThesetVerticescalls withinflipLinkwere also updated to reflect a standard robust edge flip procedure.Universe::check()Enhancement: TheverticesFourverification inUniverse::check()now iterates over all active vertices in the simulation (usingVertex::items()) and asserts that their status (perisFourVertex) matches their presence in theverticesFourbag.Universe::verticesList:Universe::updateVertexDatanow populatesUniverse::verticeswith all unique active vertices. This ensures thatUniverse::exportGeometryexports the complete geometry.Robust Geometry I/O:
Universe::importGeometrynow returns a boolean status indicating success or failure instead of asserting on errors.main.cppnow checks this return status and proceeds accordingly, allowing for fallback to new universe creation if import fails.The
trianglesFliplogic within the move functions was largely preserved to limit the scope of this set of changes, though the correctedsetVerticesinflipLinkshould contribute to its correctness. Further investigation intotrianglesFlipinvariants might be beneficial in the future.