Ft stokes collocation iga#490
Conversation
WalkthroughThis PR adds a complete example script that demonstrates a collocation-based approach to solving the Stokes flow problem using splinepy mixed velocity/pressure splines on the unit square. The script constructs refined B-spline spaces, assembles sparse coupled equations, imposes boundary conditions, solves the system, and visualizes solutions and error fields. ChangesSparse Stokes Collocation Example
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@examples/iga/collocation_stokes_problem_sparse.py`:
- Around line 309-315: The factory function error_u currently defines and
returns an inner function also named error_u, which shadows the outer name;
rename the inner function to something like _error_u or compute_error (and
similarly rename inner functions in error_v and error_p) to avoid shadowing,
update the inner function body to call solution_u.evaluate(on) and
analytical_solution_u(data, on) as before, and return the renamed inner function
so all callers of the outer factory continue to receive the correct closure
without ambiguous symbol names.
- Around line 414-417: The loss_function_p currently returns a signed
divergence: mass_factor * (mapper_u.gradient(on)[:, 0, 0] +
mapper_v.gradient(on)[:, 0, 1]); change it to return the absolute value to match
loss_function_u/v and the plot label by wrapping the whole expression with
np.abs (use numpy imported as np), i.e., compute the divergence via
mapper_u.gradient and mapper_v.gradient as before, multiply by mass_factor, then
apply np.abs before returning from loss_function_p.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 3306b836-2555-47d5-a8d3-1fa472d0e01b
📒 Files selected for processing (1)
examples/iga/collocation_stokes_problem_sparse.py
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
examples/iga/collocation_stokes_problem_sparse.py (1)
152-159:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winComment typo: this row is
dvdy, notdvdx.The third block-matrix row is the continuity equation
∂u/∂x + ∂v/∂y = 0, and the code correctly indexesgradient_v[:, :, 1](i.e.,∂v/∂y). The comment on line 152 still labels itA_v_tp dvdx, which mislabels the term and is inconsistent with line 144 (A_u_tp dudx).📝 Proposed fix
-# A_v_tp dvdx +# A_v_tp dvdy gradient_v, support_v = mapper_v.basis_gradient_and_support(greville_points_p)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@examples/iga/collocation_stokes_problem_sparse.py` around lines 152 - 159, The inline comment labeling the third block-matrix row is incorrect: change the comment "A_v_tp dvdx" to "A_v_tp dvdy" (or "A_v_tp ∂v/∂y") to match the indexed gradient component gradient_v[:, :, 1] used when building A_v_tp (created from mapper_v.basis_gradient_and_support and mass_factor and solution_field_velocity_v.cps). Ensure the updated comment mirrors the style of the corresponding "A_u_tp dudx" comment.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@examples/iga/collocation_stokes_problem_sparse.py`:
- Around line 152-159: The inline comment labeling the third block-matrix row is
incorrect: change the comment "A_v_tp dvdx" to "A_v_tp dvdy" (or "A_v_tp ∂v/∂y")
to match the indexed gradient component gradient_v[:, :, 1] used when building
A_v_tp (created from mapper_v.basis_gradient_and_support and mass_factor and
solution_field_velocity_v.cps). Ensure the updated comment mirrors the style of
the corresponding "A_u_tp dudx" comment.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 85170967-18f6-4ba9-b5ce-4628dc5a6b12
📒 Files selected for processing (1)
examples/iga/collocation_stokes_problem_sparse.py
clemens-fricke
left a comment
There was a problem hiding this comment.
Looks good thank you @jzwar for starting this and providing this very nice example, and thank you @danielwolff1 for looking over it and finding the error.
Overview
Test stokes example with L2-IGA-collocation based on the example in Finite Element Methods for Flow Problems by Donea and Huerta (Chapter 6.8.1, p. 306).!
Thanks to @danielwolff1 for finding the bug.
Addressed issues
None. This PR mainly adds a showcase/example problem and I had too much free time...
This is the output:

Feedback and further improvements are welcome.
Summary by CodeRabbit