From af610aa75566c922cb1b514c41fc3d414f338d2e 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 2b44bbf97..91f3fb784 100644 --- a/nutils/solver.py +++ b/nutils/solver.py @@ -437,7 +437,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