Skip to content

Comments

first pass at creating interface for navier stokes krylov solver#1823

Closed
awccoppFC wants to merge 1 commit intomainfrom
alexander/krylovInterface
Closed

first pass at creating interface for navier stokes krylov solver#1823
awccoppFC wants to merge 1 commit intomainfrom
alexander/krylovInterface

Conversation

@awccoppFC
Copy link
Contributor

@awccoppFC awccoppFC commented Feb 20, 2026

Note

Medium Risk
Touches solver parameter schema, validation, and JSON translation; misconfiguration could change solver behavior or produce incompatible solver configs, though changes are largely gated behind use_krylov_solver.

Overview
Adds a first-pass public interface for enabling a Navier–Stokes Krylov () solver via NavierStokesSolver.use_krylov_solver, including new LineSearch configuration and new Krylov-specific LinearSolver fields.

When Krylov is enabled, model validators auto-populate sensible defaults (e.g., tolerances, preconditioner sweeps, and line search), and the solver JSON translator emits maxPreconditionerIterations, krylovRelativeTolerance, and a lineSearch block; when disabled, Krylov-only fields are ignored/stripped.

Adds SimulationParams validation to block Krylov usage with velocity/pressure-density limiters and with Unsteady time stepping, and re-exports LineSearch from the top-level flow360 package.

Written by Cursor Bugbot for commit fff8d94. This will update automatically on new commits. Configure here.

@awccoppFC awccoppFC marked this pull request as draft February 20, 2026 22:08
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

ns_dict = translated["navierStokesSolver"]
ls_dict = ns_dict.setdefault("linearSolver", {})
if not model.navier_stokes_solver.use_krylov_solver:
ls_dict.pop("maxPreconditionerIterations", None)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Translator doesn't strip Krylov fields when solver disabled

Medium Severity

When use_krylov_solver is False, the translator only pops maxPreconditionerIterations from ls_dict but doesn't strip krylovRelativeTolerance from ls_dict or lineSearch from ns_dict. The model validator in _populate_krylov_defaults warns that these values "will be ignored" (without raising an error), so a user can set them and they survive through dump_dict into the translated output — contradicting the warning and potentially causing unexpected solver behavior.

Additional Locations (1)

Fix in Cursor Fix in Web

"residualGrowthThreshold": 0.85,
"maxResidualGrowth": 1.1,
"activationStep": 100,
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated Krylov defaults in validator and translator

Low Severity

The elif branch in the translator duplicates the same default values (25, 0.05, 0.85, 1.1, 100) already set by the _populate_krylov_defaults model validator. Since the validator always runs and populates these fields when use_krylov_solver=True, the elif condition ("maxPreconditionerIterations" not in ls_dict) is effectively unreachable — making this dead code with a maintenance risk of the two sets of defaults diverging.

Additional Locations (1)

Fix in Cursor Fix in Web

@awccoppFC awccoppFC closed this Feb 21, 2026
@awccoppFC awccoppFC deleted the alexander/krylovInterface branch February 21, 2026 00:33
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.

1 participant