Conversation
fff47df to
e911c14
Compare
There was a problem hiding this comment.
🟡 Changes recommended
A user-facing feature was added but the root release notes file (RELEASE-NOTES.md) was not updated with an “Unreleased” entry.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds support for state-dependent custom block-operator providers (including Schur complement approximations) so block preconditioners can rebuild their internal operators from the current nonlinear iterate before each Newton linearization. This extends the block preconditioner override API beyond fixed operators, wires state refresh into differentiable-numerics Newton solves, and adds weak-form helpers plus tests.
Changes:
- Introduces
StateDependentSolverand state-refresh plumbing for block preconditioners and solver wrappers (SolverWithPreconditioner). - Replaces fixed block-operator overrides with provider-based overrides (fixed and state-dependent) and adds factories to build them.
- Adds weak-form operator builder utilities for fixed/state-dependent overrides and expands tests (including a nonlinear mixed diffusion example).
File summaries
| File | Description |
|---|---|
| src/smith/numerics/tests/test_equationsolver.cpp | Adds a test ensuring EquationSolver owns/attaches a caller-supplied preconditioner. |
| src/smith/numerics/tests/test_block_preconditioner_custom_operators.cpp | Updates tests to the new provider-override API and adds a state-dependent Schur provider test. |
| src/smith/numerics/state_dependent_solver.hpp | Adds a small interface for solvers that refresh internals from nonlinear state. |
| src/smith/numerics/solver_with_preconditioner.hpp | Makes the wrapper state-refreshable by forwarding updates to owned solver/preconditioner when applicable. |
| src/smith/numerics/equation_solver.hpp | Adds constructor overload for custom owned preconditioners; adds block sub-solver builder helper. |
| src/smith/numerics/equation_solver.cpp | Implements custom-preconditioner construction and factors linear-solver building; adds block sub-solver builder. |
| src/smith/numerics/CMakeLists.txt | Registers the new numerics header. |
| src/smith/numerics/block_preconditioner.hpp | Introduces provider-based override types/factories and updateForState API on block preconditioners. |
| src/smith/numerics/block_preconditioner.cpp | Implements fixed/state-dependent providers and refresh logic; updates Schur custom path to use providers. |
| src/smith/differentiable_numerics/weak_form_block_operator.hpp | Adds helper APIs to assemble weak-form Jacobians for use as block-preconditioner operators. |
| src/smith/differentiable_numerics/weak_form_block_operator.cpp | Implements weak-form operator assembly and state-dependent rebuild logic with DOF elimination support. |
| src/smith/differentiable_numerics/tests/test_weak_form_block_operator.cpp | Adds unit tests for fixed and state-dependent weak-form operator providers. |
| src/smith/differentiable_numerics/tests/test_state_dependent_preconditioner.cpp | Tests Newton-loop state refresh wiring for a state-dependent Schur operator provider. |
| src/smith/differentiable_numerics/tests/test_porous_heat_sink.cpp | Uses weak-form operator override for custom Schur approximation in an existing block solve test. |
| src/smith/differentiable_numerics/tests/test_nonlinear_mixed_diffusion.cpp | Adds an end-to-end nonlinear mixed diffusion test exercising state-dependent custom Schur preconditioning. |
| src/smith/differentiable_numerics/tests/test_mixed_poisson.cpp | Uses weak-form operator override for custom Schur approximation in an existing mixed Poisson test. |
| src/smith/differentiable_numerics/tests/CMakeLists.txt | Registers new differentiable-numerics tests. |
| src/smith/differentiable_numerics/nonlinear_block_solver.hpp | Adds ability to register a state-dependent solver to refresh before Jacobian assembly. |
| src/smith/differentiable_numerics/nonlinear_block_solver.cpp | Calls updateForState before Jacobian assembly; adds builder overload for custom preconditioners. |
| src/smith/differentiable_numerics/CMakeLists.txt | Adds the new weak-form operator source/header to the differentiable-numerics build. |
Review details
- Files reviewed: 20/20 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| @@ -1,5 +1,11 @@ | |||
| #include <gtest/gtest.h> | |||
There was a problem hiding this comment.
Does this test add something important that the nonlinear mixed diffsusion doesn't test (or couldn't be easily modified to test). I worry about about us getting too much testing bloat. So consolidating or unifying, or extracting out common things from these tests would actually be preferred for me.
There was a problem hiding this comment.
Or, between test_mixed_poisson, mixed_diffusion, porous_heat_sink... what do we really need to be testing to be sufficiently confident without over testing early on an evolving capability.
There was a problem hiding this comment.
test_mixed_poisson is different from the other two since it is a saddle point problem and is a good starting point for other problems like that, where Schur complement approximations are important. nonlinear_diffusion is essentially a nonlinear version of the porous heat sink test. the linear test tests a bunch of the different factorizations, and the nonlinear version only looks at the custom operators. I guess those two could be combined to reduce the numbers of test files or lines of code, but it might increase test time since we'd do more nonlinear solves.
Adds state-dependent custom Schur complement approximations for block preconditioners.
Users can provide a custom Schur operator directly, or define one from a weak form whose coefficients depend on the current nonlinear solution. Before each Newton linearization, the preconditioner rebuilds that operator using the latest block state, then uses it for the Schur solve. The PR also adds the weak-form helper API and tests for fixed and state-dependent custom Schur approximations.