From 9548f0f53a2c0917b2b5d3ce5e21bffe7b85d443 Mon Sep 17 00:00:00 2001 From: acse-ej321 <89605848+acse-ej321@users.noreply.github.com> Date: Mon, 11 Nov 2024 12:22:50 +0000 Subject: [PATCH] #220 remove unused imports and limit final mesh deletion --- goalie/go_mesh_seq.py | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/goalie/go_mesh_seq.py b/goalie/go_mesh_seq.py index e2b577a..cfe365e 100644 --- a/goalie/go_mesh_seq.py +++ b/goalie/go_mesh_seq.py @@ -2,12 +2,10 @@ Drivers for goal-oriented error estimation on sequences of meshes. """ -import os from collections.abc import Iterable from copy import deepcopy import numpy as np -import psutil import ufl from animate.interpolation import interpolate from animate.utility import Mesh @@ -171,13 +169,6 @@ def indicate_errors( ADJ_NEXT = "adjoint" if self.steady else "adjoint_next" P0_spaces = [FunctionSpace(mesh, "DG", 0) for mesh in self] - process = psutil.Process(os.getpid()) # ej321 - - def mem(i): - print( - f"Memory usage {i}: {process.memory_full_info().uss / 1024**2:.0f} MB" - ) # ej321 - # Loop over each subinterval in reverse for i in reversed(range(len(self))): # Solve the adjoint problem on the current subinterval @@ -252,11 +243,11 @@ def mem(i): enriched_mesh_seq.solutions[f][ADJ_NEXT].pop(-1) # delete current subinterval enriched mesh to reduce the memory footprint - for f in self.fields: - enriched_mesh_seq._fs[f].pop(-1) - - enriched_mesh_seq.meshes.pop(-1) - enriched_mesh_seq.time_partition.drop_last_subinterval() + if len(enriched_mesh_seq.meshes) > 1: + for f in self.fields: + enriched_mesh_seq._fs[f].pop(-1) + enriched_mesh_seq.meshes.pop(-1) + enriched_mesh_seq.time_partition.drop_last_subinterval() # clear empty labels for f in self.fields: