first pass at creating interface for navier stokes krylov solver#1823
first pass at creating interface for navier stokes krylov solver#1823
Conversation
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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)
| "residualGrowthThreshold": 0.85, | ||
| "maxResidualGrowth": 1.1, | ||
| "activationStep": 100, | ||
| } |
There was a problem hiding this comment.
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.


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 newLineSearchconfiguration and new Krylov-specificLinearSolverfields.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 alineSearchblock; when disabled, Krylov-only fields are ignored/stripped.Adds SimulationParams validation to block Krylov usage with velocity/pressure-density limiters and with
Unsteadytime stepping, and re-exportsLineSearchfrom the top-levelflow360package.Written by Cursor Bugbot for commit fff8d94. This will update automatically on new commits. Configure here.