fedoo.Problem.set_reuse_factorization
- Problem.set_reuse_factorization(reuse: bool = True)
Enable or disable factorization reuse for repeated solves.
When enabled, the system matrix is factorized on the first call to
solve(), then subsequent calls reuse the factorization and only perform back-substitution. This is useful when the matrix does not change between solves but the right-hand side does (e.g. tangent stiffness computation by perturbation, multiple load cases on a linear problem).Requires one of pypardiso, python-mumps or petsc4py to be installed (same backend priority as
solver="direct").- Parameters:
reuse (bool, default=True) – If True, enable factorization reuse. If False, disable it and release the cached factorization.
Notes
The factorization is automatically invalidated when
set_A()is called. The user is responsible for callinginvalidate_factorization()if anything else modifies the reduced system matrix (e.g. Dirichlet boundary conditions affecting the constraint reduction matrix).Backend is selected automatically (pypardiso > python-mumps > petsc), regardless of the solver previously set with
set_solver(). The reuse path is direct LU only; if an iterative solver was set withset_solver(), it is silently bypassed while reuse is enabled. Disable reuse withset_reuse_factorization(False)to restore the normal solver dispatch.Examples
>>> pb.set_reuse_factorization(True) >>> for B in load_cases: ... pb.set_B(B) ... pb.apply_boundary_conditions() ... pb.solve() ... # ... read result >>> pb.set_reuse_factorization(False)