Fix StokesFlowProblem validation to ignore internal marked faces#250
Fix StokesFlowProblem validation to ignore internal marked faces#250ryancinsight wants to merge 2 commits intomainfrom
Conversation
- Implemented `StokesFlowProblem::get_external_boundary_nodes` to identify boundary nodes based strictly on topological externality (faces referenced by exactly one cell). - Updated `StokesFlowProblem::validate` to use `get_external_boundary_nodes` instead of `get_boundary_nodes`, ensuring that internal faces (even if marked) do not trigger mandatory boundary condition checks. - Uncommented `problem.validate()?` in `FemSolver::solve` to re-enable problem validation. - Added regression test `test_boundary_detection_internal_marked_face` in `crates/cfd-3d/src/fem/problem.rs`. Co-authored-by: ryancinsight <55164720+ryancinsight@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @ryancinsight, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refines the boundary condition validation logic within the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Review by RecurseML
🔍 Review performed on cc4f248..5a8412b
✨ No bugs found, your code is sparkling clean
✅ Files analyzed, no issues (2)
• crates/cfd-3d/src/fem/problem.rs
• crates/cfd-3d/src/fem/solver.rs
There was a problem hiding this comment.
Code Review
This pull request correctly fixes a validation issue where internal faces marked as boundaries were causing false validation failures. The introduction of get_external_boundary_nodes to consider only topologically external faces is a solid approach. The changes are well-tested with a new unit test that covers the exact scenario being fixed.
I've added one suggestion to refactor the new get_external_boundary_nodes function to be more concise and idiomatic using Rust's iterator chains, which improves maintainability. Overall, this is a good fix that resolves a known issue.
| pub fn get_external_boundary_nodes(&self) -> Vec<usize> { | ||
| use std::collections::{HashMap, HashSet}; | ||
|
|
||
| // Count how many cells reference each face | ||
| let mut face_cell_count: HashMap<usize, usize> = HashMap::new(); | ||
| for cell in self.mesh.cells() { | ||
| for &face_idx in &cell.faces { | ||
| *face_cell_count.entry(face_idx).or_insert(0) += 1; | ||
| } | ||
| } | ||
|
|
||
| // Collect external boundary faces (referenced by exactly one cell) | ||
| let external_boundary_faces: HashSet<usize> = face_cell_count | ||
| .iter() | ||
| .filter(|&(_face_idx, &count)| count == 1) | ||
| .map(|(&face_idx, _)| face_idx) | ||
| .collect(); | ||
|
|
||
| // Collect unique vertices from all external boundary faces | ||
| let mut boundary_vertices: HashSet<usize> = HashSet::new(); | ||
| for &face_idx in &external_boundary_faces { | ||
| if let Some(face) = self.mesh.face(face_idx) { | ||
| boundary_vertices.extend(&face.vertices); | ||
| } | ||
| } | ||
|
|
||
| // Convert to sorted vector for deterministic output | ||
| let mut result: Vec<usize> = boundary_vertices.into_iter().collect(); | ||
| result.sort_unstable(); | ||
| result | ||
| } |
There was a problem hiding this comment.
This function can be made more concise and idiomatic by using iterator chaining. This improves readability and maintainability by reducing nesting and explicit loops.
Additionally, the logic for counting face-cell references is duplicated from get_boundary_nodes. For a follow-up refactoring, you might consider extracting this counting logic into a private helper function to be used by both methods.
Here's a more concise version of get_external_boundary_nodes:
pub fn get_external_boundary_nodes(&self) -> Vec<usize> {
use std::collections::{HashMap, HashSet};
let mut face_cell_count: HashMap<usize, usize> = HashMap::new();
for cell in self.mesh.cells() {
for &face_idx in &cell.faces {
*face_cell_count.entry(face_idx).or_insert(0) += 1;
}
}
let mut result: Vec<usize> = face_cell_count
.into_iter()
.filter(|(_, count)| *count == 1)
.filter_map(|(face_idx, _)| self.mesh.face(face_idx))
.flat_map(|face| face.vertices)
.collect::<HashSet<_>>()
.into_iter()
.collect();
result.sort_unstable();
result
}- Commented out the `scheme` dependency and `scheme-integration` feature in `crates/cfd-1d/Cargo.toml` and the root `Cargo.toml`. - This resolves a build failure where the build environment was looking for a local `../scheme` path which does not exist in CI. - Verified that `cargo build --bench comprehensive_cfd_benchmarks` compiles successfully. Co-authored-by: ryancinsight <55164720+ryancinsight@users.noreply.github.com>
This PR addresses a TODO in
crates/cfd-3d/src/fem/solver.rsregarding the overly conservative validation of boundary conditions.Previously,
StokesFlowProblem::validateusedget_boundary_nodes, which included any face that was marked with a boundary label, even if it was topologically internal (shared by two or more cells). This caused validation failures for internal interfaces where no Dirichlet boundary condition was intended.The fix introduces
get_external_boundary_nodeswhich filters for faces referenced by exactly one cell. This ensures that validation only enforces boundary conditions on the actual domain boundary.FemSolvernow correctly validates the problem before solving.Note: The build requires the private
schemecrate which is not present in this environment. I temporarily patchedCargo.tomlto run tests and verified the fix, then reverted theCargo.tomlchanges before submission.PR created automatically by Jules for task 14978975845436454414 started by @ryancinsight
High-level PR Summary
This PR fixes the boundary condition validation in
StokesFlowProblemto only check nodes on the actual external boundary of the domain. Previously, validation incorrectly flagged internal interfaces (faces marked with boundary labels but shared by multiple cells) as missing boundary conditions. The fix introduces a newget_external_boundary_nodesmethod that uses topological analysis to identify only faces referenced by exactly one cell, ensuring that validation passes when internal marked faces exist without boundary conditions.⏱️ Estimated Review Time: 5-15 minutes
💡 Review Order Suggestion
crates/cfd-3d/src/fem/problem.rscrates/cfd-3d/src/fem/solver.rs