From 34d743790e1c988ac07c308229b04488791eeb3e Mon Sep 17 00:00:00 2001 From: Sebastian Blauth Date: Thu, 4 Jul 2024 07:40:58 +0200 Subject: [PATCH 1/2] add destroy and gc to snes solvers --- cashocs/nonlinear_solvers/snes.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cashocs/nonlinear_solvers/snes.py b/cashocs/nonlinear_solvers/snes.py index 703fef19..07c10b83 100644 --- a/cashocs/nonlinear_solvers/snes.py +++ b/cashocs/nonlinear_solvers/snes.py @@ -225,6 +225,11 @@ def solve(self) -> fenics.Function: if converged_reason < 0: raise _exceptions.PETScSNESError(converged_reason) + if hasattr(PETSc, "garbage_cleanup"): + snes.destory() + PETSc.garbage_cleanup(comm=self.comm) + PETSc.garbage_cleanup() + return self.u From 4febda318a247ba712de2206cf61f88fc8e77802 Mon Sep 17 00:00:00 2001 From: Sebastian Blauth Date: Thu, 4 Jul 2024 07:48:19 +0200 Subject: [PATCH 2/2] fix typo --- cashocs/nonlinear_solvers/snes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cashocs/nonlinear_solvers/snes.py b/cashocs/nonlinear_solvers/snes.py index 07c10b83..e4461e4c 100644 --- a/cashocs/nonlinear_solvers/snes.py +++ b/cashocs/nonlinear_solvers/snes.py @@ -226,7 +226,7 @@ def solve(self) -> fenics.Function: raise _exceptions.PETScSNESError(converged_reason) if hasattr(PETSc, "garbage_cleanup"): - snes.destory() + snes.destroy() PETSc.garbage_cleanup(comm=self.comm) PETSc.garbage_cleanup()