From 0d4dbad091527fa3f996260f6d6bc7d7e5c16e59 Mon Sep 17 00:00:00 2001 From: Gertjan van Zwieten Date: Tue, 22 Oct 2024 20:13:42 +0200 Subject: [PATCH] Switch row to column support in solve_constraints This patch removes rowsupp in System.solve_constraints and replaces it with a local implementation for column support. Aside from preparing for the imminent deprecation of rowsupp, switching to a column-based support test is more appropriate now that solve_constraints is no longer limited to symmetric systems, as the columns relate to the trial dofs that are being constrained. When in future row constraints will be better supported then the local test can be extended with a row test for non-symmetric systems. --- nutils/solver.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nutils/solver.py b/nutils/solver.py index 05a5ff5f5..b7838b850 100644 --- a/nutils/solver.py +++ b/nutils/solver.py @@ -445,7 +445,10 @@ def solve_constraints(self, *, droptol: Optional[float], arguments: Dict[str, nu raise ValueError('system is not linear') x, iscons, arguments = self.prepare_solution_vector(arguments, constrain) jac, res, val = self.assemble(arguments) - mycons = iscons | ~jac.rowsupp(droptol) + data, colidx, _ = jac.export('csr') + mycons = numpy.ones_like(iscons) + mycons[colidx[abs(data) > droptol]] = False # unconstrain dofs with nonzero columns + mycons |= iscons dx = -jac.solve(res, constrain=mycons, **_copy_with_defaults(linargs, symmetric=self.is_symmetric)) if self.is_symmetric: log.info(f'optimal value: {val+.5*(res@dx):.1e}') # val(x + dx) = val(x) + res(x) dx + .5 dx jac dx